Newest 'ffmpeg' Questions - Stack Overflow

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

Articles published on the website

  • FFMPEG - can you have comments in script files?

    7 July, by rossmcm

    Because of batch's poor ability to handle multi-line strings, I'm using FFMPEG script files more and more for filter_complex arguments. I'm wondering if there is any way to include comments in these files. They seem to be quite tolerant of white space and line breaks. I've tried:

    #
    #   comment
    #
    

    and

    ;
    ;   comment
    ;
    

    and

    `
    `   comment
    `
    

    and

    '
    '   comment
    '
    

    with no success. It doesn't look as if comments are officially supported, but I'm wondering of there is some syntax quirk that allows them?

    *** CLARIFICATION ***

    I'm not talking about comments in batch files here, but comments in filter_complex_script files. FFMPEG supports specifying the filter_complex argument string in a separate file. So instead of:

    ffmpeg -i "input.mp4" -filter_complex "[0:v] crop=w=100:h=100:x=12:y=34 " "output.mp4"
    

    you can specify:

    ffmpeg -i "input.mp4" -filter_complex_script "crop.txt" "output.mp4"
    

    where crop.txt contains

    [0:v] crop=w=100:h=100:x=12:y=34
    

    This is really handy when the filter_complex string gets more complicated (I routinely deal with arguments 10,000 characters in length).

  • FFmpeg stream video to rtmp from frames OpenCV python

    7 July, by batata oussama

    In the context of indistural project, i developed a real time application to detect person with AI algorithms. In local i get and display videos with OPENCV operating with frames.

    The objective is to realise a stream video from frames of Opencv to rtmp server

    FFmpeg seems a good perspective. However, often the stream strats from .mp4 or several .jpg to publish stream video on rtmp server.

    Thank you.

  • FFmpeg: Pipe segments to s3

    7 July, by Brendan Kennedy

    I'd like to pipe ffmpeg segments to s3 without writing them to disk.

    ffmpeg -i t2.mp4 -map 0 -c copy -f segment -segment_time 20 output_%04d.mkv
    

    Is it possible to modify this command so that ffmpeg writes segments to an s3 bucket? Something like this perhaps?

    ffmpeg -i t2.mp4 -map 0 -c copy -f segment -segment_time 20 pipe:1 \
      | aws s3 cp - s3://bucket/output_%04d.mkv
    

    When I run the command above I receive this error

    Could not write header for output file #0
    (incorrect codec parameters ?): Muxer not found
    

    This command works except the entire video is uploaded and not the individual segments

    ffmpeg -i t2.mp4 -map 0 -c copy -f segment -segment_time 20 pipe:output_%04d.mkv \
    | aws s3 cp - s3://bucket/test.mkv
    
  • How to use pyav or opencv to decode a live stream of raw H.264 data?

    7 July, by Dery

    The data was received by socket ,with no more shell , they are pure I P B frames begin with NAL Header(something like 00 00 00 01). I am now using pyav to decode the frames ,but i can only decode the data after the second pps info(in key frame) was received(so the chunk of data I send to my decode thread can begin with pps and sps ), otherwise the decode() or demux() will return error "non-existing PPS 0 referenced decode_slice_header error" .

    I want to feed data to a sustaining decoder which can remember the previous P frame , so after feeding one B frame, the decoder return a decoded video frame. Or someform of IO that can be opened as container and keep writing data into it by another thread.

    Here is my key code:

    #read thread... read until get a key frame, then make a new io.BytesIO() to store the new data.
    rawFrames = io.BytesIO()
    while flag_get_keyFrame:()
        ....
        content= socket.recv(2048)
        rawFrames.write(content)
        ....
    
    #decode thread... decode content between two key frames
    ....
    rawFrames.seek(0)
    container = av.open(rawFrames)
    for packet in container.demux():
        for frame in packet.decode():
            self.frames.append(frame)
    ....
    

    My code will play the video but with a 3~4 seconds delay. So I am not putting all of it here, because I know it's not actually working for what I want to achieve. I want to play the video after receiving the first key frame and decode the following frames right after receiving them . Pyav opencv ffmpeg or something else ,how can I achieve my goal?

  • FFMPEG mux video and audio (from another video) - mapping issue

    7 July, by Mark

    I would like to place the audio from a video to another video without an audio (in one command):

    ffmpeg.exe -i video1_noAudio.mov -i video2_wAudio.mov -vcodec copy -acodec copy video1_audioFromVideo2.mov
    

    I guess "-map" is the correct way to do it but I got confused with it.

    Can you suggest how to resolve it?