Labels

Showing posts with label video. Show all posts
Showing posts with label video. Show all posts

Wednesday, 21 December 2022

Chromecast

About eight years ago we purchased a small Samsung "Smart TV".  At the time we thought it was very clever as it has an ethernet connection which allowed us to use an inbuilt web browser and iPlayer.  Subsequently  it was used as a computer screen and to play media from a DLNA server.

I now want to integrate it with Home Assistant so that we can start and control videos as we do for music.  Unfortunately the Smart TV is not smart enough for this so I purchased a Chromecast to help it.

Chromecast installation and testing

As expected there is a slick installation procedure and I soon have the Chromecast working on HDMI with the usual apps such as Netflix, ITVhub available.  

Chromecast provides extra connectivity capabilities.
We can easily cast youtube or iplayer from the phone to Chromecast.
On the ipad we can cast from youtube, vlc or iplayer.
On the PC we can cast a chrome browser session to the TV allowing us to see whatever is displayed or playing in the browser.  Alternatively you can cast videos from the youtube app or vlc.
All these facilities are great but I probably wouldn't use them much in practice, so I now need to see what extras Home Assistant can offer.

Home Assistant

HA has a Google Cast integration built in and uses it to send speech or music to the Google Nest mini.  As far as HA is concerned the TV, with Chromecast attached, is just another casting device.



Using the "Browse Media" button on the card for the TV you can select a video from the DLNA server or local media and play it on the TV.  This is a great start, we can already play videos of our choice and it is as simple to use from HA as it is selecting DLNA directly on the TV.

Looking at the sample in Google Cast integration  it is easy to setup a script to cast a video to the TV.  The service is media_player.play_media, the target is media_player.john_study_tv and you just need to provide a URL and type for the media content. Running this script causes the video to play.  Now that I have a script I can use a webhook or Google Assistant command to initiate the video so I have the basis of a solution.


Clearly it is rather limiting if I have to setup a script for each video I want to play so I setup a helper, called xmas_anthem for testing.  I can can setup a number of valid options for xmas_anthem and set the value on a dashboard card.  Within the script I can now test input_select.xmas_anthem to determine which video to play.

You can also play youtube videos by specifiying suitable media_content details:


Since our first test was to play a video from DLNA it must also be possible to specify a DLNA video as the media_content.  This doesn't seem to be simple.  When looking at a DLNA video playing I can see that the media_content_id is a URL containing a numeric value (5240.mkv in the example shown below) rather than a filename.   To determine these values I would need to interrogate the DLNA server.  I have a python script which sort of does this but it doesn't work well yet.

Conclusion

I now have the tools I need to play videos on a TV, namely ChromeCast and Home Assistant scripts.  The next stage is to work out what videos I want and setup a webpage or voice commands to play them.








 




Wednesday, 22 April 2020

Floureon IPCAM

A little while ago I purchased a very cheap Floureon Wifi IP Camera webcam.  It comes with a short user guide to setup the device.  You start by downloading the Camhi software onto your phone or ipad.  The webcam has wifi and ethernet connections.  You introduce the handheld device to the webcam by holding them physically close together and allowing the ipad to start an audio dialog with the webcam to establish its ip address.  Once they have "paired" in this rather novel fashion you can look at the camera output on the ipad and swipe in any direction on the screen to pan/tilt the camera so that it shows what you want to see.  The picture quality is detailed and clear with good colour, sound is also available, I found the movement functions tedious.  You can take snapshots or record videos and optionally save them to an SD card. I couldn't find any further details about the webcam online so at face value you have a very nice webcam with an interface to a handheld device.

My current application requirement is to provide a nightime garden webcam to look for activity, particularly from foxes.  I need to record video when motion is detected in the picture so that it can be looked at the next day.   I have a Raspberry pi noir webcam which isn't being terribly useful for this purpose although it did previously carry out great service as a puppy cam in our kitchen.

