Opened 10 years ago

Last modified 10 years ago

#3940 new defect

Wrong behavior -force_key_frames

Reported by: Andrew Owned by:
Priority: normal Component: undetermined
Version: unspecified Keywords: force_key_frames
Cc: Blocked By:
Blocking: Reproduced by developer: no
Analyzed by developer: no

Description

Summary of the bug:

With this option, some of the key frames in different locations, but should be in equal time stamps

How to reproduce:

% ffmpeg -i s-0000.nut -acodec copy -vcodec libx264 -s 640x480  -force_key_frames 0,4,8 -b 2000000 -f mpegts s-0000_1.ts

% ffmpeg -i s-0000.nut -acodec copy -vcodec libx264 -s 320x240  -force_key_frames 0,4,8 -b 2000000 -f mpegts s-0000_2.ts

% ffprobe -show_frames -select_streams v:0 -print_format csv s-0000_1.ts | grep frame,video,1 | cut -d',' -f5 | tr "\n" "," | sed 's/,$//'`

 1.483333,5.275000,5.483333,9.483333

% ffprobe -show_frames -select_streams v:0 -print_format csv s-0000_2.ts | grep frame,video,1 | cut -d',' -f5 | tr "\n" "," | sed 's/,$//'`

 1.483333,4.816667,5.483333,9.483333

ffprobe version 2.1.3 Copyright (c) 2007-2013 the FFmpeg developers
  built on May  6 2014 15:10:40 with gcc 4.6 (Ubuntu/Linaro 4.6.3-1ubuntu5)
  configuration: --prefix=/usr/local/ffmpeg-2.1.3 --enable-libx264 --enable-gpl --enable-libfaac --enable-pthreads --enable-nonfree --enable-libmp3lame
  libavutil      52. 48.101 / 52. 48.101
  libavcodec     55. 39.101 / 55. 39.101
  libavformat    55. 19.104 / 55. 19.104
  libavdevice    55.  5.100 / 55.  5.100
  libavfilter     3. 90.100 /  3. 90.100
  libswscale      2.  5.101 /  2.  5.101
  libswresample   0. 17.104 /  0. 17.104
  libpostproc    52.  3.100 / 52.  3.100

bug file https://drive.google.com/file/d/0B2ChedT8aoLaOW5ZNDlwUm5EZ3M/edit?usp=sharing

Change History (7)

comment:1 by Andrew, 10 years ago

Keywords: force_key_frames ffmpeg added; force_key_framesб ааьзуп removed

comment:2 by Carl Eugen Hoyos, 10 years ago

Is this only reproducible using an external library (libx264) or also with -vcodec mpeg4?

Please provide the complete, uncut console output of the ffmpeg command that does not produce the expected output to make this a valid ticket.

comment:3 by Carl Eugen Hoyos, 10 years ago

Component: ffmpegundetermined
Keywords: ffmpeg removed

in reply to:  3 comment:4 by Andrew, 10 years ago

Replying to cehoyos:

for mpeg4

  1. 640x480 1.400000,1.900000,2.400000,2.900000,3.400000,3.900000,4.358333,4.441667,4.525000,4.566667,4.608333,4.650000,4.691667,4.733333,5.233333,5.400000,5.900000,6.400000,6.900000,7.400000,7.900000,8.400000,8.900000,9.400000,9.900000,10.400000,10.900000,11.400000

320x240 1.400000,1.900000,2.400000,2.900000,3.400000,3.900000,4.358333,4.441667,4.525000,4.566667,4.608333,5.108333,5.400000,5.900000,6.400000,6.900000,7.400000,7.900000,8.400000,8.900000,9.400000,9.900000,10.400000,10.900000,11.400000

its ok

for libx264:

ffmpeg -i s-0000.nut -acodec copy -vcodec libx264 -s 640x480 -force_key_frames 0,4,8 -b 2000000 -f mpegts s-0000_1.ts
ffmpeg version 2.1.3 Copyright (c) 2000-2013 the FFmpeg developers

built on May 6 2014 15:10:40 with gcc 4.6 (Ubuntu/Linaro 4.6.3-1ubuntu5)
configuration: --prefix=/usr/local/ffmpeg-2.1.3 --enable-libx264 --enable-gpl --enable-libfaac --enable-pthreads --enable-nonfree --enable-libmp3lame
libavutil 52. 48.101 / 52. 48.101
libavcodec 55. 39.101 / 55. 39.101
libavformat 55. 19.104 / 55. 19.104
libavdevice 55. 5.100 / 55. 5.100
libavfilter 3. 90.100 / 3. 90.100
libswscale 2. 5.101 / 2. 5.101
libswresample 0. 17.104 / 0. 17.104
libpostproc 52. 3.100 / 52. 3.100

Input #0, nut, from 's-0000.nut':

Metadata:

major_brand : isom
minor_version : 512
compatible_brands: isomiso2avc1mp41
encoder : Lavf55.48.100

Duration: 00:00:10.46, start: 0.060113, bitrate: 8250 kb/s

Stream #0:0: Video: h264 (High) (avc1 / 0x31637661), yuv420p(tv, bt709), 1280x544, 24 fps, 24 tbr, 49152 tbn, 48 tbc
Stream #0:1: Audio: aac ([255][0][0][0] / 0x00FF), 44100 Hz, 5.1, fltp

Please use -b:a or -b:v, -b is ambiguous
File 's-0000_1.ts' already exists. Overwrite ? [y/N] y
[libx264 @ 0x27e2f00] using cpu capabilities: MMX2 SSE2Fast SSSE3 FastShuffle SSE4.2 AVX
[libx264 @ 0x27e2f00] profile High, level 3.0
Output #0, mpegts, to 's-0000_1.ts':

Metadata:

major_brand : isom
minor_version : 512
compatible_brands: isomiso2avc1mp41
encoder : Lavf55.19.104
Stream #0:0: Video: h264 (libx264), yuv420p, 640x480, q=-1--1, 2000 kb/s, 90k tbn, 24 tbc
Stream #0:1: Audio: aac ([255][0][0][0] / 0x00FF), 44100 Hz, 5.1

Stream mapping:

Stream #0:0 -> #0:0 (h264 -> libx264)
Stream #0:1 -> #0:1 (copy)

Press [q] to stop, ? for help
[adts @ 0x413c460] Encoder did not produce proper pts, making some up.
frame= 251 fps=111 q=-1.0 Lsize= 4536kB time=00:00:10.37 bitrate=3580.3kbits/s dup=1 drop=0
video:3961kB audio:205kB subtitle:0 global headers:0kB muxing overhead 8.896364%
[libx264 @ 0x27e2f00] frame I:4 Avg QP: 3.57 size: 44682
[libx264 @ 0x27e2f00] frame P:158 Avg QP: 9.58 size: 23786
[libx264 @ 0x27e2f00] frame B:89 Avg QP:11.71 size: 1339
[libx264 @ 0x27e2f00] consecutive B-frames: 42.6% 30.3% 0.0% 27.1%
[libx264 @ 0x27e2f00] mb I I16..4: 38.5% 36.5% 25.0%
[libx264 @ 0x27e2f00] mb P I16..4: 7.7% 17.3% 6.4% P16..4: 28.6% 18.9% 8.6% 0.0% 0.0% skip:12.5%
[libx264 @ 0x27e2f00] mb B I16..4: 0.1% 0.2% 0.0% B16..8: 19.7% 5.4% 0.8% direct: 2.0% skip:71.7% L0:27.1% L1:50.4% BI:22.5%
[libx264 @ 0x27e2f00] final ratefactor: 10.86
[libx264 @ 0x27e2f00] 8x8 transform intra:53.6% inter:64.2%
[libx264 @ 0x27e2f00] coded y,uvDC,uvAC intra: 82.5% 58.6% 52.4% inter: 29.9% 14.3% 3.5%
[libx264 @ 0x27e2f00] i16 v,h,dc,p: 28% 9% 25% 38%
[libx264 @ 0x27e2f00] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 23% 12% 40% 3% 6% 6% 4% 3% 3%
[libx264 @ 0x27e2f00] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 30% 14% 26% 4% 8% 9% 4% 4% 2%
[libx264 @ 0x27e2f00] i8c dc,h,v,p: 79% 9% 10% 2%
[libx264 @ 0x27e2f00] Weighted P-Frames: Y:31.6% UV:0.0%
[libx264 @ 0x27e2f00] ref P L0: 57.3% 20.4% 15.5% 5.7% 1.0%
[libx264 @ 0x27e2f00] ref B L0: 91.9% 8.1%
[libx264 @ 0x27e2f00] kb/s:3102.65

ffmpeg -i s-0000.nut -acodec copy -vcodec libx264 -s 320x240 -force_key_frames 0,4,8 -b 2000000 -f mpegts s-0000_2.ts
ffmpeg version 2.1.3 Copyright (c) 2000-2013 the FFmpeg developers

built on May 6 2014 15:10:40 with gcc 4.6 (Ubuntu/Linaro 4.6.3-1ubuntu5)
configuration: --prefix=/usr/local/ffmpeg-2.1.3 --enable-libx264 --enable-gpl --enable-libfaac --enable-pthreads --enable-nonfree --enable-libmp3lame
libavutil 52. 48.101 / 52. 48.101
libavcodec 55. 39.101 / 55. 39.101
libavformat 55. 19.104 / 55. 19.104
libavdevice 55. 5.100 / 55. 5.100
libavfilter 3. 90.100 / 3. 90.100
libswscale 2. 5.101 / 2. 5.101
libswresample 0. 17.104 / 0. 17.104
libpostproc 52. 3.100 / 52. 3.100

