Android Version of ‘BenTV’ Camera Viewer

Before we had the pebble watch seizure detector, I had set up a video camera system in the house so we could keep an eye on Benjamin to see he is ok when he is up in his bedroom (he is autistic so likes to lock himself in there and doesn’t like visitors!).  The current system uses a WansView network (IP) camera and some Raspberry Pi based monitors in the living room, dining room etc. to see and hear what is happening.

I have always liked the idea of having a mobile phone or tablet computer version of the monitor that we can take with us if we are in a different room, the garage, garden etc.  I have had a couple of attempts at writing it, and always failed, so have been doing more investigations to see what is wrong.

There is a minimalist Android app on the OpenSeizureDetector Github repository which will open an RTSP stream from the camera and display it on screen with audio, using the Android MediaPlayer library which is part of the Android system.

The problem is that I kept getting an error:

E/MediaPlayer: Error (1,-2147483648)

which is not awfully helpful – error 1 means ‘Unspecified MediaPlayer Error‘, and all I got was a blank screen.

I tried all sorts of combinations of RTSP url’s and authentication methods, and different video stream sizes and bit rates, in the hope that that would help.   See the Troubleshooting_log.txt file in the repository.  Nothing Did – always got error 1 and a blank screen….

Then I remembered that I have an old Y-Cam Knight video camera in the attic.  I set that up and pointed the app at its rtsp video stream (rtsp://guest:guest@…and I got video and audio – success!

Rapidly decided to scrap Wansview camera and buy another Y-Cam one…But Y-Cam don’t do IP Cameras any more, just ‘Cloud Cameras’ which are apparently different and only transmit when they detect movement, which is no use for me….

So at least I know it is not my software, it is something to do with the wansview camera.   As a fall back I have ordered a D-Link camera, which I have seen reports of working from someone called Josh Smith, and on which I based my minimalist test app.

But that would be giving up, so I’d like to understand what is wrong with the stream from the wansview camera.

From my experiments, Error 1 could come from an RTSP authentication fault, but I don’t think that is it, because the same URL works with openRTSP from my laptop.   So another possibility is a audio/video format issue.   You can use openRTSP to download the raw audio and video streams separately –

openRTSP "rtsp://guest:guest@"

This yields a video-H264-1 and an audio-PCMA-2 file.   You can now use ffmpeg to create a .mp4 container containing either the video file alone or the video and audio combined.

Just video file:

ffmpeg -f h264 -i video-H264-1 -vcodec copy wansview_video.mp4

openRTSP can create a combined audio/video one during the download with:

openRTSP -4 "rtsp://guest:guest@" > audio_video.mp4

But the resulting file crashes mplayer and gives an “unknown error” in vlc.  So I suspect it might be the audio format that is giving the trouble – the ycam camera used amr audio format, not pcma.

A quick check confirmed that the wansview_video.mp4 file plays ok when copied into the res/raw folder of the app and the software modified to play that, rather than the RTSP stream.   So, I think that Android is playing the h264 video ok (which it should according to the Supported Media Formats page.   The problem is probably an issue with the PCMA audio format – PCM is supported, but this must be different to PCMA…

This means that I am not going to be able to write a nice simple App to play the audio and video using the provided Android MediaPlayer library – if I want it, I will have to be cleverer to deal with the audio.  I think the options are:

  • Write it all from scratch (major undertaking!)
  • Use the ffmpeg library that has been ported to Android
  • Use the Gstreamer library that has been ported to Android

I am a bit suspicious about trying to use ffmpeg, as this didn’t seem to like the PCMA on my laptop (although dolphin player, which is based on ffmpeg plays the openRTSP created .mp4 file ok), so maybe Gstreamer is the way to go.   There is an Open Source RTSP viewer available that is based on gstreamer (rtspviewer), or possibly (rtspplayer).

So I’m going to have to learn a bit more about native apps on Android – I had hoped that making a video player would be trivial!


Updated BenTV Video Monitor Camera

The IP camera that I have been using for the ‘BenTV’ video monitors for Benjamin (Benja-Telly as we call it) started to fail (picture started breaking up more and more, and sound was replaced by an awful loud buzz), so I needed a new one.
The one I was using was a WansView pan and tilt wireless IP camera, and I was using an RTSP audio/video stream encoded using H264 codec to display it on the raspberry PI based monitors.
When I bought it I had bought a spare – a cheaper, lower resolution one, so I just installed that and expected it to work. Alas, in addition to being lower resolution, it also used different audio/video formats – rather than H264 video it uses motion-jpeg, and an audio format I have been unable to fathom – basically, to use my ‘spare’ camera would need significant changes to how I play the audio/video on the raspberry Pi.
So, I gave up and bought a new camera – the WansView one had been ok, but its wifi was always a bit weak, and I suspected it ‘jammed’ my wifi network for a while if you switched off one of the monitors, so I thought I’d try a different manufacturer. FosCam seemed quite popular, so I went for a FosCam FI9821W Version 2.

All started very promising – plugged it into an ethernet port on my router, and I could see it connect to the router and receive an IP address. Pointed a web browser to the correct IP address and I could access the admin interface and tell it to connect to my wifi network. I thought I ought to upgrade to the latest firmware before I commission it, because I know I’ll not touch it once it is working, so I used the admin interface to download the latest firmware from FosCam and then install it.

It was at this point that I suffered a sense-of-humour-failure because under the new software you can not log into the camera unless you have installed a browser plugin…..and that browser plugin only works on Windows, but my computers all run Linux…. Now I don’t mind Linux not being fully supported because I know most users of a commercial product will use Windows…but I do object to it working with Linux then stopping when the firmware is upgraded. I found a very bad tempered forum ‘discussion’ about it from last year, but no apparent answer.

I tried a factory re-set, but that came back with the new firmware.  I tried downloading some older firmware from the FosCam web site, but that did not seem to do anything (newer firmware retained).   Got very tempted to send the thing back….

In the end I got it working by installing the Wine windows ’emulator’ for Linux, and the ‘winetricks’ tool to install extra things (sudo apt-get install wine winetricks), and used winetricks to install the windows version of the firefox web browser.  With that I can download the browser plugins from the camera and access the admin interface.   Not Ideal!

Using Raspberry Pi as an IP Camera to Analogue Converter

I have an old-fashioned analogue TV distribution system in our house.   We use it for a video monitor for our disabled son so we can check he is ok.
The quality of the analogue camera we use is not good, but rather than getting a new analogue one, I thought I should really get into digital IP cameras.
I have had quite a nice IP camera with decent infra-red capabilities for a while (a Ycam Knight).   You can view the images and hear the audio on a computer, but it is not as useful as it working on the little portable flat panel TVs we have installed in a few rooms for the old analogue camera.

I am trying an experiment using a raspberry Pi to take the audio and video from the IP camera, and convert it to analogue signals so my old equipment can be used to view it.

What we have is:

  • IP Camera connected to home network.
  • Raspberry Pi connected to same network.
  • Analogue video and audio signals from Pi connected to an RF modulator, which is connected to our RF distribution system.

Using this I can tune the TVs on the RF distribution system to view the Raspberry Pi output.

I set up the Pi to view the audio and video streams from the IP camera by using the omxplayer video player, which is optimised for the Pi.   I added the following to /etc/rc.local:

omxplayer rtsp:// &

Now when the Pi boots, it displays the video from the IP camera on its screen, which is visible to other monitors via the RF modulator.

My concern is how reliable this will be – I tried earlier in the year and the Pi crashed after a few weeks with a completely mangled root filesystem, which is no good at all.   This time I am using a new Pi and new SD card for the filesystem, so I will see how long it lasts.