Como controlar a geração de quadros-chave no ffmpeg

0

Eu uso o ffmpeg para transcodificar um arquivo FLV que tem apenas um GOP, ou seja, apenas o primeiro quadro é um I-frame. O problema é que meu arquivo de saída tem mais de um quadro I, mas preciso que ele tenha apenas um no começo.

O objetivo é alterar a taxa de bits.

Eu uso este comando para converter:

ffmpeg -y -copyts -i 1.flv -acodec copy -vcodec libx264 -r 30 -b:v 500k -g 500 -keyint_min 500 1_500k.flv

Saída do FFmpeg:

ffmpeg version 1.2 Copyright (c) 2000-2013 the FFmpeg developers
  built on May  3 2013 10:11:18 with gcc 4.1.2 (GCC) 20080704 (Red Hat 4.1.2-48)
  configuration: --prefix=/usr/local/lib --enable-gpl --enable-nonfree --enable-postproc --enable-pthreads --enable-x11grab --enable-swscale --enable-version3 --disable-ffplay --disable-ffserver --enable-filter=movie --enable-frei0r --enable-libfaac --enable-libmp3lame --enable-libx264 --enable-libxvid --enable-libopencore-amrnb --enable-libopencore-amrwb --extra-cflags='-O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic -fPIC' --extra-ldflags=-ldl --enable-shared --enable-libopenjpeg --enable-encoder=png --enable-encoder=bmp --enable-encoder=wmv1 --enable-encoder=wmv2
  libavutil      52. 18.100 / 52. 18.100
  libavcodec     54. 92.100 / 54. 92.100
  libavformat    54. 63.104 / 54. 63.104
  libavdevice    54.  3.103 / 54.  3.103
  libavfilter     3. 42.103 /  3. 42.103
  libswscale      2.  2.100 /  2.  2.100
  libswresample   0. 17.102 /  0. 17.102
  libpostproc    52.  2.100 / 52.  2.100
Input #0, flv, from '1.flv':
  Duration: 00:00:03.86, start: 1.000000, bitrate: 195 kb/s
    Stream #0:0: Video: vp6f, yuv420p, 320x240, 30 tbr, 1k tbn, 1k tbc
    Stream #0:1: Audio: mp3, 22050 Hz, mono, s16p, 48 kb/s
[libx264 @ 0xbffcc0] using cpu capabilities: MMX2 SSE2Fast FastShuffle SSEMisalign LZCNT
[libx264 @ 0xbffcc0] profile High, level 2.0
 [libx264 @ 0xbffcc0] 264 - core 118 r0+7M 0176d43 - H.264/MPEG-4 AVC codec - Copyleft 2003-2011 - 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=1 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=500 keyint_min=251 scenecut=40 intra_refresh=0 rc_lookahead=40 rc=abr mbtree=1 bitrate=500 ratetol=1.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 ip_ratio=1.40 aq=1:1.00
Output #0, flv, to '1_500k.flv':
  Metadata:
    encoder         : Lavf54.63.104
    Stream #0:0: Video: h264 ([7][0][0][0] / 0x0007), yuv420p, 320x240, q=-1--1, 500 kb/s, 1k tbn, 30 tbc
    Stream #0:1: Audio: mp3 ([2][0][0][0] / 0x0002), 22050 Hz, mono, 48 kb/s
Stream mapping:
  Stream #0:0 -> #0:0 (vp6f -> libx264)
  Stream #0:1 -> #0:1 (copy)
Press [q] to stop, [?] for help
frame=   75 fps=0.0 q=18.0 Lsize=     148kB time=00:00:03.88 bitrate= 311.7kbits/s    

video:127kB audio:17kB subtitle:0 global headers:0kB muxing overhead 2.455463%
[libx264 @ 0xbffcc0] frame I:1     Avg QP:19.31  size: 14022
[libx264 @ 0xbffcc0] frame P:53    Avg QP:13.74  size:  1965
[libx264 @ 0xbffcc0] frame B:21    Avg QP:21.83  size:   551
[libx264 @ 0xbffcc0] consecutive B-frames: 62.7%  0.0%  0.0% 37.3%
[libx264 @ 0xbffcc0] mb I  I16..4:  2.7% 64.0% 33.3%
[libx264 @ 0xbffcc0] mb P  I16..4:  0.1%  0.2%  0.0%  P16..4: 40.3%  5.5% 10.6%  0.0%  0.0%    skip:43.4%
[libx264 @ 0xbffcc0] mb B  I16..4:  0.1%  0.1%  0.0%  B16..8: 30.6%  3.5%  2.5%  direct: 2.8%  skip:60.4%  L0:43.8% L1:49.3% BI: 6.9%
[libx264 @ 0xbffcc0] final ratefactor: 14.33
[libx264 @ 0xbffcc0] 8x8 transform intra:64.8% inter:86.4%
[libx264 @ 0xbffcc0] coded y,uvDC,uvAC intra: 87.5% 96.0% 75.6% inter: 22.7% 21.9% 9.5%
[libx264 @ 0xbffcc0] i16 v,h,dc,p: 29% 19% 48%  5%
[libx264 @ 0xbffcc0] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu:  9% 22% 34%  6%  4%  4%  8%  5%  9%
[libx264 @ 0xbffcc0] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 23% 20% 13%  7%  6%  5%  9%  6% 10%
[libx264 @ 0xbffcc0] i8c dc,h,v,p: 59% 19% 16%  6%
[libx264 @ 0xbffcc0] Weighted P-Frames: Y:0.0% UV:0.0%
[libx264 @ 0xbffcc0] ref P L0: 79.2%  7.6%  8.3%  4.9%
[libx264 @ 0xbffcc0] ref B L0: 91.0%  6.4%  2.6%
[libx264 @ 0xbffcc0] ref B L1: 93.3%  6.7%
[libx264 @ 0xbffcc0] kb/s:362.09
    
por yangtao 07.05.2014 / 10:13

1 resposta

0

Seu arquivo de saída já possui apenas um quadro I.

Você pode ver isso nos logs x264:

[libx264 @ 0xbffcc0] frame I:1     Avg QP:19.31  size: 14022
[libx264 @ 0xbffcc0] frame P:53    Avg QP:13.74  size:  1965
[libx264 @ 0xbffcc0] frame B:21    Avg QP:21.83  size:   551

O número ao lado do tipo de quadro é a contagem.

    
por 07.05.2014 / 10:34

Tags