Newest 'ffmpeg' Questions - Stack Overflow

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

Les articles publiés sur le site

  • Why isn't FFmpeg compiler-optimized ?

    10 octobre 2013, par Saptarshi Biswas

    FFmpeg is compiled by first creating a debug build and then stripping debug symbols off.

    LD      ffmpeg_g
    CP      ffmpeg
    STRIP   ffmpeg
    

    Why not have compiler optimizations, O3 for instance?

  • How to optimize ffmpeg w/ x264 for multiple bitrate output files

    10 octobre 2013, par Jonesy

    The goal is to create multiple output files that differ only in bitrate from a single source file. The solutions for this that were documented worked, but had inefficiencies. The solution that I discovered to be most efficient was not documented anywhere that I could see. I am posting it here for review and asking if others know of additional optimizations that can be made.

    Source file       MPEG-2 Video (Letterboxed) 1920x1080 @>10Mbps
                      MPEG-1 Audio @ 384Kbps
    Destiation files  H264 Video 720x400 @ multiple bitrates
                      AAC Audio @ 128Kbps
    Machine           Multi-core Processor
    

    The video quality at each bitrate is important so we are running in 2-Pass mode with the 'medium' preset

    VIDEO_OPTIONS_P2 = -vcodec libx264 -preset medium -profile:v main -g 72 -keyint_min 24 -vf scale=720:-1,crop=720:400

    The first approach was to encode them all in parallel processes

    ffmpeg -y -i $INPUT_FILE $AUDIO_OPTIONS_P2 $VIDEO_OPTIONS_P2 -b:v 250k -threads auto -f mp4 out-250.mp4 &
    ffmpeg -y -i $INPUT_FILE $AUDIO_OPTIONS_P2 $VIDEO_OPTIONS_P2 -b:v 500k -threads auto -f mp4 out-500.mp4 &
    ffmpeg -y -i $INPUT_FILE $AUDIO_OPTIONS_P2 $VIDEO_OPTIONS_P2 -b:v 700k -threads auto -f mp4 out-700.mp4 &
    

    The obvious inefficiencies are that the source file is read, decoded, scaled, and cropped identically for each process. How can we do this once and then feed the encoders with the result?

    The hope was that generating all the encodes in a single ffmpeg command would optimize-out the duplicate steps.

    ffmpeg -y -i $INPUT_FILE \
    $AUDIO_OPTIONS_P2 $VIDEO_OPTIONS_P2 -b:v 250k -threads auto -f mp4 out-250.mp4 \
    $AUDIO_OPTIONS_P2 $VIDEO_OPTIONS_P2 -b:v 500k -threads auto -f mp4 out-500.mp4 \
    $AUDIO_OPTIONS_P2 $VIDEO_OPTIONS_P2 -b:v 700k -threads auto -f mp4 out-700.mp4
    

    However, the encoding time was nearly identical to the previous multi-process approach. This leads me to believe that all the steps are again being performed in duplicate.

    To force ffmpeg to read, decode, and scale only once, I put those steps in one ffmpeg process and piped the result into another ffmpeg process that performed the encoding. This improved the overall processing time by 15%-20%.

    INPUT_STREAM="ffmpeg -i $INPUT_FILE -vf scale=720:-1,crop=720:400 -threads auto -f yuv4mpegpipe -"
    
    $INPUT_STREAM | ffmpeg -y -f yuv4mpegpipe -i - \
    $AUDIO_OPTIONS_P2 $VIDEO_OPTIONS_P2 -b:v 250k -threads auto out-250.mp4 \
    $AUDIO_OPTIONS_P2 $VIDEO_OPTIONS_P2 -b:v 500k -threads auto out-500.mp4 \
    $AUDIO_OPTIONS_P2 $VIDEO_OPTIONS_P2 -b:v 700k -threads auto out-700.mp4
    

    Does anyone see potential problems with doing it this way, or know of a better method?

  • Can ffmpeg process files by their size ? - looking for a faster way to process

    10 octobre 2013, par nlahkim

    i looking for a faster way to convert mp3 files on mp4 by adding a simple image on it maybe can the codec sort files by size before processing

    i use this portion of code to do the conversion:

    for %%a in ("*.*")
    do
    "C:\ffmpeg\bin\ffmpeg" -loop 1 -i  "C:\ffmpg\bin\input.jpg" -i  "%%a" -c:v libx264 -preset veryslow -tune stillimage -crf 18 -pix_fmt yuv420p -vf scale=640:480 -c:a aac -shortest -strict experimental -b:a 192k -shortest "C:\mp4\%%~na.mp4"
    pause
    

    i don't find anything about sorting files on ffmpeg support site

    the only thing i have fond about processing faster is using cpu and thread but it dosen't really work like i expected

    so any idea about processing faster?

    thanks

  • decode mpeg4 video stream with FFMEG

    10 octobre 2013, par thaibaodoan

    I have a prolem with ffmpeg library when using it for decoding video. Data send from server to remote is fine, I decode H264 data well. But when decode mpeg-4 data, avcodec_decode_video2() function always decode fail a frame after decode successfully a frame.

                int len = 0;
        int ret = 0;
        int got_picture = 0;
        uint8_t* padding_data = NULL;
        AVPacket avpacket;
        av_init_packet(&avpacket);
    
        jboolean result = false;
        int encoded_size = dFrame.length + FF_INPUT_BUFFER_PADDING_SIZE;
        padding_data = (uint8_t*) aligned_malloc(encoded_size, IMC_ALIGNED32);
        memcpy(padding_data, dFrame.bitstream, dFrame.length);
        memset(padding_data + dFrame.length, 0, FF_INPUT_BUFFER_PADDING_SIZE);
        avpacket.data = padding_data;
        avpacket.size = dFrame.length;
    
    
        avcodec_get_frame_defaults(this->pFrame);
    
        len = avcodec_decode_video2(this->pCodecCtx, this->pFrame, &got_picture,
                &avpacket);
    
        if (padding_data)
        {
            aligned_free (padding_data);
        }
        av_free_packet(&avpacket);
    

    And I init decoder with AV_CODEC_ID_MPEG4 . Anybody can give me some advice?

  • When merging video and audio, converting audio to AAC, sound is missed at the end 3 seconds

    10 octobre 2013, par profuel

    I have to build video from images and some audio clip.
    Audio is much longer, so I have to mute last 5 seconds of audio track, cutting to video length.
    My issue is that adding AAC encoding to audio removes last 2-5 seconds of audio in resulted video.

    Here are my command lines:

    ffmpeg -i sound.mp3 -i video.mp4 -shortest out.mp4 -> results in correct audio in result video with played audio over 100% of movie

    ffmpeg -i sound.mp3 -i video.mp4 -acodec aac -ab 160000 -strict experimental -shortest out.mp4 -> not correct audio, gets crop at end of video for 2-5 seconds


    The problem appears for me both on Windows and on CentOS 6.4, no matter which version of ffmpeg is used.

    FFMPEG details (downloaded from http://ffmpeg.gusari.org/static/64bit/ffmpeg.static.64bit.2013-06-01.tar.gz )
    ffmpeg version N-53724-g716dbc7 Copyright (c) 2000-2013 the FFmpeg developers
    built on Jun 1 2013 05:26:08 with gcc 4.6 (Debian 4.6.3-1)
    configuration: --prefix=/root/ffmpeg-static/64bit --extra-cflags='-I/root/ffmpeg-static/64bit/include -static' --extra-ldflags='-L/root/ffmpeg-static/64bit/lib -static' --extra-libs='-lxml2 -lexpat -lfreetype' --enable-static --disable-shared --disable-ffserver --disable-doc --enable-bzlib --enable-zlib --enable-postproc --enable-runtime-cpudetect --enable-libx264 --enable-gpl --enable-libtheora --enable-libvorbis --enable-libmp3lame --enable-gray --enable-libass --enable-libfreetype --enable-libopenjpeg --enable-libspeex --enable-libvo-aacenc --enable-libvo-amrwbenc --enable-version3 --enable-libvpx
    libavutil 52. 34.100 / 52. 34.100
    libavcodec 55. 12.102 / 55. 12.102
    libavformat 55. 8.102 / 55. 8.102
    libavdevice 55. 2.100 / 55. 2.100
    libavfilter 3. 73.100 / 3. 73.100
    libswscale 2. 3.100 / 2. 3.100
    libswresample 0. 17.102 / 0. 17.102
    libpostproc 52. 3.100 / 52. 3.100