Newest 'ffmpeg' Questions - Stack Overflow

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

Les articles publiés sur le site

  • ffmpeg : Concatenating webm files - output file shows first video only

    12 juillet 2016, par Bora B.

    I have 6 webm files (video/audio) which I captured through WebRTC (web browser getUserMedia API). Individually they all play fine. They're all 15 seconds in length and 2MB in size each.

    When I concatenate them with ffmpeg using concat demuxer (documentation), the resulting output file is 12MB (wchich I expect), but when I play it , it only plays the first video and then it stops after 15 seconds. Tried playing it with Google Chrome as well as VLC.

    This is the ffmpeg command I am using:

    ffmpeg -f concat -i mylist.txt -c copy output3.webm
    

    And here is mylist.txt:

    file 'tmpD08D.webm'
    file 'tmpD08E.webm'
    file 'tmpD08F.webm'
    file 'tmpD090.webm'
    file 'tmpD091.webm'
    file 'tmpD0A1.webm'
    

    Here is the ffmpeg output:

    c:\Temp\files>ffmpeg -f concat -i mylist.txt -c copy output4.webm
    ffmpeg version N-72383-g7206b94 Copyright (c) 2000-2015 the FFmpeg developers
      built with gcc 4.9.2 (GCC)
      configuration: --enable-gpl --enable-version3 --disable-w32threads --enable-av
    isynth --enable-bzlib --enable-fontconfig --enable-frei0r --enable-gnutls --enab
    le-iconv --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --
    enable-libdcadec --enable-libfreetype --enable-libgme --enable-libgsm --enable-l
    ibilbc --enable-libmodplug --enable-libmfx --enable-libmp3lame --enable-libopenc
    ore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopus --ena
    ble-librtmp --enable-libschroedinger --enable-libsoxr --enable-libspeex --enable
    -libtheora --enable-libtwolame --enable-libvidstab --enable-libvo-aacenc --enabl
    e-libvo-amrwbenc --enable-libvorbis --enable-libvpx --enable-libwavpack --enable
    -libwebp --enable-libx264 --enable-libx265 --enable-libxavs --enable-libxvid --e
    nable-lzma --enable-decklink --enable-zlib
      libavutil      54. 26.100 / 54. 26.100
      libavcodec     56. 41.100 / 56. 41.100
      libavformat    56. 33.101 / 56. 33.101
      libavdevice    56.  4.100 / 56.  4.100
      libavfilter     5. 16.101 /  5. 16.101
      libswscale      3.  1.101 /  3.  1.101
      libswresample   1.  1.100 /  1.  1.100
      libpostproc    53.  3.100 / 53.  3.100
    Input #0, concat, from 'mylist.txt':
      Duration: N/A, start: 0.000000, bitrate: N/A
        Stream #0:0: Audio: opus, 48000 Hz, mono, fltp
        Stream #0:1: Video: vp8, yuv420p, 640x480, SAR 1:1 DAR 4:3, 30 fps, 30 tbr,
    1k tbn, 1k tbc
    [webm @ 00000000003a5fe0] Codec for stream 0 does not use global headers but con
    tainer format requires global headers
    [webm @ 00000000003a5fe0] Codec for stream 1 does not use global headers but con
    tainer format requires global headers
    Output #0, webm, to 'output4.webm':
      Metadata:
        encoder         : Lavf56.33.101
        Stream #0:0: Video: vp8, yuv420p, 640x480 [SAR 1:1 DAR 4:3], q=2-31, 30 fps,
     30 tbr, 1k tbn, 1k tbc
        Stream #0:1: Audio: opus, 48000 Hz, mono
    Stream mapping:
      Stream #0:1 -> #0:0 (copy)
      Stream #0:0 -> #0:1 (copy)
    Press [q] to stop, [?] for help
    [concat @ 0000000000361e20] DTS 0 < 14911 out of order
    [webm @ 00000000003a5fe0] Non-monotonous DTS in output stream 0:0; previous: 149
    11, current: 0; changing to 14911. This may result in incorrect timestamps in th
    e output file.
    [webm @ 00000000003a5fe0] Non-monotonous DTS in output stream 0:0; previous: 149
    11, current: 48; changing to 14911. This may result in incorrect timestamps in t
    he output file.
    [webm @ 00000000003a5fe0] Non-monotonous DTS in output stream 0:1; previous: 148
    69, current: 59; changing to 14869. This may result in incorrect timestamps in t
    he output file.
    

    Note that I see a lot of "Non-monotonous DTS in output stream " errors in the ffmpeg output.

    What am I doing wrong here?

  • How to read information from .3gp and .mp4 using ffmpeg-php ?

    12 juillet 2016, par Neltharian

    I have a bit of a problem with ffmpeg-php. I'm trying to get some information from video files and it works pretty fine with file formats like .avi, .mpg or .flv but when I try to use .3gp or .mp4 in:

    $movie = new ffmpeg_movie('path/to/file/test.3gp');
    

    I get error like this :

    ffmpeg_movie::__construct() []: ISO: File Type Major Brand: 3gp5 
    

    or

    ffmpeg_movie::__construct() []: ISO: File Type Major Brand: mp42 
    

    I installed ffmpeg-php on WAMP using instructions found here: http://stackoverflow.com/questions/1172916/how-to-install-ffmpeg-in-wampserver-2-0-windows-xp

    I need those information to send them to ffmpeg using exec(). Anyone could help me with this?

  • Integrate the FFMPEG in android

    12 juillet 2016, par John Smith

    I'm trying to integrate FFMPEG into my android app(I am trying to implement a video cropper), I was following the steps from an Kevin Law's answer here:

    quora question

    I have downloaded the android ndk. In the step two it says I should modify the package name which I did. It also says that I should modify the flags for codecs I'm interested in. So my first question is

    1. Which codecs would I need to work with mp4, 3gp and maybe avi files in android?

    I tried to leave everything by default and build with build.sh script but it fails on the line where I have changed the package name

        FLAGS="$FLAGS --soname-prefix=/data/data/cropit.dassem.com.videocropper/lib/"
    

    with

    Unknown option "--soname-prefix=/data/data/cropit.dassem.com.videocropper/lib/".
    See ./configure --help for available options.
    
    1. Now is there anyone familiar with FFMPEG integration and sees something that I have missed?

    I do not want to use the pre-compiled FFMPEG libraries because they are really big, the ones I found take around 15 MB of space. I've read somewhere that if i'll compile and integrate FFMPEG myself it will be much smaller.

    1. Are there any easier ways of cropping video on android?

    Maybe there is no point in dealing with this, which proves quite a pain I must admit, and there is an easier solution available?

  • Sync Audio/Video in MP4 using AutoGen FFmpeg library

    12 juillet 2016, par williamtroup

    I'm currently having problems making my audio and video streams stay synced.

    These are the AVCodecContexts I'm using:

    For Video:

    AVCodec* videoCodec = ffmpeg.avcodec_find_encoder(AVCodecID.AV_CODEC_ID_H264)
    AVCodecContext* videoCodecContext = ffmpeg.avcodec_alloc_context3(videoCodec);
    videoCodecContext->bit_rate = 400000;
    videoCodecContext->width = 1280;
    videoCodecContext->height = 720;
    videoCodecContext->gop_size = 12;
    videoCodecContext->max_b_frames = 1;
    videoCodecContext->pix_fmt = videoCodec->pix_fmts[0];
    videoCodecContext->codec_id = videoCodec->id;
    videoCodecContext->codec_type = videoCodec->type;
    videoCodecContext->time_base = new AVRational
    {
        num = 1,
        den = 30
    };
    

    For Audio:

    AVCodec* audioCodec = ffmpeg.avcodec_find_encoder(AVCodecID.AV_CODEC_ID_AAC)
    AVCodecContext* audioCodecContext = ffmpeg.avcodec_alloc_context3(audioCodec);
    audioCodecContext->bit_rate = 1280000;
    audioCodecContext->sample_rate = 48000;
    audioCodecContext->channels = 2;
    audioCodecContext->channel_layout = ffmpeg.AV_CH_LAYOUT_STEREO;
    audioCodecContext->frame_size = 1024;
    audioCodecContext->sample_fmt = audioCodec->sample_fmts[0];
    audioCodecContext->profile = ffmpeg.FF_PROFILE_AAC_LOW;
    audioCodecContext->codec_id = audioCodec->id;
    audioCodecContext->codec_type = audioCodec->type;
    

    When writing the video frames, I setup the PTS position as follows:

    outputFrame->pts = frameIndex;  // The current index of the image frame being written
    

    I then encode the frame using avcodec_encode_video2(). After this, I call the following to setup the time stamps:

    ffmpeg.av_packet_rescale_ts(&packet, videoCodecContext->time_base, videoStream->time_base);
    

    This plays perfectly.

    However, when I do the same for audio, the video plays in slow motion, plays the audio first and then carry's on with the video afterwards with no sound.

    I cannot find an example anywhere of how to set pts/dts positions for video/audio in an MP4 file. Any examples of help would be great!

    Also, I'm writing the video frames first, after which (once they are all written) I write the audio. I've updated this question with the adjusted values suggested in the comments.

    I've uploaded a test video to show my results here: http://www.filedropper.com/test_124

  • ffmpeg in Python subprocess - Unable to find a suitable output format for 'pipe :'

    12 juillet 2016, par Spencer

    Trying to burn subs into video with ffmpeg via Python. Works fine in the command line, but when calling from Python subprocess with:

    p = subprocess.Popen('cd ~/Downloads/yt/; ffmpeg -i ./{video} -vf subtitles=./{subtitles} {out}.mp4'.format(video=vid.replace(' ', '\ '), subtitles=subs, out='out.mp4'), shell=True)
    

    I get:

    Unable to find a suitable output format for 'pipe:'
    

    Full traceback:

    'ffmpeg version 2.7.2 Copyright (c) 2000-2015 the FFmpeg developers
      built with Apple LLVM version 6.1.0 (clang-602.0.53) (based on LLVM 3.6.0svn)
      configuration: --prefix=/usr/local/Cellar/ffmpeg/2.7.2_1 --enable-shared --enable-pthreads --enable-gpl --enable-version3 --enable-hardcoded-tables --enable-avresample --cc=clang --host-cflags= --host-ldflags= --enable-opencl --enable-libx264 --enable-libmp3lame --enable-libvo-aacenc --enable-libxvid --enable-libfreetype --enable-libvpx --enable-libass --enable-libfdk-aac --enable-nonfree --enable-vda
      libavutil      54. 27.100 / 54. 27.100
      libavcodec     56. 41.100 / 56. 41.100
      libavformat    56. 36.100 / 56. 36.100
      libavdevice    56.  4.100 / 56.  4.100
      libavfilter     5. 16.101 /  5. 16.101
      libavresample   2.  1.  0 /  2.  1.  0
      libswscale      3.  1.101 /  3.  1.101
      libswresample   1.  2.100 /  1.  2.100
      libpostproc    53.  3.100 / 53.  3.100
    Input #0, mov,mp4,m4a,3gp,3g2,mj2, from './OnHub - a router for the new way to Wi-Fi-HNnfHP7VDP8.mp4':
      Metadata:
        major_brand     : isom
        minor_version   : 512
        compatible_brands: isomiso2avc1mp41
        encoder         : Lavf56.36.100
      Duration: 00:00:53.94, start: 0.000000, bitrate: 2092 kb/s
        Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 1920x1080 [SAR 1:1 DAR 16:9], 1961 kb/s, 23.98 fps, 23.98 tbr, 90k tbn, 47.95 tbc (default)
        Metadata:
          handler_name    : VideoHandler
        Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 125 kb/s (default)
        Metadata:
          handler_name    : SoundHandler
    [NULL @ 0x7fc07b077600] Unable to find a suitable output format for 'pipe:'
    pipe:: Invalid argument'