[FFmpeg-user] cutting at keyframes?

Gregory1234 gregory.aimo at gmail.com
Thu Aug 2 19:20:34 CEST 2012


Hi Carl,

Thanks.  I wasn't clear.  Let me try to clarify,

The codec of the input file 01087001.MOV is mpeg2video (main) in a .mov
container.  I have to transcode it to a file synctest2.mp4 that will play on
our fms server.  The output file that I want to play on the fms server is
codec h.264 in a .mp4 container. 

[gaimo at de-dev-trans22 ~]$ ffmpeg -i 01087001.MOV -t 50  synctest2.mp4
ffmpeg version 0.11.1 Copyright (c) 2000-2012 the FFmpeg developers
  built on Jul 30 2012 18:48:45 with gcc 4.1.2 20080704 (Red Hat 4.1.2-52)
  configuration: --prefix=/usr/local --enable-gpl --enable-version3
--enable-nonfree --enable-libx264 --enable-libxvid --enable-shared
--enable-postproc --enable-swscale --enable-avfilter --enable-pthreads
--enable-yasm --enable-libfaac --enable-libmp3lame --enable-libvorbis
--enable-libvpx
  libavutil      51. 54.100 / 51. 54.100
  libavcodec     54. 23.100 / 54. 23.100
  libavformat    54.  6.100 / 54.  6.100
  libavdevice    54.  0.100 / 54.  0.100
  libavfilter     2. 77.100 /  2. 77.100
  libswscale      2.  1.100 /  2.  1.100
  libswresample   0. 15.100 /  0. 15.100
  libpostproc    52.  0.100 / 52.  0.100
Guessed Channel Layout for  Input Stream #0.1 : mono
Guessed Channel Layout for  Input Stream #0.2 : mono
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '01087001.MOV':
  Metadata:
    major_brand     : qt  
    minor_version   : 537331968
    compatible_brands: qt  CDes
    creation_time   : 2008-06-06 20:25:39
  Duration: 00:11:43.50, start: 0.000000, bitrate: 20349 kb/s
    Stream #0:0(eng): Video: mpeg2video (Main) (xdv1 / 0x31766478), yuv420p,
1280x720 [SAR 1:1 DAR 16:9], 18000 kb/s, 29.97 fps, 29.97 tbr, 2997 tbn,
59.94 tbc
    Metadata:
      creation_time   : 2008-06-06 20:25:39
    Stream #0:1(eng): Audio: pcm_s24be (lpcm / 0x6D63706C), 48000 Hz, mono,
s32, 1152 kb/s
    Metadata:
      creation_time   : 2008-06-06 20:25:39
    Stream #0:2(eng): Audio: pcm_s24be (lpcm / 0x6D63706C), 48000 Hz, mono,
s32, 1152 kb/s
    Metadata:
      creation_time   : 2008-06-06 20:25:39
    Stream #0:3(eng): Data: none (tmcd / 0x64636D74)
    Metadata:
      creation_time   : 2008-06-06 20:25:39
      timecode        : 00:00:07;02
[buffer @ 0x1a833a0] w:1280 h:720 pixfmt:yuv420p tb:1/2997 sar:1/1
sws_param:flags=2
[buffersink @ 0x1a83da0] No opaque field provided
[aformat @ 0x1a808c0] auto-inserting filter 'auto-inserted resampler 0'
between the filter 'src' and the filter 'aformat'
[aresample @ 0x1ac02e0] chl:mono fmt:s32 r:48000Hz -> chl:mono fmt:s16
r:48000Hz
[libx264 @ 0x1a81ac0] using SAR=1/1
[libx264 @ 0x1a81ac0] using cpu capabilities: MMX2 SSE2Fast SSSE3
FastShuffle SSE4.2
[libx264 @ 0x1a81ac0] profile High, level 3.1
[libx264 @ 0x1a81ac0] 264 - core 122 - H.264/MPEG-4 AVC codec - Copyleft
2003-2012 - 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=3 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 'synctest2.mp4':
  Metadata:
    major_brand     : qt  
    minor_version   : 537331968
    compatible_brands: qt  CDes
    creation_time   : 2008-06-06 20:25:39
    encoder         : Lavf54.6.100
    Stream #0:0(eng): Video: h264 (![0][0][0] / 0x0021), yuv420p, 1280x720
[SAR 1:1 DAR 16:9], q=-1--1, 2997 tbn, 29.97 tbc
    Metadata:
      creation_time   : 2008-06-06 20:25:39
    Stream #0:1(eng): Audio: aac (@[0][0][0] / 0x0040), 48000 Hz, mono, s16,
128 kb/s
    Metadata:
      creation_time   : 2008-06-06 20:25:39
Stream mapping:
  Stream #0:0 -> #0:0 (mpeg2video -> libx264)
  Stream #0:1 -> #0:1 (pcm_s24be -> libfaac)
