A while back, I wrote a script to do a live screencast of your desktop to a smart TV. I am planning to continue development on that in order to make it more user-friendly. I will update this post with my progress.
May 27, 2015
I tried the old scripts and verified that they can be made to work on Ubuntu 15.04 (Vivid Vervet) on a Samsung UE40H7005 TV (2014 model).
Ffmpeg is deprecated in Ubuntu, so I am using avconv instead, adapting a command line that user Avio posted in a comment here. In the file dlna_fuse.py, replace the command line in class DlnaFuse with this:
cmd = ("parec -d %(pulseaudio_monitor)s | " " avconv -f x11grab -s 1280x720 -r 30 -i :0.0+0,0 -ab 192k " " -f s16le -ac 2 -ar 44100 -i - " " -vcodec libx264 -crf 30 -preset ultrafast -tune animation -threads 0 " " -acodec libmp3lame -f matroska - " " | %(live_filter)s - ") % locals()
This captures a 1280×720 section of the screen at 30 frame per second and the audio that is played by Pulseaudio and encodes them as H.264 video and MP3 audio in a Matroska container.
In my test, I started the capture two minutes before starting playback on the TV, and I kept streaming for about half an hour. Worked nicely. Next I will see how far I can bring down the latency.
June 2, 2015
Currently, the scripts require several parts to work together: The screen capture is filtered and served up by a FUSE filesystem and served via UPnP by a media server like Mediatomb.
To simplify this, I want to get rid of the FUSE filesystem and package my own UPnP server. Right now I am investigating a UPnP framework written in Python that looks promising: Coherence.
The idea is to write a modified version of Coherence to serve the live stream. When the TV client requests the stream, the screen capture can be started automatically, and the necessary filtering can happen on-the-fly inside the server, circumventing the FUSE filesystem, and removing the need for installing too many additional pieces of software.