As the supplied CamHi software doesn't have the functions we require (in particular motion based recording), it is necessary to find other ways to access the webcam via its network interface. A very helpful open source site ispyconnect provides details of URLs which can be used to access webcams.  We know our ip address 192.168.0.175 and user/password admin:admin.
To take a snapshot from the camera we can use a chrome URL:
 http://admin:admin@192.168.0.175/snap.jpg
To stream a video from the camera we can Open a network stream in vlc with:
 rtsp://admin:admin@192.168.0.175/1/h264major
The video can be streamed at a lower resolution with:
 rtsp://admin:admin@192.168.0.175/2/h264major

For the picamera we have previously used linux motion software very successfully to process a video stream and record only when motion is detected.  We can utilise the stream coming from the webcam by specifying in motion.conf configuration file netcam_url the rtsp streaming address.  Once we restart the motion service (on RPi pi34) we can view camera output at http://pi34:8081.

I am quite keen to be able to be able to control pan/tilt from linux or PC.  I found that I can login to its network interface http://192.168.0.175.


In addition to showing the camera view it allows me to use pan and tilt.  "Left and right", "up and down" buttons cause the camera to scan throughout its range.  You can view two streams, full detail  (1280x720) or smaller (640x352).  There are 8 preset positions you can setup.

The settings tab is informative, allowing you to see/set many more features on the camera (e.g. turn IR on / off).  The network page includes settings for ONVIF, which is already on at port 8080.  This should allow me to use a general purpose ONVIF client to control the camera.  ispyconnect has a suitable client Agent DVR which I could install on Windows.


After a little experimentation I was able to setup the camera in ispy Agent UI and see the camera.  It also gives me a device service URL http://192.168.0.175:8080/onvif/devices .  Using Ispy PTZ controls are a bit better.

I was now ready to try out the solution.  It turns out, quite reasonably, that infra red light reflects well off glass (which is designed to let optical wavelengths through) so attempts at a setup inside were not successful.  As the weather is good I took the IPCAM outside and set it up in the garden.  Using the web interface I set the IR leds on continuously.  I setup linux motion software to record when movement is detected.  I set the sensitivity quite high to capture small changes, and I did capture various moths / insects whizzing by, but I did also see the fox doing his/her evening walk across the garden just before midnight.  The motion software worked well, it only recorded about 5 minutes video overnight so it isn't onerous to look through the recording.







Monday, 7 January 2019

Watching TV without an aerial

Problem

Until recently my upstairs TV was near to an aerial socket.  I have moved it to a room without an aerial but still want to watch programmes which are available through DVB (Digital Video Broadcast).  I have a Samsung Smart TV which has an ethernet/internet connection so I figure there should be a good way to stream "broadcast" channels to the TV.  My preference is for a solution which doesn't require extra hardware purchase or a subscription and it must be simple / non-technical to use.

Approaches

1 Use a (free) app on the smart TV
2 Cast programmes from an Android/IoS device
3 Play in a TV web browser session - tortuous
4 Use an extra hardware box - not that interesting
5 Use an RPI to send a stream to the TV

App (Smart IPTV)

My TV has about 100 apps which can be used to watch content.  iPlayer, all4 etc are very good but only when you want to watch a particular programme or channel.  I want a more general ability to change between any available channel.  Many of the apps such as Amazon, Netflix require a subscription and provide access to premium content; as the TV is used only occasionally this is not appropriate for me.  There are many more specialist apps which are of no interest.
Google pointed me to tvplayer which works on Samsung and shows a good range of channels.  It works well on an iPad or in a PC browser window.  Unfortunately it is not supported by my Samsung TV(s).

After further investigation I settled on using the Smart IPTV app.  It doesn't actually provide any IPTV channels but allows you to create and save your own list of channels which you can then play.  It has a nice interface so that you can see whats on using an EPG (Electronic Programme Guide) and you can surf channels using the TV program button.  It is available for both my Samsung TVs.  There is a one-off £5 subscription per device so that you can upload your channel list to their website and then download it to the TV based on Mac address.  However you can try it for a week to see if it works before paying up.

