Transcoding Tvheadend DVB-T with FFMPEG Rpi

  • So I decided to kill some time playing with transcoding and I'm getting frustrated..

    Im not even sure if this is possible..

    I m trying to transcode an mpeg2 stream to h264..

    So far I only managed to get it working not longer then 10 minutes after that stream just drops...

    While it's working cpu is averaging around 50% so no big deal I suppose...

    Output is h264/aac as command...no buffers or glitches..

    Command i m using right now is this tough I tryed loads and loads of different versions... :S

    Code
    ffmpeg -threads 4 -c:v mpeg2_mmal -v panic -hide_banner -nostats -i pipe:0 -map 0:0 -map 0:1 -map 0:2? -c:v h264_omx -s 480x270 -b:v 768k -pix_fmt yuv420p -bufsize 3000k -c:a aac -ac 1 -ar 22050 -c:s copy -f mpegts -r 25 pipe:1

    Anyone got this working?Or I m asking too much from my little computer ^^

  • I know ppl had it working at RPi3 and Tvh, so it may be a problem at the cmd you are using.

    Nothing obviouse if you ask me. I would cut down the commandline as much as possible, maybe some command combination creates problems.

    I tryed so many commands that I m running out of ideas...problem is that even with the simplest of commands with just copy and no transcoding...stream just stops..

    Maybe someone comes up with a working command so I can hopefully know if issue is with command or something else..

  • Hi

    I'm using 'mpegts spawn profile' in tvheadend and adding that command in spawn settings command line..you can add that in a script and add path to script in spawn settings command line..

    I assume that is using ffmpeg from ffmpeg-tools addon as it doesn't work without the addon installed..so same as adding full path..

    To play channels I made a playlist

    Code
    http://xxx:[email protected]:xxxx/stream/channelid/1234567?profile=transcoding

    transcoding frofile enabled for user in TvHeadend settings..

    Been watching mem and cpu trough Htop while transcoding and cpu doesn't exceed 75%

    This is free -m during a working transcode

    Code
    LibreELEC:~ # free -m
                  total        used        free      shared  buff/cache   available
    Mem:            747         104          31          12         612         576
    Swap:             0           0           0       12         612       

    Transcoding is defo working..as an mpeg2 stream with mp2 audio is transcoded to h264/aac..problem is it doesn t last long...all I get from tvheadend is unsubscibing from channel and a sigkill from ffmpeg.

    Not sure where to find ffmpegx?

    Edited 3 times, last by Mario77 (April 15, 2021 at 12:54 PM).

  • This is very strange.

    I use the exact same approach with a RPi3 and a RPi4, but I have none of those issues.

    As I've posted in another thread, this is my ffmpeg command line,

    Code
    /storage/.kodi/addons/service.ffmpeg/bin/ffmpeg -loglevel quiet -i pipe:0 -vf scale=640:360 -vcodec h264_omx -vb 512k -bufsize 2048k -g 100 -af "aresample=async=1:first_pts=0" -acodec aac -ab 128k -f mpegts pipe:1

    The major diferences are that I'm not forcing the frame rate nor the pixel format and I use a different ffmpeg version.

    I use a ffmpeg version compiled directly in my RPi3 from the official ffmpeg sources.

    If you want to test with it, just download from this link:

    https://mega.nz/file/NGIxxSIa#…IAtSfNVEoInPmL8

    Install the add-on directly from libreelec's kodi interface.

    ffmpeg path is:

    Code
    /storage/.kodi/addons/service.ffmpeg/bin/ffmpeg


    Note: Also take a look into gpu_mem in /flash/config.txt (i'm using 256 in my RPi3, and 512 imnRPi4)

    Note: It is a personal add-on that I've not yet released, which includes ffmpeg to help nginx to serve as a transcode server

    (if you are interested in knowing more, just read the txt file inside the add-on, or take a look at http://RPi_ip_address:9996/cgi-bin/movies.cgi?/storage after install - user/pass)


    Another thing: What client are you using to test the stream ?

    Edited 2 times, last by nvdias: Merged a post created by nvdias into this post. (April 16, 2021 at 4:12 PM).

  • Thanks I will try that soon..

    I used vlc and kodi on windows with iptv simple client and libreelec iptv simple client

    getting error

    Code
    /storage/.kodi/addons/service.ffmpeg/bin/ffmpeg: error while loading shared libraries: libdrm.so.2: cannot open shared object file: No such file or directory

    Thanks I will try that soon..

    I used vlc and kodi on windows with iptv simple client and libreelec iptv simple client

    getting error

    Code
    /storage/.kodi/addons/service.ffmpeg/bin/ffmpeg: error while loading shared libraries: libdrm.so.2: cannot open shared object file: No such file or directory

    I m still on Libreelec 9 not 10

    Edited 2 times, last by Mario77: Merged a post created by Mario77 into this post. (April 16, 2021 at 11:15 AM).

  • About your error:

    is strange, I use libreelec 9.2.6 and my ffmpeg works ok.

    libdrm.so.2 is in /usr/lib/libdrm.so.2

    Have you tried executing ffmpeg from a ssh shell ?


    About clients:

    I do my tests with vlc in PC to connect to tvheadend in my Rpi trough a m3u list got from http://tvheadend_ip_address:9981/playlist/channels

    This transcoding, takes some seconds to start, after starting 5 to 10s after it stops for 2 seconds (buffering), but then it plays all the time without issues, providing I have a good network connection. of course.

    There is also a nice free tvheadend client for iOS devices that works great, and it is easy to select a codec profile from it.

  • No idea what s going on then..

    I have no /usr/lib/libdrm.so.2 on rpi3 le9.2.6

    I don t have it even on my rpi2 I use as frontened also with 9.2.6

    Edited once, last by Mario77 (April 16, 2021 at 2:08 PM).

  • Further testing and it looks like issue is with my streams and even recordings...ffmpeg is showing many errors while transcoding both live tv and recordings..strange thing is these corrupt segments are not teally visible when watching live tv and not even on recordings...my reception is a bit on the low side tough..about 43%..

  • The transcoder works great on my device, I use this to limit the bandwidth of the TV channel stream on a remote device.

    Work environment:

    Device: Intel i5 x86_64

    Graphics: Intel Iris 6100

    Operating System: LE 9.2.6 Stable

    Tvheadend service: 4.3-1964 from docker linuxserver/tvheadend

    Hardware transcoding: h264-vaapi (very low CPU consumption)

    Limitations:

    - H265 transcoding does not work

    - H265 local decoding unusable (high CPU consumption)

    - H265 remote decoding on amlogic S905X3 and S912 devices works great