Newest 'ffmpeg' Questions - Stack Overflow

http://stackoverflow.com/questions/tagged/ffmpeg

Les articles publiés sur le site

  • RTP streaming with FFmpeg audio and video out of sync

    26 août 2017, par Matt Mahony

    I am streaming a webcam/audio with the command:

    ffmpeg.exe -f dshow -framerate 30 -i video="xxx" -c:v libx264 -an -f rtp rtp://localhost:50041 -f dshow -i audio="xxx" -c:a aac -vn -f rtp rtp://localhost:50043
    

    This outputs the following sdp info:

        v=0
        o=- 0 0 IN IP4 127.0.0.1
        s=No Name
        t=0 0
        a=tool:libavformat 57.65.100
        m=video 50041 RTP/AVP 96
        c=IN IP6 ::1
        a=rtpmap:96 H264/90000
        a=fmtp:96 packetization-mode=1
        m=audio 50043 RTP/AVP 97
        c=IN IP6 ::1
        b=AS:128
        a=rtpmap:97 MPEG4-GENERIC/44100/2
        a=fmtp:97 profile-level-id=1;mode=AAC-
        hbr;sizelength=13;indexlength=3;indexdeltalength=3; config=121056E500
    

    And I read the stream with the command:

    ffmpeg.exe -protocol_whitelist file,udp,rtp -i D:\test.sdp -c:v libx264 -c:a aac d:\out.mp4
    

    In the resulting file, the audio is slightly ahead of the video. I have read that RTCP runs on the RTP port + 1, and contains synchronization information. I don't see any RTCP information in the SDP file though.

    Do I need to specify something to include RTCP?

    If that's not the issue, what else can I do to sync the audio and video?

  • Bash : bash script to download trimmed mp3 from youtube url

    25 août 2017, par Bhishan Poudel

    I would like to download the initially x seconds trimmed mp3 from a video url of youtube.
    I found that youtube-dl can download the video from youtube to local machine. But, when I looked at the man pages of youtube-dl, I could not find any trim options.

    So I tried to use the ffmpeg to trim downloaded mp3 file.
    Instead of doing this is two steps, I like to write one bash script which does the same thing.
    My attempt is given below.

    However, I was stuck at one place:
    "HOW TO GET THE VARIABLE NAME OF OUTPUT MP3 FILE FROM YOUTUBE-DL?"
    The script is given below:

    # trim initial x seconds of mp3 file
    # e.g. mytrim https://www.youtube.com/watch?v=dD5RgCf1hrI 30
    function mytrim() {
        youtube-dl --extract-audio --embed-thumbnail --audio-format mp3 -o "%(title)s.%(ext)s" $1
        ffmpeg -ss $2 -i $OUTPUT_MP3 -acodec copy -y temp.mp3
        mv temp.mp3 $OUTPUT_MP3
        }
    

    How to get the variable value $OUTPUT_MP3?
    echo "%(title)s.%(ext)s" gives the verbatim output, does not give the output filename.

    How could we make the script work?

    The help will be appreciated.

  • How to render video overlay with C# Graphics (FFMPEG library) ? [on hold]

    25 août 2017, par JoeSkurczysyn

    I want to render GPS data on video with ffmpeg. I can't use console command line version because there is a command len limit on windows. I want to use ffmpeg directly from code. But all examples I found are for .bat files and command line. Can anyone provide example on how to process a viideo file with ffmpeg frame by frame and draw Graphics onto it (preferrably with C# Graphics class)?

  • ffmpeg nginx "Past duration ... too large" [duplicate]

    25 août 2017, par Philip Kirkbride

    This question already has an answer here:

    I have nginx compiled with the rtmp module. I start nginx and run the following to start streaming my webcam:

    ffmpeg -i /dev/video0 -f flv rtmp://localhost/live/test    
    

    Which works, I can then connect to my stream at rtmp://localhost/live/test

    The logs look like:

    frame=51 fps=34 q=31.0 size=203kB time=00:00:02.60 bitrate=638.9
    frame=66 fps=33 q=31.0 size=239kB time=00:00:03.10 bitrate=632.0 
    frame=82 fps=33 q=31.0 size=271kB time=00:00:03.63 bitrate=611.6
    ...
    

    With a new line being output every second or so. After streaming for 3-4 minutes I start getting logs like these about 5 per second:

    Past duration 0.987877 too large
    Past duration 0.911079 too large
    Past duration 0.949013 too large
    

    Despite the warnings the stream still seems to be live and working.

    I believe nginx is triggering the following ffmpeg command:

    exec ffmpeg -i rtmp://localhost:1935/encode/$name
      -c:a libfdk_aac -b:a 128k -c:v libx264 -b:v 1000k -f flv -g 30 -r 30 -s 854x480 -preset superfast -profile:v baseline rtmp://localhost:1935/live/$name
    ;
    

    Complete nginx.conf file.

    Does anyone know what this warning is referring to?

  • Using hex colors with ffmpeg's showwaves

    25 août 2017, par Dan

    I've been trying to create a video with ffmpeg's showwaves filter and have cobbled together the below command which I sort of understand. I'm wondering if it is possible to set the color of the wav form using hex colors. (i.e. #F3ECDA instead of "blue") Also, feel free to tell me if there's any unneeded garbage in the command as is. Thanks.

    ffmpeg -i audio.mp3 -loop 1 -i picture.jpg -filter_complex \
    "[0:a]showwaves=s=960x202:mode=cline:colors=blue[fg]; \
     [1:v]scale=960:-1,crop=iw:540[bg]; \
     [bg][fg]overlay=shortest=1:main_h-overlay_h-30,format=yuv420p[out]" \
    -map "[out]" -map 0:a -c:v libx264 -preset fast -crf 18 -c:a libopus output.col.mkv