I found streaming URLs (google online tv stream url)  without too much difficulty.  

Casting

I tried casting from my (old) iPad and Samsung S5 Neo.  Both of them allowed youtube to cast (the old large Samsung TV was very temperamental) but I didn't find other apps. On the S5 you connect using Quick Connect and you are then able to play local videos and music from the phone. 
I also have an apple cable to connect my iPad to a TV.  That works when playing xvid or hdtv films with vlc.  It also works quite well playing TVplayer on the iPad and allows iPlayer and youtube. I foresee few occasions to use this in practice.



Monday, 17 September 2018

Floureon Pan Tilt IP Camera

Why?

A floureon Pan Tilt wifi ipcam only costs £20 on eBay.  I was intrigued whether it would be any good and whether I could control it from RPi based software.  It echoes my first linux project challenge from 2002 when I had a logitech webcam controlled by an Eagle Pan Tilt mechanism and used it at work to see whether my program to turn a  home light on and off was working.
I am not sure what I would use this for - I think I will just experiment with it and see what I can make it do.

Installation

A short but helpful pamphlet tells you how to set up the webcam.  You download the CamHi app to an iPad or Android device first.  You then add a camera.  The install procedure can find the webcam through wifi and you then put your phone next to the camera and it has an audio hand-shaking procedure to link the app with the phone - it sounds somewhat like old modems talking to eachother.
The app shows you a webcam feed and you can swipe up / down / left / right to move it - however it is very ungainly.

Documentation on the floureon website is rather sparse but contains useful info on features.
Motion tracking, IR and two-way sound all should be investigated.  It says that the movement controls have no lag but that was not my experience.  
It says that the windows client is CMS software.  I downloaded what seemed the appropriate software from the website but I couldn't get either utility, DeviceViewer or SriCam, to see the web cam.

There is an option to check for firmware upgrades, so I upgraded firmware.

Extra Software

I looked briefly at ISpyConnect to see if that would work on windows.  It has some good documentation and I managed to get the URL rtsp://hostname:554/11 to view the video feed.  It seemed a bit cumbersome to use so I installed a nice utility anycam instead.  I could also see the video feed using vlc with this url.

Other URLs which work are rtsp://hostname:554/1/h264major (in VLC) and http://hostname/tmpfs/auto.jpg in Chrome.  The directory tmpfd/* is visible in chrome but doesn't have much of interest in it.  However it does confirm that the webcam contains an embedded linux server.

In fact I found that http://hostname/ gives access to an inbuilt webserver and also allows pan / tilt control.  The buttons remain pressed whilst you click down on them.  Unfortunately there is a 2 second lag on the picture update so it isn't practical to adjust the camera this way.  However there are 8 presets which can be used to set positions and you then "call" them.  In practice this should be enough.

Using Chrome Developer tools you can look at the programs used on the webserver.  I managed to copy all the files I could find down to a Windows folder to see whether they would work locally.    The server uses flash to show video in the browser and I couldn't (easily) get flash to work locally on my Windows PC running video from the IPCAM.  However I did see that the site is written in html/css/javascript.
In particular the commands to control the webcam work through cgi.  Thus I can move the camera left a bit using http://hostname/cgi-bin/hi3510/ptzctrl.cgi?-step=1&-act=left.  This would allow me to set up webcam control very easily.  Googling hi3510 gave me a list of commands that can be used.

Verdict

The camera gives a very nice picture but the lag is quite irritating when you are in the same room.  It would be simple to setup a web page to control the camera and keep the image in a separate session in vlc or anycam.
It would also be easy to setup periodic room scans.
It is also an amazing package a pan-tilt camera accessed via in built webserver for £20.