VDR on Smart TV contains one server plugin and (currently only?) one client widget. The Client Widget runs on a Samsung Smart TV (TV or Blue Ray Player) and fetches the needed information using HTTP from the smarttvweb plugin. The plugin also exposes a Web GUI so that you can access your recordings conveniently from your PC, SmartPhone or Tablet.
A description of the Samsung Smart TV client is here.
The smarttvweb plugin implements a simple (single threaded) Web Server. It supports multiple simultaneous HTTP sessions, including HTTP Byte Range support for seeking and trick play. The recordings are not duplicated, transcoded or re-formated. The plugin cuts the media segments and HTTP range requests from the TS or PES recordings.
As default, the plugin server listens on port 8000
. No extra libraries (beside pthread) are needed for the plugin. Just compile and load it.
- Table of contents
- Introduction
- Server Plugin HTTP Methods (for Metadata)
- HTTP GET on Metadata
- Getting the list of Recordings
- Getting the list of Live Channels
- Getting list of Media items
- Getting list of URLs
- Getting EPG data for Live Channels
- Getting Status of VDR
- Getting VDR Server name
- Getting Resume
- Setting Resume
- Delete Recordings
- Delete Media
- Get Recording Commands List
- Execute a recording command
- Get Commands List
- Execute a command
- Get Timers
- Add a Timer
- Delete a Timer
- Activate or deactivate a Timer
- Get Cover Image (iTunes covr) from MP4 media items
- HTTP GET on recordings and media items (Streaming of recordings and other media)
- HTTP POST
- HTTP GET on Metadata
- Plugin installation
- Plugin Configuration: smarttvweb.conf
Introduction¶
Plugin Features¶
- Streaming of .ts and .pes recordings as HTTP stream
- Formats: Progressive (PES and TS), HLS (TS only) and MPEG-DASH / OIPF HAS (TS only)
- Seeking and Trickplay (Support for HTTP range request header)
- Different HTTP Methods (get and set)
- Recording, Channel and Media lists
- Storage of YouTube Urls
- Recording deletion: The plugins allows deletion of recordings
- Resume support: The server plugin stores resume information for each recording
- Status: The server plugin provides information about HD utilization.
- Notification: The plugin notifies clients if the clients register themselves (limited to Samsung TVs only).
- Log: Clients can send log message to server via HTTP
Clients¶
Samsung Smart TV (TVs and BD Players of Samsung's D- (limited), ES- Series and newer Series)
Prime objective for the plugin development was to get VDR Recordings shown in according quality on the TV. I used a Hauppauge MediaMVP with VOMP to get my recordings from my VDR PC onto the TV screen. However, the MVP only has a Scart-Connector. I didn't find any good streaming client for the VDR with HDMI output. After I bought my new TV, I found the SmartTV functions, the built-in Video-Player functions and the possibility to develop own Widgets (HTML, CSS and Javascript).
There is a good chance, that the client can be adjusted to other SmartTVs. Almost all new TVs include SmartTV functions. In particular the remote control key handler and the player object interaction would require adjustments.
Android (Playback of Recordings)
Although the prime objective of the plugin is to serve recordings to TVs, I also tested with Android based SmartPhones (via WIFI). Also seeking is working. There are several Android Media Players, which offer MPEG2 decoding (MX Video Player for example). Since the recordings are not transcoded, and SD Channel are still MPEG2 encoded. A Web GUI (using jQuery Mobile) allows convenient access to your recordings. Check http://<server>:8000/web/index.html
.
Note, the HTTP streams are provided at full TV quality. Running the HTTP streams over public mobile networks to mobile phones may generate high charges due to the high bitrates. Further, the server plugin is not tested from a security perspective for public Internet usage.
VLC (Playback of Recordings)
The server plugin exposes recordings as HTTP progressive stream. The VLC player can render the HTTP stream (ts and pes recordings) and supports seeking (fast forward and rewind). A Web GUI (using jQuery Mobile) allows convenient access to your recordings. http://<server>:8000/web/index.html
. Note, you may need to install the VLC Mozilla plugin.
Chrome (Smart TV GUI testing only)
The GUI loads through a Chromes browser, if you uncomment the publicly available jquery library in index.html (the TV pre-installed library is used as default). Navigation is possible through the cursor keys (left, right, up, down, ESC and enter). Video Playback does not work, since the Player APIs are different (later maybe). You need to set serverUrl
in Config.js (see Installation Section) to guide the browser to your server. Further, you either locate the client software on the server (i.e. in Media Folder, see Configuration Section) or you allow Cross-Domain Ajax.
VIP
See http://projects.vdr-developer.org/projects/vdr-vipclient
Known Issues
- The plugin is NOT tested for open Internet usage (Security). The plugin allows anybody to write into your log file, delete recordings, etc.
Future Features¶
- Update of available Recordings
- Auto-Discovery of servers
- Code cleanup
Why a plugin realization?¶
In order to get all recordings rendered by a Smart TV, the recordings need to be provided as HTTP stream from a web server. For seeking and trick-play, the web-server needs to support HTTP range requests on the recordings. My Samsung fetches the end of a progressive stream to get the precise play duration information. Therefore, a progressive stream is not suitable for "Playback while recording". The end of the stream is not yet recorded. The only work-around is using Apple HLS (m3u8) or MPEG-DASH (mpd). Further, there is no need to re-format the recordings, as a Smart TV can read a ts and a pes recording as is.
Since I have not found a suitable solution for getting my recordings as HTTP stream, I started a new plugin. Since I started a plugin, it was easier to get all metadata through new HTTP APIs than parsing it out of SVDRP. It should be possible to make the server plugin obsolete in future.
The work is inspired by the VOMP plugin, which brought a nice and VDR-tailored GUI onto the MediaMVP.
Now, the plugin offers additional functions such as set resume position, get vdr disk utilization, etc to improve the Smart TV client look and feel.
Screenshots of the Web GUI¶
See the Widget Wiki page for more Widget Screenshots (link).
Browser GUI (Mobile Optimized) | |
http://<server>:8000/web/index.html |
Getting list of Recordings and Live Channels as HTML page¶
http://<host>:8000/web/index.html
Provides an HTML page with the list of recordings. I started it due to plugin testings, but... The GUI uses Progressive URL as default. Accessing your recordings as m3u8 Playlist (type=hls
) or as MPD (type=has
) may be supported in future.
Server Plugin HTTP Methods (for Metadata)¶
HTTP GET on Metadata¶
Getting the list of Recordings¶
http://<host>:8000/recordings.xml[?type=[has|hls]][&model=samsung][&mode=nodesc][&guid=<guid>]
Provides a list of recordings in XML format. The URL to the recoding is either a Progressive URL (no type parameter), a URL to an m3u8 Playlist (type=hls
) or a URL to an MPD (type=has
). When the parameter model=samsung
is added, then the URL follows the URL format of Samsung Smart TV (Link). Tailoring to other devices should be possible, when needed.
If guid=<guid> is present, then only a single entry (as specified by guid) is provided.
XML structure follows roughly an RSS format:
<?xml version="1.0" encoding="UTF-8"?> <rss version="2.0"> <channel> <item> <title>Title of the Recording</title> <link>URL of the recording</link> <enclosure url="URL of the recording" /> <guid>GUID of the recording, needed for forming a delete request</guid> <programme>NA</programme> <description>Description of the recording</description> <start>Time and date of the recording</start> <duration>Duration of the recording</duration> </item> ... </channel> </rss>
Getting the list of Live Channels¶
http://<host>:8000/channels.xml[?channels=<no>][&mode=nodesc]
provide the list of Liver Channels in XML format. Viewing Live Channels require the streamdev
plugin. The query attribute channels=<no>
allows specifying the number of live channels to be described in the response.
<?xml version="1.0" encoding="UTF-8"?> <rss version="2.0"> <channel> <item> <title>Title of the Channel</title> <link>URL of the Live Channel (streamdev plugin required)</link> <guid>-</guid> <programme>Name of the current program</programme> <description>Description of the current program</description> <start>Time and date of the current program</start> <duration>Duration of the current program</duration> </item> ... </channel> </rss>
Getting list of Media items¶
http://<host>:8000/media.xml
Provides a list of media items, which are stored in a special media folder (configurable, see below). Prime intention is to quickly bring .avi
, .mkv
or .mp4
recordings into the system (e.g. phone cam recordings). Also, entire VDR directories are recognized, e.g. when you copy the directory from another hard-disk into the system. Note, in case of MP4 media items, the plugins parses the iTunes Metadata out of the file, specifically title, description. If an cover image is embedded in the MP4 file, then the image can be fetched using the http://<host>:8000/mp4covr?guid=...
function (see below).
Getting list of URLs¶
http://<host>:8000/urls.xml
Provides a list of GUIDs for e.g. YouTube functions.
Getting EPG data for Live Channels¶
Allows querying EPG data for current and next programs of a given channel.
http://<host>:8000/epg.xml?id=<guid of the channel>&mode=nodesc
Getting Status of VDR¶
http://<host>:8000/vdrstatus.xml
Getting VDR Server name¶
http://<host>:8000/serverName.xml
Getting Resume¶
http://<host>:8000/getResume.xml?id=<guid>
Method: GET and POST
Setting Resume¶
http://<host>:8000/setResume.xml?id=<guid>&resume=<pos in sec, float>
Method: GET and POST
Delete Recordings¶
http://<host>:8000/deleteRecording.xml?id=<guid>
Method: GET
Delete Media¶
http://<host>:8000/deleteFile?id=<guid>
Method: GET
Get Recording Commands List¶
http://<host>:8000/reccmds.xml
Method: GET
Execute a recording command¶
http://<host>:8000/execreccmd?cmd=<cmd_id>&id=<guid>
Method: GET
Get Commands List¶
http://<host>:8000/cmds.xml
Method: GET
Execute a command¶
http://<host>:8000/execcmd?cmd=<cmd_id>
Method: GET
Get Timers¶
http://<host>:8000/timers.xml
Method: GET
Add a Timer¶
http://<host>:8000/addTimer
Method: GET
Delete a Timer¶
http://<host>:8000/deleteTimer
Method: GET
Activate or deactivate a Timer¶
http://<host>:8000/activateTimer
Method: GET
Get Cover Image (iTunes covr) from MP4 media items¶
http://<host>:8000/mp4covr?guid=<guid>
<guid> is the value of <guid> XML element, which is provided with http://<host>:8000/media.xml
(see "Getting list of Media items" section)
Method: GET
HTTP GET on recordings and media items (Streaming of recordings and other media)¶
Progressive¶
The actual URL of the recording is provided with the /recording.xml
file. If the URL ends with http://<host>:8000/.../2012-04-20.23.56.99.99.rec
(no trailing slash), then the VDR recording is provided as progressive stream. Byte Range requests on recordings are supported. PES recordings are always only offered as progressive stream.
MPEG-DASH / OIPF HAS¶
The URLs in DASH format are provided, when the /recordings.xml
is requested with the type=has query parameter. A DASH MPD is generated for a recording, when a request of a recording is ending with http://<host>:8000/.../2012-04-20.23.56.99.99.rec/manifest-seg.mpd
. Note the manifest file is generated by the plugin. The bitrate used in the MPD is calculated from the file size. A correction factor is defined in smarttvweb.conf.
Note, my Samsung supports only urn:mpeg:mpegB:schema:DASH:MPD:DIS2011
, which is a pre-version of MPEG-DASH. Additional formats may be supported (tailored through query attributes) when needed.
Apple HLS¶
The URLs in DASH format are provided, when the /recordings.xml
is requested with the type=hls
query parameter. A m3u8 playlist is generated for a recording, when a request of a recording is ending with "http://<host>:8000/.../2012-04-20.23.56.99.99.rec/manifest-seg.m3u8"
. Note the playlist file is generated by the plugin.
Media Segments¶
A media segment for a recording is generated, when a URL in form of "http://<host>:8000/.../2012-04-20.23.56.99.99.rec/N-seg.ts"
is received. N
is here the segment number. The segment duration (e.g. 10sec) is plugin-wide unique and configurable.
HTTP POST¶
log collection¶
An HTTP post on http://<host>:8000/log
allows upload of a log message.
Plugin installation¶
The following description assumes an Ubuntu VDR (1.7.22) installation. It assumes that the Ubuntu package vdr-dev
and other compilation packages are installed. Additional libraries are not needed.
cd $YOUR_WORKING_DIR wget http://projects.vdr-developer.org/attachments/download/1307/vdr-plugin-smarttvweb_096.tgz # fetch the highest plugin version from http://projects.vdr-developer.org/projects/plg-smarttvweb/files tar xzvf vdr-plugin-smarttvweb_096.tgz # tar is assumed to unpack a smarttvweb folder. # Server Plugin subfolder cd smarttvweb make all # VDR header files are assumed to be in ../../.. (default). sudo /etc/init.d/vdr stop # Ubuntu VDR folder is in /usr/lib/vdr/ sudo cp libvdr-smarttvweb.so.1.7.22 /usr/lib/vdr/plugins/ # Ubuntu VDR config folder is in /var/lib/vdr/ sudo mkdir /var/lib/vdr/plugins/smarttvweb # widget.conf contains configurations for the SmartTV Widget sudo cp widget.conf /var/lib/vdr/plugins/smarttvweb # web folder contains html and js for the web frontend sudo cp -r web/ /var/lib/vdr/plugins/smarttvweb # smarttvweb.conf contains the server plugin configurations sudo cp smarttvweb.conf /var/lib/vdr/plugins/smarttvweb sudo chown -R vdr:vdr /var/lib/vdr/plugins/smarttvweb # Modify config file (in particular LogFile and MediaFolder items) sudo vi /var/lib/vdr/plugins/smarttvweb/smarttvweb.conf ...do your adjustments in smarttvweb.conf... sudo /etc/init.d/vdr startTest the correct functioning of the plugin by using a browser and a VLC player:
http://<host>:8000/widget.conf
and a small XML file should appear.http://<host>:8000/web/index.html
and the Web GUI to the recordings is shown.http://<host>:8000/recordings.xml
and a list of recordings should appear.- Play a recording through a media player such as VLC. The recording-link should be of form
http://<host>:8000/.../2012-04-20.23.56.99.99.rec
(no trailing slash). Copy a link from the recordings.xml page and paste it into VLC's network media Url field. The video should start playing. Seeking should also work.
Further, the streamdev
plugin is needed for playback of Live TV.
Troubleshooting¶
If a browser like firefox renders an empty recordings listing (although there should be recordings), then there are likely charset issues. The XML parser expects a UTF-8 charset, which has a certain way to encode Umlaute. If your system has stored the text in Latin-1 (ISO 8859-1), then many parsers throw exceptions.
Open http://<host>:8000/recordings.xml
in your favorite browser like Firefox. Press Ctrl+U
to view the page source. Check, whether you already see some strange characters.
Save the Page Source with File->Save As
. Run the saved xml-file through xmllint or upload it to an Online XML validator like validome.org. Let it find the errors.
If the xml validator finds some errors, then fix them manually.
If the xml validator finds many errors, then use a script around the linux tool iconv.
Plugin Configuration: smarttvweb.conf¶
The smarttvweb.conf
contains plugin configurations.
#LogFile /tmp/smarttvweb.txt MediaFolder /multimedia/video SegmentDuration 10 HasMinBufferTime 30 HasBitrateCorrection 1.2 LiveChannels 30 GroupSeparators EmptyFolderDown #ServerAddress 127.0.0.1 #ServerPort 8000 #Commands enable
LogFile: Uncomment to enable logging.
MediaFolder: Folder to read when selecting "Media" Item in the TV Widget (or fetch http://<host>:8000/media.xml
). The server plugin also allows fetching the content of the Media Folder and all subfolders through http://<host>:8000/multimedia/video/
(Path according to MediaFolder config in smarttvweb.conf
).
SegmentDuration: Media segment duration fot HLS and HAS content
HasMinBufferTime: value for the minBufferTime MPD attribute (HAS).
HasBitrateCorrection: Correction factor for bitrate attribute in MPD. The bitrate is determined from file size and play duration.
LiveChannels: Number of Live Channels listed in http://<host>:8000/channels.xml
GroupSeparators: Handling of group separators in channel.conf
ServerAddress: Server address, if the plugin should not listen on all interfaces.
ServerPort: Server port, if the plugins should listen to a different port than port 8000.
Commands: If enabled, the plugins allows execution of commands from recmds.conf and commands.conf. Careful, ensure that only authorized hosts get access to the plugin (e.g. firewall protected).