Posts by nvdias

    This addon is more than ffmpeg:

    It is a full transcode server with a ready to use configuration and user interface to help you serve your local content to an external device (example: stream from your pi --> ipad on the run).

    It includes ffmpeg and nginx in order to have everything together in just one add-on without external dependencies.

    isn't the included ffmpegx (ffpge-tools) already compiled with everything that it works with rpi transcode ?

    For what I've seen in the past, omx and mmal weren't included.

    Pi Foundation folks are currently focussed on finishing the 10/12-bit video and 4K60 work. This will firm up the kernel/DRM side of the puzzle and allow some ffmpeg cleanup, which needs to happen before more complication (with deinterlace) is added. It's vacation season so all of the above is running about 3/4 speed right now. IMHO the current software deinterlace capability is quite usable (not perfect, but usable).

    Yes. it is of course acceptable to wait for deinterlacing,

    But in my opinion and taste, the software deinterlace with RPi4 is not a good viewing experience.

    At least for TV Reception of full-hd 1080i@50 fps soccer games - there's a movement lag that feels somehow "unnatural". And gives an uncomfortable viewing sensation (probably the RPi4 is not powerful enough to do software deinterlace).

    But that's only my opinion, of course.

    when deinterlace is not needed LE10 is great ;)

    Update for aarch64 - RPi 4 & 5 - 10/02/2025


    INTRO

    I've mounted a transcoding server with a simple web control interface to help viewing your videos in a compatible web browser.

    It includes ffmpeg own compilation ready to do real time transcode in rpi 3 and rpi 4 using omx and mmal.

    It also works great spawned by tvheadend

    Also includes nginx specific compile to help the transcoding process.

    You can even add nginx additional configurations with an included php authorization server.

    add-on will be identified as service.ffmpeg in kodi.

    Download here:

    https://mega.nz/file/oHZi3b5K#F1HMIak0x6-AkZlRpaUKekUnNPtZFwvkN87aNWvTlNY


    DETAILS

    FFmpeg TRANSCODING Server for Raspberry Pi

    This add-on includes:

    1 A small TRASNCODING web based service - you can transcode your local stored movies across the network.
    even when on low bandwidth.

    2 NGINX with:
    rtmp and hls for transcoding services.
    php scripts handler.
    cgi scripts handler.
    authorizaiton server running on port 444 (for form based authorizaiton - see bellow)
    nginx can also publish your custom sites.

    See examples in the default configuration site at:
    /storage/.kodi/addons/service.ffmpeg/etc/nginx/sites-enabled

    Your custom sites definitions goes into:
    /storage/.kodi/userdata/addon_data/service.ffmpeg/sites-custom/

    3 FFMPEG with omx and mmal support for Pi, and also libx264 with presets (for fast transcoding).
    can be used in a tvheadend profile (see bellow).


    Compatible with vlc player and chrome (must install a m3u8 extension for playing streams).


    = QUICK SETUP

    After install go to add-on settings in kodi:
    - Change user and pass (defaults to user / pass)


    Access to the User interface with a web-browser:

    in which path_to_transcode is the directory path that contains video contents to be browsed and transcoded.
    use linux format (example: /media/hdd/movies)


    = TECH STUFF


    1 TRANSCODING SERVER

    - TRANSCODING CONTROL PORT : Defaults to 9996.

    Simple CTRL GUI :
    Start Transcode :
    Stop Transcode :
    Play stream :

    Movies will default transcode to 640x480 @ 512kbps.
    Publishing is made to rtmp://localhost/hls/movie (internal port 1935)


    - USER AND PASSWORD:

    User and password defaults to "user" and "pass".
    Should be changed in kodi's add-on configuration screen.


    - KODI ADD-ON CONFIGURATION:

    In the add-on configuration screen, you can define:
    - Server port (defaults to 9996);
    - Transcoded streaming video frame size (defaults to 640 x 480);
    - Transcoded streaming video bitrate (defaults to 512 Kbps);
    - User and password to access the control site;


    - Control GUI:

    Should be called with the local server directory with movies to transcode.
    Example:

            
    This interface allows choosing the movie, start transcoding, start playback and stop transcoding.
    m3u8 can be watched in chrome by installing an extension. VLC Plays them directly.

    - TRANSCODE:

    transcode.cgi can be called directly by giving the movie FULL PATH NAME WITHIN THE SERVER,
    and several optional arguments.
    The example bellow uses the default options:

    All arguments are self explanatory, except "caller",
    which is an optional address to transfer execution after the transcoding is started.
    If "caller" is not passed as argument,
    transcode.cgi will stay in browser with a small simple interface to playback and stop the stream.
      


    2 NGINX - ADDITIONAL SITES:

    As nginx is being used, you can define additional servers in:
    /storage/.kodi/userdata/addon_data/service.ffmpeg/sites-custom

    Or by samba as:
    \\Userdata\addon_data\service.ffmpeg\sites-custom

    You sites may also use cgi and php.


    3 NGINX - THE AUTHORIZATION SERVER

    - INCLUDE FILE
    Script to include in nginx servers in order to test and request authentication
    /storage/.kodi/addons/service.ffmpeg/etc/nginx/authentication.include;

    Each location to protect should include a:
    auth_request /oauth;
         
    Locations to explicitly ignore auth_request should do a:
    auth_request off;
        
    - $authentication_server variable
    it is defined to the internal server that will answer authorization requests, login and logout procedures.
    defaults to http://127.0.0.1:444;

    - LOGOUT
    To force a logout, there is a virtual page that you can can force from your site.
        
    - VIRTUAL LOCATIONS
    This is a list of all virtual locations included with this config:
    /oauth authorization validation (internal to nginx config)
    /login_form.php login form (internal to nginx config)
    /login_process.php form credentials test (called by form)
    /logout.php force user logout (can be called externally)
        
    The login user information is kept in a php session
        
    - PASSWORD FILE
    Should be in htpasswd format:
    defined in $passwords variable
        
        
    - TYPICAL IUSAGE:
        
    server {
    ..... your server definitions ....
        
    include /storage/.kodi/addons/service.ffmpeg/etc/nginx/authentication.include;
    set $passwords /storage/path/password_file

    # List of nginx variables that may be OPTIONALLY configured AFTER the include:
    # set $autentication_server (internal LAN address - usually http://127.0.0.1:444)
    # set $passwords (full path to the filename with the passwords)
        
    # This location needs login & password
    location /secure/ {
    auth_request /oauth;
    expires -1;
    }
        
    # This locatin will NOT request login
    location /free/ {
    auth_request off;
    }
        
    }


    4 FFmpeg

    ffmpeg is used as the encoding for the server,
    but it is also usable trought command-line.
    just call as:

    ffmpeg


    TVHEADEND

    If you use tvheadend, you may define a profile that pipes video streams trough ffmpeg before delivering.
    The following example uses x264 to live transocde with a Rapsberry Pi4.
    Assuming ffmpeg server kodi add-on installed in LibreELEC:

    - tvheaded / configiration / stream / stream profiles / add
    - create and enable new stream profiles with the followig:
    . enabled = true
    . Data timeout = 0
    . Restart on error = true
    . Continue if descrambling fails = true
    . Descrambling timeout = 10000
    . Command Line
    /storage/.kodi/addons/service.ffmpeg/bin/ffmpeg -loglevel quiet -i pipe:0 -vcodec libx264 -preset faster -s 640x480 -vb 512k -bufsize 1024k -g 100 -af "aresample=async=1:first_pts=0" -acodec aac -ab 128k -f mpegts pipe:1
    . Kill signal = SIGTERM
    . Kill timeout = 15
        
    - The ffmpeg provided command will do live transcode with the major setup:
    . video codec : libx264
    . preset : faster
    . frame size : 640x480
    . video bitrate : 512k
    . audio codec : aac
    . audio bitrate : 128k
    . audio sync with video (to handle received lost frames)
        
            
        
            
    5 COMPILATION DETAILS


    ffmpeg and nginx were compiled using the following flags:


    ffmpeg version N-114580-g8a23a145d8 Copyright (c) 2000-2024 the FFmpeg developers
    built with gcc 9 (Ubuntu 9.4.0-1ubuntu1~20.04.2)
    configuration: --arch=aarch64 --prefix=/usr --enable-gpl --enable-libx264 --enable-libx265
    --enable-libdrm --enable-libaom --enable-omx --enable-omx-rpi --enable-openssl --disable-ffplay
    --disable-ffprobe --disable-doc --disable-libxcb --disable-libxcb-shm --disable-libxcb-xfixes
    --disable-libxcb-shape --enable-nonfree


    nginx version: nginx/1.23.2
    built by gcc 9.3.0 (Ubuntu 9.3.0-17ubuntu1~20.04)
    built with OpenSSL 1.1.1f 31 Mar 2020
    TLS SNI support enable
    configure arguments:
    --with-http_ssl_module --with-http_dav_module --with-http_flv_module
    --with-http_mp4_module --with-http_gunzip_module --with-http_gzip_static_module
    --with-http_auth_request_module
    --add-module=../nginx-rtmp-module --add-module=../echo-nginx-module

    nginx was patched with patchelf to force usage of specific libcrypt.so.1
    distributed with the bin


    php-fpm
    PHP 7.4.32 (fpm-fcgi)
    (built: Sep 29 2022 16:15:14)
    Copyright (c) The PHP Group
    Zend Engine v3.4.0, Copyright (c) Zend Technologies
    configure arguments:
    --without-iconv --enable-fpm

    php-fpm was patched with patchelf to force usage of specific libraries
    distributed with the bin

    I'm not using it either!

    It simply comes with every release from the past weeks,, but my rpi4 simply crashes at boot if I have it selected.

    I have to manualy disable it, placing the sc-card in my pc and manually editing distroconfig.txt.

    Is cma-512 needed ?

    could it be possible to NOT being enabled by default ?

    thanks

    I've lost some hours to understand why my RPi4 started to crash at boot after installing newer le10 nightly builds.

    After some tests I've noticed that the line in distroconfig.txt:

    dtoverlay=vc4-kms-v3d,cma-512

    Is the one to blame.

    If I remove cma-512 from distroconfig.txt, Le10 works just fine.

    I have a RPi4 with 4 GB RAM.

    What could be happening ? (the previous le10 builds did not had cma-512 and also worked ok).

    No one else had the same problem ?


    Thanks :)

    SNR 28 db

    strenght -78 dBm

    Well ... assuming those are DVB-C signals, I will suggest you to try a different connection.

    do you have a way to connect to 1 of the first cable wall plugs ?

    Or even directly in the cable that enters your home ?

    (just to make sure you are not getting a big signal drop in your home cabling, and assure that that is not the reason for your breaks)

    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%..

    Have you've been successful meanwhile ?


    When you say 43%, can you report the SNR ? (in tvheadend's interface, status/stream).

    For your reference, in average I have:
    cable - SNR 36.3 dBm ; Signal strength 51.0 dBm.
    sat - SNR 15. dBm ; -30.5 dBm.

    Using a TBS 5520 SE combo receiver.

    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.

    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 ?

    Gonna try your command...you have some code I never tryed before..

    what is this for?

    Code
    -g 100 -af "aresample=async=1:first_pts=0"

    Still stopping on my setup..max it plays is 10 minutes...are you using FFMPEG addon from Libreelec repo?

    Your 10 mins, might be a memory problem.

    I am not using ffmpeg from libreelec. I've made a ffmpeg compilation with omx serving nginx server for live web transcoding of recordings - I might share it in the forum but I do not believe that is the issue.

    -g 100 is the GOP length. 100 is recommended for mpeg streams.

    -af "aresample=async=1:first_pts=0", helps audio resampling when there are interruptions in tv reception and solving audio de-syncs.

    -bufsize 2048k increases the buffer size to help again handling interruptions in reception.

    These had been very helpfull for me in receiving steady streams.

    • For your tests I suggest you use an unencrypted channel.
    • Also confirm you have a good cable connection (of course).
    • And depending in your device, as I have a Raspberry Pi4 with 4GB, I have dedicated 512 KB to the GPU, which has been helpfull in timeshift buffering and fast-forward and rewiding recordings (gpu_mem=512 in /flash/config.txt)
    • About timeshift, i only use RAM for timeshift, never disk, which also increases stability, as less disk access when watching tv.

    Have you tried nextpvr? not sure if it's any good or not but it seems to be actively supported. Maybe somebody here knows if it's any good or not.

    I've tried nextpvr in my RPi4 with libreelec.

    As i have docker installed is wuite easy, just need to add privileges and devi /dev/dvb/adapter0, and adjust directories.
    But ...... NEXTPVR fails the transcoding in RPI devices.

    AND ... does not support encrypted channels.


    Tvheadend, even with not much updates in the past years is still the best pvr backend.


    TRANSCODING WITH TVHEADEND AND FFMPEG

    About some issues, some people asked some threads above, regarding transcoding with tvheadend.

    I use tvheadend nighlty build (4.3 beta) which support spawning.

    I'm using ffmpeg compiled with omx installed in libreelec.

    for reference I share my ffmpeg transcoding for tvheanded.

    I call it "transcode-omx". It uses about 60% of RPi4 total performance:

    Code
    {path_ffmpeg}/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

    Just add-it "configuration/ stream" in tvheaded webui.

    some additional tweaks I use for it in the attached picture.

    This configuration summary:

    • codec omx from Raspberry Pi hardware
    • output video 640x360,
    • ar 16:9
    • video bitrate 512 kbps
    • audio bitrate 128 kbps
    • audio resync (to handle some drop frames that could happen during reception of channels).


    This profile is great for watching tv channels in a rmeote smartphone connected to tvheadend running in libreelec.

    This profile can also be applied to record programmes with lower bitrates

    With the change suggested, compilation for RPi4 failed:

    - Compiled with:

    PROJECT=RPi DEVICE=RPi4 ARCH=arm make image

    - Returned error. Log here:

    Ubuntu Pastebin


    Hi,

    I tried to install it for TBS 5955. The installation was successful, without any visible error. But TVheadend doesn't show USB TBS 5955 tuner.

    Can you help me, please ?

    The patch that smp made seems to be only for 5520SE.

    Maybe he could help with 5955 too ...


    Btw, i've just updated the driver for the new kernel version that goes with last LE10 nightly builds (5.10.25).

    https://mega.nz/file/MCpFVS6a#…hOBte5fIgANvTxg