Press [q] to stop, [?] for help
[mpeg2video @ 0x1a8b360] warning: first frame is no keyframe
frame= 1499 fps= 30 q=-1.0 Lsize=    6351kB time=00:00:49.94
bitrate=1041.6kbits/s    
video:5793kB audio:505kB global headers:0kB muxing overhead 0.851820%
[libx264 @ 0x1a81ac0] frame I:6     Avg QP:21.95  size: 42839
[libx264 @ 0x1a81ac0] frame P:926   Avg QP:24.26  size:  5262
[libx264 @ 0x1a81ac0] frame B:567   Avg QP:25.91  size:  1414
[libx264 @ 0x1a81ac0] consecutive B-frames: 25.3% 71.9%  2.8%  0.0%
[libx264 @ 0x1a81ac0] mb I  I16..4: 28.7% 56.7% 14.6%
[libx264 @ 0x1a81ac0] mb P  I16..4:  0.4%  0.7%  0.1%  P16..4: 22.8%  3.8% 
3.3%  0.0%  0.0%    skip:69.0%
[libx264 @ 0x1a81ac0] mb B  I16..4:  0.0%  0.0%  0.0%  B16..8: 23.3%  0.7% 
0.1%  direct: 0.1%  skip:75.7%  L0:34.3% L1:62.8% BI: 3.0%
[libx264 @ 0x1a81ac0] 8x8 transform intra:56.8% inter:80.5%
[libx264 @ 0x1a81ac0] coded y,uvDC,uvAC intra: 50.1% 59.1% 18.6% inter: 5.7%
7.7% 0.1%
[libx264 @ 0x1a81ac0] i16 v,h,dc,p: 16% 40%  7% 37%
[libx264 @ 0x1a81ac0] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 17% 21% 26%  4%  6%  6% 
7%  6%  6%
[libx264 @ 0x1a81ac0] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 25% 27% 18%  4%  6%  6% 
6%  5%  4%
[libx264 @ 0x1a81ac0] i8c dc,h,v,p: 46% 30% 19%  6%
[libx264 @ 0x1a81ac0] Weighted P-Frames: Y:1.7% UV:0.0%
[libx264 @ 0x1a81ac0] ref P L0: 66.4% 14.7% 13.4%  5.5%  0.0%
[libx264 @ 0x1a81ac0] ref B L0: 75.6% 24.2%  0.2%
[libx264 @ 0x1a81ac0] ref B L1: 99.6%  0.4%
[libx264 @ 0x1a81ac0] kb/s:948.68
[gaimo at de-dev-trans22 ~]$ 


 Ultimately I want the output file to start with a keyframe so that it will
play in sync - but it appears as if the input file does not start with a
keyframe.  I tried to force a keyframe - see below.  But that didn't work so
I was wondering how to cut off all frames till both audio and video on the
output file start at the first video keyframe 

[gaimo at de-dev-trans22 ~]$ ffmpeg -i 01087001.MOV -t 50 -force_key_frames 1
synctest3.mp4
ffmpeg version 0.11.1 Copyright (c) 2000-2012 the FFmpeg developers
  built on Jul 30 2012 18:48:45 with gcc 4.1.2 20080704 (Red Hat 4.1.2-52)
  configuration: --prefix=/usr/local --enable-gpl --enable-version3
--enable-nonfree --enable-libx264 --enable-libxvid --enable-shared
--enable-postproc --enable-swscale --enable-avfilter --enable-pthreads
--enable-yasm --enable-libfaac --enable-libmp3lame --enable-libvorbis
--enable-libvpx
  libavutil      51. 54.100 / 51. 54.100
  libavcodec     54. 23.100 / 54. 23.100
  libavformat    54.  6.100 / 54.  6.100
  libavdevice    54.  0.100 / 54.  0.100
  libavfilter     2. 77.100 /  2. 77.100
  libswscale      2.  1.100 /  2.  1.100
  libswresample   0. 15.100 /  0. 15.100
  libpostproc    52.  0.100 / 52.  0.100
Guessed Channel Layout for  Input Stream #0.1 : mono
Guessed Channel Layout for  Input Stream #0.2 : mono
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '01087001.MOV':
  Metadata:
    major_brand     : qt  
    minor_version   : 537331968
    compatible_brands: qt  CDes
    creation_time   : 2008-06-06 20:25:39
  Duration: 00:11:43.50, start: 0.000000, bitrate: 20349 kb/s
    Stream #0:0(eng): Video: mpeg2video (Main) (xdv1 / 0x31766478), yuv420p,
1280x720 [SAR 1:1 DAR 16:9], 18000 kb/s, 29.97 fps, 29.97 tbr, 2997 tbn,
59.94 tbc
    Metadata:
      creation_time   : 2008-06-06 20:25:39
    Stream #0:1(eng): Audio: pcm_s24be (lpcm / 0x6D63706C), 48000 Hz, mono,
s32, 1152 kb/s
    Metadata:
      creation_time   : 2008-06-06 20:25:39
    Stream #0:2(eng): Audio: pcm_s24be (lpcm / 0x6D63706C), 48000 Hz, mono,
