Newest 'ffmpeg' Questions - Stack Overflow

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

Les articles publiés sur le site

  • Getting frames from video and not with MediaMetadataRetriever

    2 décembre 2015, par Nativ

    I'm trying to find a way to extract video into frames. The main goal is to change the image using openGl and construct the video again.

    the problem is that I can't find a desent way to extract the video. I saw that lots of familiar questions were answered with the use of MediaMetadataRetriever but I don't want to use it because it works really slow.

    I did a little research about libraries like - jcodec, ffmpeg ,openCV and mp4parser.

    jcodec - works fine but really slow, every getFrame() costs 1 second.

    ffmpeg - under GPL license which means that you'll have to publish your code.

    openCV - complicated. Maybe I can accomplish what I need with it but it looks too complicate and I'm looking for a simpler solution.

    mp4parser - extracts decoded frames but doesn't support encoding them to jpg/png.

    Would be wonderful to get some help on that one. tnx

  • webm to mp4 conversion using ffmpeg

    2 décembre 2015, par Pavan K

    When I try to convert a webm file to mp4 the output is very very choppy and it appears as if many frames have been dropped by ffmpeg

    I used the following commands to convert

    ffmpeg -i movie.webm movie.mp4
    ffmpeg -i movie.webm -vcodec libx264 movie.mp4
    ffmpeg -i movie.webm -vcodec libx264 -qscale 0 movie.mp4
    

    All of them have the same problem. When I use ffprobe it seems to show the frames more or less properly.

    UPDATE:

     built on Jun 14 2013 14:31:50 with gcc 4.7 (Ubuntu/Linaro 4.7.2-2ubuntu1)
      configuration: --prefix=/home/user2/ffmpeg_build --extra-cflags=-I/home/user2/ffmpeg_build/include --extra-ldflags=-L/home/pavan4/ffmpeg_build/lib --bindir=/home/pavan4/bin --extra-libs=-ldl --enable-gpl --enable-libass --enable-libfdk-aac --enable-libmp3lame --enable-libtheora --enable-libvorbis --enable-libvpx --enable-libx264 --enable-nonfree --enable-x11grab
      libavutil      52. 35.101 / 52. 35.101
      libavcodec     55. 16.100 / 55. 16.100
      libavformat    55.  8.102 / 55.  8.102
      libavdevice    55.  2.100 / 55.  2.100
      libavfilter     3. 77.101 /  3. 77.101
      libswscale      2.  3.100 /  2.  3.100
      libswresample   0. 17.102 /  0. 17.102
      libpostproc    52.  3.100 / 52.  3.100
    Hyper fast Audio and Video encoder
    usage: ffmpeg [options] [[infile options] -i infile]... {[outfile options] outfile}...
    
    Use -h to get full help or, even better, run 'man ffmpeg'
    
    Input #0, matroska,webm, from '1.webm':
      Duration: 00:00:10.64, start: 0.000000, bitrate: 5024 kb/s
        Stream #0:0(eng): Video: vp8, yuv420p, 1280x720, SAR 1:1 DAR 16:9, 1k fps, 1k tbr, 1k tbn, 1k tbc (default)
    [libx264 @ 0x1d966a0] using SAR=1/1
    [libx264 @ 0x1d966a0] MB rate (3600000) > level limit (2073600)
    [libx264 @ 0x1d966a0] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2
    [libx264 @ 0x1d966a0] profile High, level 5.2
    [libx264 @ 0x1d966a0] 264 - core 133 r2 a3ac64b - H.264/MPEG-4 AVC codec - Copyleft 2003-2013 - http://www.videolan.org/x264.html - options: cabac=1 ref=3 deblock=1:0:0 analyse=0x3:0x113 me=hex subme=7 psy=1 psy_rd=1.00:0.00 mixed_ref=1 me_range=16 chroma_me=1 trellis=1 8x8dct=1 cqm=0 deadzone=21,11 fast_pskip=1 chroma_qp_offset=-2 threads=12 lookahead_threads=2 sliced_threads=0 nr=0 decimate=1 interlaced=0 bluray_compat=0 constrained_intra=0 bframes=3 b_pyramid=2 b_adapt=1 b_bias=0 direct=1 weightb=1 open_gop=0 weightp=2 keyint=250 keyint_min=25 scenecut=40 intra_refresh=0 rc_lookahead=40 rc=crf mbtree=1 crf=23.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 ip_ratio=1.40 aq=1:1.00
    Output #0, mp4, to '1_conv4.mp4':
      Metadata:
        encoder         : Lavf55.8.102
        Stream #0:0(eng): Video: h264 (libx264) ([33][0][0][0] / 0x0021), yuv420p, 1280x720 [SAR 1:1 DAR 16:9], q=-1--1, 16k tbn, 1k tbc (default)
    Stream mapping:
    Stream #0:0 -> #0:0 (vp8 -> libx264)
    Press [q] to stop, [?] for help
    frame=  168 fps=0.0 q=33.0 size=      62kB time=00:00:00.11 bitrate=4606.0kbits/frame=  293 fps=230 q=33.0 size=     138kB time=00:00:00.23 bitrate=4809.7kbits/
    
    video:5620kB audio:0kB subtitle:0 global headers:0kB muxing overhead 2.212461%
    [libx264 @ 0x1d966a0] frame I:46    Avg QP:18.50  size: 39849
    [libx264 @ 0x1d966a0] frame P:2940  Avg QP:18.27  size:  1222
    [libx264 @ 0x1d966a0] frame B:7651  Avg QP:17.68  size:    43
    [libx264 @ 0x1d966a0] consecutive B-frames:  4.0%  0.2%  0.3% 95.5%
    [libx264 @ 0x1d966a0] mb I  I16..4: 19.9% 63.2% 16.9%
    [libx264 @ 0x1d966a0] mb P  I16..4:  0.2%  0.5%  0.1%  P16..4:  3.9%  1.1%  0.6%  0.0%  0.0%    skip:93.6%
    [libx264 @ 0x1d966a0] mb B  I16..4:  0.0%  0.0%  0.0%  B16..8:  0.2%  0.0%  0.0%  direct: 0.0%  skip:99.8%  L0:25.1% L1:74.9% BI: 0.0%
    [libx264 @ 0x1d966a0] 8x8 transform intra:63.6% inter:75.9%
    [libx264 @ 0x1d966a0] coded y,uvDC,uvAC intra: 61.5% 53.4% 24.4% inter: 0.5% 0.5% 0.0%
    [libx264 @ 0x1d966a0] i16 v,h,dc,p: 52% 19% 19% 11%
    [libx264 @ 0x1d966a0] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 32% 17% 13%  4%  6%  9%  5%  8%  6%
    [libx264 @ 0x1d966a0] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 30% 18% 14%  5%  8% 10%  6%  6%  3%
    [libx264 @ 0x1d966a0] i8c dc,h,v,p: 55% 17% 24%  4%
    [libx264 @ 0x1d966a0] Weighted P-Frames: Y:0.0% UV:0.0%
    [libx264 @ 0x1d966a0] ref P L0: 82.5% 13.2%  4.0%  0.3%
    [libx264 @ 0x1d966a0] ref B L0: 60.2% 39.2%  0.6%
    [libx264 @ 0x1d966a0] ref B L1: 98.5%  1.5%
    [libx264 @ 0x1d966a0] kb/s:4327.77
    
  • ffmpeg read_frame set timeout, i dont know the time unit when i use av_dict_set set timeout

    2 décembre 2015, par ICYMYM

    i am confused, when i use av_dict_set func to set timeout, but i search information about av_dict_set, i see the time unit different, so i don't no how to set it. anyone can help?

    i find some code like follow:

    pFormatCtx = avformat_alloc_context();
    
    av_dict_set(&opts, "rtsp_transport", "tcp", 0);
    //av_dict_set(&opts, "timeout", "5000000", 0);
    if(strncmp(stream_url, "rtmp:", sizeof("rtmp:")) == 0){
        av_dict_set(&opts, "timeout", "6", 0); // in secs
    }
    else if(strncmp(stream_url, "http:", sizeof("http:")) == 0){
        av_dict_set(&opts, "timeout", "6000", 0); // in ms
    }
    
    if(avformat_open_input(&pFormatCtx, stream_url, NULL, &opts)!=0)
    {
      return 1;
    }
    

    maybe it should set the time unit according to the different protocols(http or rtsp).

    who know the above code is right ? thanks very much!

  • FFMpeg cuts off silent audio at beginning of video

    2 décembre 2015, par Ned Rockson

    I'm currently merging two video files which are the same length, but one has 4 seconds of silence at the beginning. I'm using the amerge,pan filters to do this as follows:

    ffmpeg -i left-cut.webm -i right-cut.webm -filter_complex "[0:v]setpts=PTS-STARTPTS, pad=iw*2:ih[bg]; [1:v]setpts=PTS-STARTPTS[fg]; [0:a]asetpts=PTS-STARTPTS[bga]; [1:a]asetpts=PTS-STARTPTS[fga]; [bg][fg]overlay=w; [bga][fga]amerge,pan=stereo:c0code>

    The output plays fine with the videos synced perfectly, however the audio does not. Instead of syncing up, the audio that has 4 seconds of silence starts immediately causing the audio to be off by 4 seconds.

  • FFmpeg : merge 8 mono audio streams MOV file into one audio stream FLV file

    1er décembre 2015, par snucky

    I have a MOV file with eight mono audio streams, likely a 5.1 or 7.1 setup. I want to generate a for-web preview FLV file from it but in doing so lose the voices in the dialogue. FFmpeg is likely favoring an audio stream out of the eight that doesn't have the voices. When I researched ways to merge the audio streams, in order to bring the voices back, I lose the ability to execute my ffmpeg command entirely. Here's what I have at the moment (the introduction of the "-map 0" option rendered the command non-executable)

    /usr/local/bin/ffmpeg -i ../vmx_files/6711177.mov -map 0 -y -f flv -qmax 10
          -vf "scale=trunc(oh*a/2)*2:720" -ar 44100 -ab 64k assets/flv/6711177.flv
    
    
    ffmpeg version N-69160-g1013c15 Copyright (c) 2000-2015 the FFmpeg developers
      built on Jan 20 2015 09:41:10 with gcc 4.4.7 (GCC) 20120313 (Red Hat 4.4.7-11)
      configuration:
      libavutil      54. 17.100 / 54. 17.100
      libavcodec     56. 20.100 / 56. 20.100
      libavformat    56. 19.100 / 56. 19.100
      libavdevice    56.  4.100 / 56.  4.100
      libavfilter     5.  8.100 /  5.  8.100
      libswscale      3.  1.101 /  3.  1.101
      libswresample   1.  1.100 /  1.  1.100
    Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '../vmx_files/6711177.mov':
      Metadata:
        major_brand     : qt
        minor_version   : 537199360
        compatible_brands: qt
        creation_time   : 2015-11-24 23:00:27
      Duration: 00:01:48.34, start: 0.000000, bitrate: 229443 kb/s
        Stream #0:0(eng): Video: prores (apch / 0x68637061), yuv422p10le(bt709), 1920x1080, 220043 kb/s, SAR 1:1 DAR 16:9, 29.97 fps, 29.97 tbr, 2997 tbn, 2997 tbc (default)
        Metadata:
          creation_time   : 2015-11-24 23:00:27
          handler_name    : Apple Alias Data Handler
          encoder         : Apple ProRes 422 (HQ)
          timecode        : 00:59:50;00
        Stream #0:1(eng): Audio: pcm_s24le (in24 / 0x34326E69), 48000 Hz, mono, s32 (24 bit), 1152 kb/s (default)
        Metadata:
          creation_time   : 2015-11-24 23:00:27
          handler_name    : Apple Alias Data Handler
        Stream #0:2(eng): Audio: pcm_s24le (in24 / 0x34326E69), 48000 Hz, mono, s32 (24 bit), 1152 kb/s (default)
        Metadata:
          creation_time   : 2015-11-24 23:00:27
          handler_name    : Apple Alias Data Handler
        Stream #0:3(eng): Audio: pcm_s24le (in24 / 0x34326E69), 48000 Hz, mono, s32 (24 bit), 1152 kb/s (default)
        Metadata:
          creation_time   : 2015-11-24 23:00:27
          handler_name    : Apple Alias Data Handler
        Stream #0:4(eng): Audio: pcm_s24le (in24 / 0x34326E69), 48000 Hz, mono, s32 (24 bit), 1152 kb/s (default)
        Metadata:
          creation_time   : 2015-11-24 23:00:27
          handler_name    : Apple Alias Data Handler
        Stream #0:5(eng): Audio: pcm_s24le (in24 / 0x34326E69), 48000 Hz, mono, s32 (24 bit), 1152 kb/s (default)
        Metadata:
          creation_time   : 2015-11-24 23:00:27
          handler_name    : Apple Alias Data Handler
        Stream #0:6(eng): Audio: pcm_s24le (in24 / 0x34326E69), 48000 Hz, mono, s32 (24 bit), 1152 kb/s (default)
        Metadata:
          creation_time   : 2015-11-24 23:00:27
          handler_name    : Apple Alias Data Handler
        Stream #0:7(eng): Audio: pcm_s24le (in24 / 0x34326E69), 48000 Hz, mono, s32 (24 bit), 1152 kb/s (default)
        Metadata:
          creation_time   : 2015-11-24 23:00:27
          handler_name    : Apple Alias Data Handler
        Stream #0:8(eng): Audio: pcm_s24le (in24 / 0x34326E69), 48000 Hz, mono, s32 (24 bit), 1152 kb/s (default)
        Metadata:
          creation_time   : 2015-11-24 23:00:28
          handler_name    : Apple Alias Data Handler
        Stream #0:9(eng): Data: none (tmcd / 0x64636D74)
        Metadata:
          rotate          : -0
          creation_time   : 2015-11-24 23:03:22
          handler_name    : Apple Alias Data Handler
          timecode        : 00:59:50;00
    Data stream encoding not supported yet (only streamcopy)