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@192.168.1.18/live_mpeg4.sdp)…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@192.168.1.25/12"

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@192.168.1.25/12" > 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!

 

Fixed Problem with Google Play Listing

Michael Long has reported a problem with the Pebble Seizure Detector Server App which is that if you have a device that does not have mobile telephony capability, the seizure detector app does not appear in the Google Play store listing for the device.   This is because the app has the capability of sending SMS alarms, but this feature will not work if the device does not have a mobile phone included.

I have just uploaded an update to the app, which makes telphony optional, which should fix this and allow the app to be installed on tablet computers etc. that do not include mobile phones.   This should appear in Play store in a few hours time.  I don’t know how to test if this minor change has fixed the problem or not though, so there may be another attempt later….

For those who struggle to install it through Play Store, I have included the compiled version of the app in the Github Repository so you can download it from there and follow Mike’s instructions for installing it.

Thanks for reporting this, Mike!

EpilepSEE – Mike Long’s Videos

Screenshot from 2015-08-09 13:24:05

Mike Long from epilepSEE has posted some very helpful videos on his Facebook page, which demonstrate how to set up and install the seizure detector on the Pebble Watch and Android. You can see his videos below and can reach his Facebook Page by clicking on the logo above.

Introduction

Getting a Phone

Installing Pebble Software

Installing OpenSeizureDetector

A Slight Problem

Completion of Pebble and Android Software Installation + How it Works

Seizure Detector Warning ‘Pips’

pebble-screenshot_2015-04-04_22-15-57A new version (v1.11a) of the OpenSeizureDetector Android App is now available on Google Play Store.

This fixes an issue where brief interruptions in communications between the watch and the phone (I don’t know what causes it!), results in the phone app issuing fault warning ‘pips’ until communications are restored.   This is usually only a few seconds, but it is annoying!

The new version introduces an Screenshot_2015-03-22-17-06-29extra time out period where the app waits for data from the watch before it issues the fault warning noise.   You can change the timeouts in the settings menu in the app if necessary.

See Pebble Watch Seizure Detector for more details.

Are there any other annoying ‘features’ that users would like to see fixed?

Graham.

New Version of Pebble Watch based Epileptic Seizure Detector

pebble-screenshot_2015-04-04_22-15-57Today I have published a new version of the Pebble Watch App Seizure Detector and the associated Android Server App (Versions 1.1 and 1.10 respectively)

The system is designed to monitor for a tonic-clonic epileptic seizure by detecting movement of the wrist, and raise an alarm so a parent/carer can check on the person suffering the seizure.

Screenshot_2015-04-04-22-09-47Details of what it does and how it works are available on the Pebble Watch Seizure Detector page of the OpenSeizureDetector.org.uk web site.

These changes mean that I have added all of the functionality that I intended to provide for the system, so it is essentially ‘finished’.

The will of course be bugs and ‘features’ that I can address, but I do not envisage any major changes in functionality now, unless someone has a bright idea for something to add that I have not thought of!

As always, comments and information on testing results would be much appreciated (email graham@openseizuredetector.org.uk, or http://google.com/+grahamjones).

There are a few other people working on seizure detection at the moment – have a look at the Similar Projects page for links to them.

Improved Fault Warnings

I have noticed that most people use the Pebble Seizure Detector app as a background service and rely on the audible beep warnings to prompt them to check on the person wearing the seizure detector watch.

This is fine as long as the whole system is working – watch paired with server phone and client devices connecting to server ok.

I have had some issues with the server disconnecting from the pebble watch if it goes out of bluetooth range for a while (only has to be a few minutes).   The main app screen shows up warnings in bright red if you look at it, but that only works if it is on the screen.

To get around this I have just added system fault warning ‘chirps’ (very short beeps) to both the server and client apps if there is a general system fault such as not being able to communicate with the pebble, or connect to the server – these should appear as version 1.8 of the server app and version 1.3 of the client in the app store sometime today (Sunday 22 March 2015).

Updated Android App for Pebble Based Seizure Detector

Screenshot_2015-03-03-23-15-19A few improvements to the Android App associated with the pebble based seizure detector over the last couple of days.

  • Version 1.2
    • Updated service so that alarm beep will sound even if main app display is not visible.
  • Version 1.3
    • Added logging to sd card – records data to sd card regularly (every minute) and when a warning or alarm is raised.
    • Added app version number to main display so users know which version they are using to report issues.

Version 1.3 should appear on the Google Play Store in a few hours.

Benjamin wears his new watch

Benjamin wearing his new Pebble Watch Seizure Detector
Benjamin wearing his new Pebble Watch Seizure Detector

Quite a success today – Benjamin is tolerating wearing his new Pebble Watch Seizure Detector – pressure on me to get the Android alarm server application working properly now!

We have had a couple of spurious alarms from some of his more ‘odd’ behaviours, but when he is bouncing around like that he is so noisy that we know he is ok, so that’s not such a concern.

 

(For an explanation of why an 18 year-old wearing a watch is a success, see About Benjamin).

 

 

Pebble Smart-Watch Version – Progress Update

The Pebble Smart-Watch seizure detector is looking very promising.   The software to run on the watch itself seems to be quite reliable at detecting shaking, without giving false alarms during normal activities.

The watch application is published on the Pebble App Store.

diagram

 

We have a rudimentary android app working that talks to the Pebble watch and acts as a web server that clients can query to get the alarm status etc.   This is on the Google Play Store.

You can see a demo here:  https://plus.google.com/+GrahamJones/posts/P9mWstgqP8N?pid=6111006693838101826&oid=106497137253664241170.

The main issue currently is that it works fine with the phone plugged in and charging, but if it is running on battery, the web server goes to sleep so does not work.   For my application this is ok, because we will always be using it in the house, but for it to be useful for others we may want it to work outdoors – I think there is an android permission to stop the phone sleeping that I will have to use.

But, looking promising!

All source code is on the project Github Repository.