Input #0, nut, from 's-0000.nut':

Metadata:

major_brand : isom
minor_version : 512
compatible_brands: isomiso2avc1mp41
encoder : Lavf55.48.100

Duration: 00:00:10.46, start: 0.060113, bitrate: 8250 kb/s

Stream #0:0: Video: h264 (High) (avc1 / 0x31637661), yuv420p(tv, bt709), 1280x544, 24 fps, 24 tbr, 49152 tbn, 48 tbc
Stream #0:1: Audio: aac ([255][0][0][0] / 0x00FF), 44100 Hz, 5.1, fltp

Please use -b:a or -b:v, -b is ambiguous
File 's-0000_2.ts' already exists. Overwrite ? [y/N] y
[libx264 @ 0x3053f00] using cpu capabilities: MMX2 SSE2Fast SSSE3 FastShuffle SSE4.2 AVX
[libx264 @ 0x3053f00] profile High, level 2.1
Output #0, mpegts, to 's-0000_2.ts':

Metadata:

major_brand : isom
minor_version : 512
compatible_brands: isomiso2avc1mp41
encoder : Lavf55.19.104
Stream #0:0: Video: h264 (libx264), yuv420p, 320x240, q=-1--1, 2000 kb/s, 90k tbn, 24 tbc
Stream #0:1: Audio: aac ([255][0][0][0] / 0x00FF), 44100 Hz, 5.1

Stream mapping:

Stream #0:0 -> #0:0 (h264 -> libx264)
Stream #0:1 -> #0:1 (copy)

Press [q] to stop, ? for help
[adts @ 0x43f0c00] Encoder did not produce proper pts, making some up.
frame= 251 fps=220 q=-1.0 Lsize= 4008kB time=00:00:10.37 bitrate=3163.4kbits/s dup=1 drop=0
video:3470kB audio:205kB subtitle:0 global headers:0kB muxing overhead 9.076326%
[libx264 @ 0x3053f00] frame I:4 Avg QP: 0.01 size: 17256
[libx264 @ 0x3053f00] frame P:147 Avg QP: 1.44 size: 19247
[libx264 @ 0x3053f00] frame B:100 Avg QP: 5.04 size: 6549
[libx264 @ 0x3053f00] consecutive B-frames: 37.1% 26.3% 9.6% 27.1%
[libx264 @ 0x3053f00] mb I I16..4: 40.8% 25.4% 33.8%
[libx264 @ 0x3053f00] mb P I16..4: 10.1% 16.6% 17.0% P16..4: 14.9% 15.6% 13.6% 0.0% 0.0% skip:12.3%
[libx264 @ 0x3053f00] mb B I16..4: 0.4% 1.6% 1.3% B16..8: 14.2% 8.7% 7.8% direct:12.9% skip:53.1% L0:24.0% L1:28.3% BI:47.7%
[libx264 @ 0x3053f00] final ratefactor: 0.81
[libx264 @ 0x3053f00] 8x8 transform intra:37.7% inter:28.2%
[libx264 @ 0x3053f00] coded y,uvDC,uvAC intra: 92.8% 70.0% 69.8% inter: 57.2% 44.8% 43.0%
[libx264 @ 0x3053f00] i16 v,h,dc,p: 27% 12% 14% 46%
[libx264 @ 0x3053f00] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 24% 19% 24% 4% 8% 7% 5% 4% 5%
[libx264 @ 0x3053f00] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 24% 18% 19% 6% 12% 8% 6% 4% 4%
[libx264 @ 0x3053f00] i8c dc,h,v,p: 75% 16% 7% 2%
[libx264 @ 0x3053f00] Weighted P-Frames: Y:38.8% UV:0.7%
[libx264 @ 0x3053f00] ref P L0: 52.1% 30.3% 13.3% 3.5% 0.8%
[libx264 @ 0x3053f00] ref B L0: 94.6% 5.0% 0.4%
[libx264 @ 0x3053f00] ref B L1: 98.1% 1.9%
[libx264 @ 0x3053f00] kb/s:2717.95

Version 0, edited 10 years ago by Andrew (next)

comment:5 by Ridley Combs, 10 years ago

All I see here is libx264 inserting keyframes on its own (in addition to the forced ones), because you haven't explicitly instructed it not to; I don't understand the problem.

in reply to:  5 comment:6 by Andrew, 10 years ago

Replying to 11rcombs:

All I see here is libx264 inserting keyframes on its own (in addition to the forced ones), because you haven't explicitly instructed it not to; I don't understand the problem.

The problem of non-synchronous time stamps

comment:7 by Andrew, 10 years ago

Is it possible to synchronously insert keyframes using ffmpeg and libx264?

Note: See TracTickets for help on using tickets.