Recherche avancée

Médias (1)

Mot : - Tags -/MediaSPIP 0.2

Autres articles (91)

Sur d’autres sites (16689)

  • Waiting between FFMPEG scripts when creating .hdr/.chk and .mpd files on NGINX server using RTMP module

    17 avril 2020, par Mathew Knight

    Wonder if anyone might be able to suggest a solution to and issue i'm having.

    



    I'm running some FFMPEG scripts inside a RTMP server block on an NGINX server running on Ubuntu 18.04.

    



    Basically i'm ingesting the RTMP stream to the server then using FFMPEG to Demux into separate audio and video header and chunk files, then in separate scripts i'm creating two separate manifests for both the audio and video.

    



    The player i have (a development ambisonic, 360 video player) is having problems reading the stream correctly and i believe this is due to the FFMPEG process for the manifests not waiting 2 seconds before running.

    



    Is there a way to program a wait in between the scripts to facilitate this ?

    



    furthermore, is there a way to make the manifest scripts only run once then quit ?

    



    heres my current NGINX .conf

    



    user root;
#user www-data;
worker_processes 1;
pid /run/nginx.pid;
include /etc/nginx/modules-enabled/*.conf;
events {
    worker_connections 768;
    # multi_accept on;
}
http {
    ##
    # Basic Settings
    ##
    sendfile on;
    tcp_nopush on;
    tcp_nodelay on;
    keepalive_timeout 65;
    types_hash_max_size 2048;
    # server_tokens off;
    # server_names_hash_bucket_size 64;
    # server_name_in_redirect off;
    include /etc/nginx/mime.types;
    default_type application/octet-stream;
    ##
    # SSL Settings
    ##
    #ssl_protocols TLSv1 TLSv1.1 TLSv1.2; # Dropping SSLv3, ref: POODLE
    #ssl_prefer_server_ciphers on;
    ##
    # Logging Settings
    ##
    access_log /var/log/nginx/access.log;
    error_log /var/log/nginx/error.log;
    ##
    # Gzip Settings
    ##
    ##
    # Virtual Host Configs
    ##
    include /etc/nginx/conf.d/*.conf;
    include /etc/nginx/sites-enabled/*;
}
rtmp {
        server {
            listen 1935;
            chunk_size 4096;

            application live {
            live on;
            record off;
            interleave off;
            wait_key on;
            meta on;
            wait_video off;
            idle_streams off;
            sync 300ms;
            session_relay on;
            #allow publish 127.0.0.1;
            #allow publish 192.168.2.0/24;
            allow publish all;
            #deny publish all;
            allow play all;    
        #RX stream to FFMPEG, demux audio and video, write .hdr files, start chunking DASH segments .chk
         exec_push sudo ffmpeg -y -re -i 'rtmp://localhost:1935/live/stream' -map 0:1 -pix_fmt yuv420p -maxrate 750k -bufsize 3000k -c:v libvpx-vp9 -s 1920x1080 -keyint_min 60 -g 60 -speed 6 -tile-columns 4 -frame-parallel 1 -threads 8 -static-thresh 0 -max-intra-rate 300 -deadline realtime -lag-in-frames 0 -error-resilient 1 -b:v 6000k -f webm_chunk -header "/var/www/html/dash/video_360.hdr" -chunk_start_index 1 "/var/www/html/dash/video_360_%d.chk" -map 0:2 -c:a libopus -mapping_family 255 -b:a 1024k -vn -f webm_chunk -audio_chunk_duration 2000 -header "/var/www/html/dash/audio_171.hdr" -chunk_start_index 1 "/var/www/html/dash/audio_171_%d.chk" 2>>/var/log/nginx/ffmpegChunk.log;

        #Create video manifest
        exec_push sudo ffmpeg -probesize 500M -analyzeduration 100M -f webm_dash_manifest -live 1 -i "/var/www/html/dash/video_360.hdr" -map 0 -c copy -f webm_dash_manifest -live 1 -adaptation_sets "id=0,streams=0" -chunk_start_index 1 -chunk_duration_ms 2000 -minimum_update_period 7200 "/var/www/html/dash/video.mpd" 2>>/var/log/nginx/ffmpegManifestVideo.log;
        #Create audio manifest
        exec_push sudo ffmpeg -probesize 500M -analyzeduration 100M -f webm_dash_manifest -live 1 -i "/var/www/html/dash/audio_171.hdr" -map 0 -c libopus -mapping_family 255 -f webm_dash_manifest -live 1 -adaptation_sets "id=1,streams=0" -chunk_start_index 1 -chunk_duration_ms 2000 -minimum_update_period 7200 "/var/www/html/dash/audio_16ch.mpd" 2>>/var/log/nginx/ffmpegManifestAudio.log;

        ##
        # Record the incoming stream
        ##
        # Record audio and video together
        record all;
        record_path /home/mathewknight/Desktop/StreamRecord/Master;
        record_notify on;
        # Record audio seperately
        recorder audio {
            record audio;
            record_path /home/mathewknight/Desktop/StreamRecord/Audio;
            record_suffix -%d-%b-%y-%T.audio.flv;
            record_notify on;
            }
        # Record video seperately
        recorder video{
            record video;
            record_path /home/mathewknight/Desktop/StreamRecord/Video;
            record_suffix -%d-%b-%y-%T.video.flv;
            record_notify on;
            }

            }


        }

}



    


  • Slow start time in FFmpeg conversion - Seeking advice on optimization and identifying unnecessary flags [closed]

    30 novembre 2023, par Mohamed Dhouib

    I'm currently facing an issue with the startup time of FFmpeg conversion from RTSP stream to DASH stream in my application.
The conversion process takes longer to initiate than expected (sometimes even 15 seconds), impacting overall performance.
I've provided the relevant FFmpeg used options flags below :

    


        "-g 48",
    "-map 0:v:0",
    "-pix_fmt yuv420p",
    "-f dash",
    "-window_size 5",
    "-use_template 1",
    "-g 48",
    "-sc_threshold 0",
    "-vf scale=1920:1080",
    "-c:a aac",
    "-ar 48000",
    "-ac 2",
    "-strict experimental",
    "-max_muxing_queue_size 1024",
    "-c:v libx264",
    "-use_timeline 0"
    `-preset medium`,
    `-b:v 500k`,
    `-s 1280x720`,
    `-r 30`


    


    I'm looking for guidance on optimizing the FFmpeg configuration by adding new flags or identifying any unnecessary flags that might contribute to the slow start time.
The goal is to reduce the time it takes for FFmpeg to start the conversion process.
I appreciate any insights or recommendations on how to improve the startup time of FFmpeg conversion in my application.

    


    Relevant Dependencies :

    


    "@ffmpeg-installer/ffmpeg" : "^1.1.0",
"fluent-ffmpeg" : "^2.1.2",

    


    I am expecting the first stream chunk to be created in the first 3 seconds or so but it takes a lot more than that ( about 10 seconds )

    


  • FFmpeg ignores some HTTP options when using the PUT method

    6 mars 2020, par mehdi.r

    I am using FFmpeg to create a CMAF stream and I upload it to an AWS resource (AWS MediaStore) using the PUT method of FFMpeg.
    I need to pass the Content-Type header when uploading manifests & segments.
    I have 3 type of files :

    application/x-mpegURL : m3u8 manifest

    application/dash+xml : mpd manifest

    video/mp4 : video segments

    Currently, all the types are set to Binary - octet-stream in the AWS resource (AWS MediaStore).
    As I will upload a huge number of files, I can’t use AWS Lambda functions to set the correct content type after a file as been uploaded.

    FFmpeg upload logs

    [https @ 0x555fe7a7d1c0] Opening 'https://XXXX.YYYY.amazonaws.com/chunk-stream0-00001.mp4' for writing
    [https @ 0x555fe7a7d0c0] request: PUT /chunk-stream0-00001.mp4 HTTP/1.1
    Transfer-Encoding: chunked
    User-Agent: Lavf/58.28.100
    Accept: */*
    Connection: keep-alive
    Host: XXXXX.YYYY.amazonaws.com
    Icy-MetaData: 1

    My tries

    I tried static builds & master branch of FFMpeg.
    I tried different ways to pass the content type, without success :

    -mime_type 1 -headers "Content-type: video/mp4\r\n"

    -mime_type "video/mp4,application/dash+xml,application/x-mpegURL"

    -content_type application/dash+xml

    -multiple_requests 1  -headers "a:b" -icy 0

    Upload command :

    ./ffmpeg -re -i ~/videos/BigBuckBunny.mp4 -loglevel debug \
     -map 0 -map 0 -map 0 -c:a aac -c:v libx264 -tune zerolatency \
     -b:v:0 2000k -s:v:0 1280x720 -profile:v:0 high -b:v:1 1500k -s:v:1 640x340  -profile:v:1 main -b:v:2 500k -s:v:2 320x170  -profile:v:2 baseline -bf 1 \
    -keyint_min 24 -g 24 -sc_threshold 0 -b_strategy 0 -ar:a:1 22050 -use_timeline 1 -use_template 1 -window_size 5 \
    -adaptation_sets "id=0,streams=v id=1,streams=a" -hls_playlist 1 -seg_duration 3 -streaming 1 \
    -strict experimental -lhls 1 -remove_at_exit 0 -master_m3u8_publish_rate 3 \
    -f dash -method PUT -http_persistent 1  https://example.com/manifest.mpd

    Any help would be highly appreciated.

    Reference :
    https://www.ffmpeg.org/ffmpeg-protocols.html#http