Live TV & DVR in Plex Media Server

Finally found an IPTV provider with Hungarian channels (wanna replace my https://freesat.sk/ cause we don’t watch TV so much), https://huntv.net/ but can’t find their terms before paying them (waiting for reply huntvnet@gmail.com). Tried the test which works flawlessly in Plex Media Server via xTeVe https://github.com/xteve-project/xTeVe

Live TV channel settings
Live TV channel guide
Live TV channels guide refresh

Mosaic/grid view of RTSP streams with ffmpeg

Finally found a solution for grid/mosaic playback of RTSP streams.


#!/bin/bash
ffmpeg -rtsp_transport tcp \
-i rtsp://smartiptv:PASSWORD@192.168.2.3/Streaming/Channels/102 \
-i rtsp://smartiptv:PASSWORD@192.168.2.3/Streaming/Channels/202 \
-i rtsp://smartiptv:PASSWORD@192.168.2.3/Streaming/Channels/302 \
-i rtsp://smartiptv:PASSWORD@192.168.2.3/Streaming/Channels/402 \
-i rtsp://smartiptv:PASSWORD@192.168.2.3/Streaming/Channels/502 \
-i rtsp://smartiptv:PASSWORD@192.168.2.3/Streaming/Channels/602 \
-filter_complex "
nullsrc=size=1920×1080 [base];
[0:v] setpts=PTS-STARTPTS, scale=w=960:h=360 [upperleft];
[1:v] setpts=PTS-STARTPTS, scale=w=960:h=360 [upperright];
[2:v] setpts=PTS-STARTPTS, scale=w=960:h=360 [middleleft];
[3:v] setpts=PTS-STARTPTS, scale=w=960:h=360 [middleright];
[4:v] setpts=PTS-STARTPTS, scale=w=960:h=360 [lowerleft];
[5:v] setpts=PTS-STARTPTS, scale=w=960:h=360 [lowerright];
[base][upperleft] overlay=x=0:y=0 [tmp1];
[tmp1][upperright] overlay=x=960:y=0 [tmp2];
[tmp2][middleleft] overlay=x=0:y=360 [tmp3];
[tmp3][middleright] overlay=x=960:y=360 [tmp4];
[tmp4][lowerleft] overlay=x=0:y=720 [tmp5];
[tmp5][lowerright] overlay=x=960:y=720
" \
-c:v rawvideo -f nut – | mpv –


#!/bin/bash
# 8 channel input, 4 rows and 2 columns layout
ffmpeg -rtsp_transport tcp \
-i rtsp://smartiptv:PASSWORD@192.168.2.3/Streaming/Channels/102 \
-i rtsp://smartiptv:PASSWORD@192.168.2.3/Streaming/Channels/202 \
-i rtsp://smartiptv:PASSWORD@192.168.2.3/Streaming/Channels/302 \
-i rtsp://smartiptv:PASSWORD@192.168.2.3/Streaming/Channels/402 \
-i rtsp://smartiptv:PASSWORD@192.168.2.3/Streaming/Channels/502 \
-i rtsp://smartiptv:PASSWORD@192.168.2.3/Streaming/Channels/602 \
-i rtsp://smartiptv:PASSWORD@192.168.2.3/Streaming/Channels/702 \
-i rtsp://smartiptv:PASSWORD@192.168.2.3/Streaming/Channels/802 \
-filter_complex "
nullsrc=size=1920×1080 [base];
[0:v] setpts=PTS-STARTPTS, scale=w=960:h=270 [upperleft];
[1:v] setpts=PTS-STARTPTS, scale=w=960:h=270 [upperright];
[2:v] setpts=PTS-STARTPTS, scale=w=960:h=270 [middleleft];
[3:v] setpts=PTS-STARTPTS, scale=w=960:h=270 [middleright];
[4:v] setpts=PTS-STARTPTS, scale=w=960:h=270 [lowerleft];
[5:v] setpts=PTS-STARTPTS, scale=w=960:h=270 [lowerright];
[6:v] setpts=PTS-STARTPTS, scale=w=960:h=270 [centerleft];
[7:v] setpts=PTS-STARTPTS, scale=w=960:h=270 [centerright];
[base][upperleft] overlay=x=0:y=0 [tmp1];
[tmp1][upperright] overlay=x=960:y=0 [tmp2];
[tmp2][middleleft] overlay=x=0:y=270 [tmp3];
[tmp3][middleright] overlay=x=960:y=270 [tmp4];
[tmp4][lowerleft] overlay=x=0:y=540 [tmp5];
[tmp5][lowerright] overlay=x=960:y=540 [tmp6];
[tmp6][centerleft] overlay=x=0:y=810 [tmp7];
[tmp7][centerright] overlay=x=960:y=810
" \
-c:v rawvideo -f nut – | mpv –


ffmpeg -rtsp_transport tcp \
-i rtsp://smartiptv:PASSWORD@192.168.2.3:6911/Streaming/Channels/101 \
-i rtsp://smartiptv:PASSWORD@192.168.2.3:6911/Streaming/Channels/201 \
-i rtsp://smartiptv:PASSWORD@192.168.2.3:6911/Streaming/Channels/301 \
-i rtsp://smartiptv:PASSWORD@192.168.2.3:6911/Streaming/Channels/401 \
-filter_complex "
nullsrc=size=1920×1080 [base];
[0:v] setpts=PTS-STARTPTS, scale=960×540 [upperleft];
[1:v] setpts=PTS-STARTPTS, scale=960×540 [upperright];
[2:v] setpts=PTS-STARTPTS, scale=960×540 [lowerleft];
[3:v] setpts=PTS-STARTPTS, scale=960×540 [lowerright];
[base][upperleft] overlay=shortest=1 [tmp1];
[tmp1][upperright] overlay=shortest=1:x=960 [tmp2];
[tmp2][lowerleft] overlay=shortest=1:y=540 [tmp3];
[tmp3][lowerright] overlay=shortest=1:x=960:y=540
" \
-c:v libx264 -preset superfast -crf 18 -f matroska – | ffplay –


ffmpeg -rtsp_transport tcp \
-i rtsp://smartiptv:PASSWORD@192.168.2.3:6911/Streaming/Channels/102 \ # use substream with lower resolution
-i rtsp://smartiptv:PASSWORD@192.168.2.3:6911/Streaming/Channels/202 \
-i rtsp://smartiptv:PASSWORD@192.168.2.3:6911/Streaming/Channels/302 \
-i rtsp://smartiptv:PASSWORD@192.168.2.3:6911/Streaming/Channels/402 \
-filter_complex "
nullsrc=size=1920×1080 [base];
[0:v] setpts=PTS-STARTPTS, scale=960×540 [upperleft];
[1:v] setpts=PTS-STARTPTS, scale=960×540 [upperright];
[2:v] setpts=PTS-STARTPTS, scale=960×540 [lowerleft];
[3:v] setpts=PTS-STARTPTS, scale=960×540 [lowerright];
[base][upperleft] overlay=shortest=1 [tmp1];
[tmp1][upperright] overlay=shortest=1:x=960 [tmp2];
[tmp2][lowerleft] overlay=shortest=1:y=540 [tmp3];
[tmp3][lowerright] overlay=shortest=1:x=960:y=540
" \
-c:v libx265 \ # check output and see what format the camera use, see `ffmpeg -encoders | grep V`
-preset superfast -crf 18 -f matroska – | ffplay –

Source: https://trac.ffmpeg.org/wiki/Create%20a%20mosaic%20out%20of%20several%20input%20videos

Installing Plex Media Server on a remote host

Finally nailed it. I installed Plex Media Server on a remote host and after visiting the http://REMOTE_HOST_IP:32400/web I had no add server option.

In a forum thread I found the add server URL part, just add #!/setup http://raspi:32400/web/index.html#!/setup
But I got Setup is not allowed for shared servers. error

ss_2018-09-30-08-28-38
Setup is not allowed for shared servers.

I ended up with port forwarding to the remote host
ssh -L 32400:raspi:32400

To be able to add server I had to connect to localhost http://localhost:32400/web/index.html#!/setup

Plex media server setup wizard

More info about troubleshooting remote access is at https://support.plex.tv/articles/200931138-troubleshooting-remote-access/

Video cutting from start to end time using ffmpeg

Sometimes I need pieces from movies to upload to YouTube for example.

It’s possible with the following nice oneliner:

ffmpeg -i IN.mp4 -ss 01:12:55 -t 35 -async 1 OUT.mp4

The solution came from http://stackoverflow.com/questions/18444194/cutting-the-videos-based-on-start-and-end-time-using-ffmpeg

Convert iTunes DRM .m4v into .mp4

  1. I used Windows 7 64bit and downloaded iTunes 12.1.2 because the need to login and play the purchased TV show.
    For video converting I found Wondershare Video Converter Ultimate.
  2. After adding a video into Wondershare it complains that the movie is DRM protected so after click OK a browser window should open to download Free DRM & DVD Protection Removal Plugin from http://www.protectdvd.com/
  3. After installing the plugin and rerunning the converting procedure in Wondershare it worked.

converting itunes m4v drm