s32, 1152 kb/s
    Metadata:
      creation_time   : 2008-06-06 20:25:39
    Stream #0:3(eng): Data: none (tmcd / 0x64636D74)
    Metadata:
      creation_time   : 2008-06-06 20:25:39
      timecode        : 00:00:07;02
[buffer @ 0x1dae4ac0] w:1280 h:720 pixfmt:yuv420p tb:1/2997 sar:1/1
sws_param:flags=2
[buffersink @ 0x1dae4f20] No opaque field provided
[aformat @ 0x1db1a0a0] auto-inserting filter 'auto-inserted resampler 0'
between the filter 'src' and the filter 'aformat'
[aresample @ 0x1db1ab80] chl:mono fmt:s32 r:48000Hz -> chl:mono fmt:s16
r:48000Hz
[libx264 @ 0x1dae2ac0] using SAR=1/1
[libx264 @ 0x1dae2ac0] using cpu capabilities: MMX2 SSE2Fast SSSE3
FastShuffle SSE4.2
[libx264 @ 0x1dae2ac0] profile High, level 3.1
[libx264 @ 0x1dae2ac0] 264 - core 122 - H.264/MPEG-4 AVC codec - Copyleft
2003-2012 - 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=3 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 'synctest3.mp4':
  Metadata:
    major_brand     : qt  
    minor_version   : 537331968
    compatible_brands: qt  CDes
    creation_time   : 2008-06-06 20:25:39
    encoder         : Lavf54.6.100
    Stream #0:0(eng): Video: h264 (![0][0][0] / 0x0021), yuv420p, 1280x720
[SAR 1:1 DAR 16:9], q=-1--1, 2997 tbn, 29.97 tbc
    Metadata:
      creation_time   : 2008-06-06 20:25:39
    Stream #0:1(eng): Audio: aac (@[0][0][0] / 0x0040), 48000 Hz, mono, s16,
128 kb/s
    Metadata:
      creation_time   : 2008-06-06 20:25:39
Stream mapping:
  Stream #0:0 -> #0:0 (mpeg2video -> libx264)
  Stream #0:1 -> #0:1 (pcm_s24be -> libfaac)
Press [q] to stop, [?] for help
[mpeg2video @ 0x1daec360] warning: first frame is no keyframe
frame= 1499 fps= 28 q=-1.0 Lsize=    6395kB time=00:00:49.94
bitrate=1048.8kbits/s    
video:5837kB audio:505kB global headers:0kB muxing overhead 0.846011%
[libx264 @ 0x1dae2ac0] frame I:7     Avg QP:21.64  size: 44213
[libx264 @ 0x1dae2ac0] frame P:925   Avg QP:24.27  size:  5249
[libx264 @ 0x1dae2ac0] frame B:567   Avg QP:25.89  size:  1430
[libx264 @ 0x1dae2ac0] consecutive B-frames: 25.3% 71.9%  2.8%  0.0%
[libx264 @ 0x1dae2ac0] mb I  I16..4: 26.8% 58.2% 15.0%
[libx264 @ 0x1dae2ac0] mb P  I16..4:  0.4%  0.7%  0.1%  P16..4: 23.0%  3.7% 
3.3%  0.0%  0.0%    skip:68.8%
[libx264 @ 0x1dae2ac0] mb B  I16..4:  0.0%  0.0%  0.0%  B16..8: 23.5%  0.7% 
0.1%  direct: 0.1%  skip:75.5%  L0:34.1% L1:63.0% BI: 3.0%
[libx264 @ 0x1dae2ac0] 8x8 transform intra:56.9% inter:80.7%
[libx264 @ 0x1dae2ac0] coded y,uvDC,uvAC intra: 50.5% 59.5% 18.9% inter:
5.7% 7.8% 0.1%
[libx264 @ 0x1dae2ac0] i16 v,h,dc,p: 16% 40%  6% 38%
[libx264 @ 0x1dae2ac0] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 18% 21% 26%  4%  6% 
6%  7%  6%  6%
[libx264 @ 0x1dae2ac0] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 27% 26% 17%  4%  5% 
6%  6%  5%  4%
[libx264 @ 0x1dae2ac0] i8c dc,h,v,p: 45% 30% 20%  5%
[libx264 @ 0x1dae2ac0] Weighted P-Frames: Y:1.7% UV:0.0%
[libx264 @ 0x1dae2ac0] ref P L0: 66.5% 14.6% 13.4%  5.6%  0.0%
[libx264 @ 0x1dae2ac0] ref B L0: 75.5% 24.2%  0.2%
[libx264 @ 0x1dae2ac0] ref B L1: 99.7%  0.3%
[libx264 @ 0x1dae2ac0] kb/s:955.83
[gaimo at de-dev-trans22 ~]$ 







--
View this message in context: http://ffmpeg-users.933282.n4.nabble.com/cutting-at-keyframes-tp4652236p4652239.html
Sent from the FFmpeg-users mailing list archive at Nabble.com.


More information about the ffmpeg-user mailing list