Opened 5 years ago

Closed 4 years ago

#4316 closed defect (invalid)

ffmpeg gives ambigous results with number of frames

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

Description

I have an AVI file containing raw UYVY 4:2:2 video, where I'd like to know the number of frames (and also their PTS).

I get conflicting results when doing stream copying with remuxing, re-encoding, or running ffprobe:

$ ffprobe -select_streams v -show_streams nb-frames.avi
ffprobe version 2.5.4 Copyright (c) 2007-2015 the FFmpeg developers
  built on Feb 16 2015 20:49:00 with Apple LLVM version 6.0 (clang-600.0.56) (based on LLVM 3.5svn)
  configuration: --prefix=/usr/local/Cellar/ffmpeg/2.5.4 --enable-shared --enable-pthreads --enable-gpl --enable-version3 --enable-hardcoded-tables --enable-avresample --cc=clang --host-cflags= --host-ldflags= --enable-libx264 --enable-libmp3lame --enable-libvo-aacenc --enable-libxvid --enable-libfontconfig --enable-libfreetype --enable-libtheora --enable-libvorbis --enable-libvpx --enable-librtmp --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libfaac --enable-libass --enable-ffplay --enable-libssh --enable-libspeex --enable-libschroedinger --enable-libfdk-aac --enable-openssl --enable-libopus --enable-frei0r --enable-libcaca --enable-libsoxr --enable-libquvi --enable-libvidstab --enable-libx265 --enable-libwebp --enable-libopenjpeg --disable-decoder=jpeg2000 --extra-cflags='-I/usr/local/Cellar/openjpeg/1.5.1_1/include/openjpeg-1.5 ' --enable-nonfree --enable-vda
  libavutil      54. 15.100 / 54. 15.100
  libavcodec     56. 13.100 / 56. 13.100
  libavformat    56. 15.102 / 56. 15.102
  libavdevice    56.  3.100 / 56.  3.100
  libavfilter     5.  2.103 /  5.  2.103
  libavresample   2.  1.  0 /  2.  1.  0
  libswscale      3.  1.101 /  3.  1.101
  libswresample   1.  1.100 /  1.  1.100
  libpostproc    53.  3.100 / 53.  3.100
Input #0, avi, from 'nb-frames.avi':
  Metadata:
    encoder         : Lavf55.37.102
  Duration: 00:00:05.21, start: 0.000000, bitrate: 764567 kb/s
    Stream #0:0: Video: rawvideo (UYVY / 0x59565955), uyvy422, 1920x1080, 770576 kb/s, SAR 1:1 DAR 16:9, 24 fps, 24 tbr, 24 tbn, 24 tbc
    Stream #0:1: Audio: mp3 (U[0][0][0] / 0x0055), 44100 Hz, stereo, s16p, 128 kb/s
[STREAM]
index=0
codec_name=rawvideo
codec_long_name=raw video
profile=unknown
codec_type=video
codec_time_base=1/24
codec_tag_string=UYVY
codec_tag=0x59565955
width=1920
height=1080
has_b_frames=0
sample_aspect_ratio=1:1
display_aspect_ratio=16:9
pix_fmt=uyvy422
level=-99
color_range=N/A
color_space=unknown
color_transfer=unknown
color_primaries=unknown
chroma_location=unspecified
timecode=N/A
id=N/A
r_frame_rate=24/1
avg_frame_rate=24/1
time_base=1/24
start_pts=0
start_time=0.000000
duration_ts=125
duration=5.208333
bit_rate=770576516
max_bit_rate=N/A
bits_per_raw_sample=N/A
nb_frames=125
nb_read_frames=N/A
nb_read_packets=N/A
DISPOSITION:default=0
DISPOSITION:dub=0
DISPOSITION:original=0
DISPOSITION:comment=0
DISPOSITION:lyrics=0
DISPOSITION:karaoke=0
DISPOSITION:forced=0
DISPOSITION:hearing_impaired=0
DISPOSITION:visual_impaired=0
DISPOSITION:clean_effects=0
DISPOSITION:attached_pic=0
[/STREAM]

As you can see, the number of frames is indicated as 125. But when I list the frames, I get only 120:

$ ffprobe -select_streams v -show_frames -of compact nb-frames.avi | wc -l
120

When I encode, I get 125 frames, 5 of them duplicated:

$ ffmpeg -i nb-frames.avi -c:v libx264 out.mp4
ffmpeg version 2.5.4 Copyright (c) 2000-2015 the FFmpeg developers
  built on Feb 16 2015 20:49:00 with Apple LLVM version 6.0 (clang-600.0.56) (based on LLVM 3.5svn)
  configuration: --prefix=/usr/local/Cellar/ffmpeg/2.5.4 --enable-shared --enable-pthreads --enable-gpl --enable-version3 --enable-hardcoded-tables --enable-avresample --cc=clang --host-cflags= --host-ldflags= --enable-libx264 --enable-libmp3lame --enable-libvo-aacenc --enable-libxvid --enable-libfontconfig --enable-libfreetype --enable-libtheora --enable-libvorbis --enable-libvpx --enable-librtmp --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libfaac --enable-libass --enable-ffplay --enable-libssh --enable-libspeex --enable-libschroedinger --enable-libfdk-aac --enable-openssl --enable-libopus --enable-frei0r --enable-libcaca --enable-libsoxr --enable-libquvi --enable-libvidstab --enable-libx265 --enable-libwebp --enable-libopenjpeg --disable-decoder=jpeg2000 --extra-cflags='-I/usr/local/Cellar/openjpeg/1.5.1_1/include/openjpeg-1.5 ' --enable-nonfree --enable-vda
  libavutil      54. 15.100 / 54. 15.100
  libavcodec     56. 13.100 / 56. 13.100
  libavformat    56. 15.102 / 56. 15.102
  libavdevice    56.  3.100 / 56.  3.100
  libavfilter     5.  2.103 /  5.  2.103
  libavresample   2.  1.  0 /  2.  1.  0
  libswscale      3.  1.101 /  3.  1.101
  libswresample   1.  1.100 /  1.  1.100
  libpostproc    53.  3.100 / 53.  3.100
Input #0, avi, from 'nb-frames.avi':
  Metadata:
    encoder         : Lavf55.37.102
  Duration: 00:00:05.21, start: 0.000000, bitrate: 764567 kb/s
    Stream #0:0: Video: rawvideo (UYVY / 0x59565955), uyvy422, 1920x1080, 770576 kb/s, SAR 1:1 DAR 16:9, 24 fps, 24 tbr, 24 tbn, 24 tbc
    Stream #0:1: Audio: mp3 (U[0][0][0] / 0x0055), 44100 Hz, stereo, s16p, 128 kb/s
No pixel format specified, yuv422p for H.264 encoding chosen.
Use -pix_fmt yuv420p for compatibility with outdated media players.
[libx264 @ 0x7f9872005c00] using SAR=1/1
[libx264 @ 0x7f9872005c00] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX FMA3 AVX2 LZCNT BMI2
[libx264 @ 0x7f9872005c00] profile High 4:2:2, level 4.0, 4:2:2 8-bit
[libx264 @ 0x7f9872005c00] 264 - core 144 r2525 40bb568 - H.264/MPEG-4 AVC codec - Copyleft 2003-2014 - 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=6 lookahead_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=250 keyint_min=24 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 'out.mp4':
  Metadata:
    encoder         : Lavf56.15.102
    Stream #0:0: Video: h264 (libx264) ([33][0][0][0] / 0x0021), yuv422p, 1920x1080 [SAR 1:1 DAR 16:9], q=-1--1, 24 fps, 12288 tbn, 24 tbc
    Metadata:
      encoder         : Lavc56.13.100 libx264
    Stream #0:1: Audio: aac (libfaac) ([64][0][0][0] / 0x0040), 44100 Hz, stereo, s16, 128 kb/s
    Metadata:
      encoder         : Lavc56.13.100 libfaac
Stream mapping:
  Stream #0:0 -> #0:0 (rawvideo (native) -> h264 (libx264))
  Stream #0:1 -> #0:1 (mp3 (native) -> aac (libfaac))
Press [q] to stop, [?] for help
frame=  125 fps= 14 q=-1.0 Lsize=    2949kB time=00:00:05.20 bitrate=4644.9kbits/s dup=5 drop=0
video:2862kB audio:82kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.165776%
[libx264 @ 0x7f9872005c00] frame I:5     Avg QP:18.69  size: 76030
[libx264 @ 0x7f9872005c00] frame P:81    Avg QP:22.44  size: 27817
[libx264 @ 0x7f9872005c00] frame B:39    Avg QP:24.00  size:  7611
[libx264 @ 0x7f9872005c00] consecutive B-frames: 47.2% 27.2% 19.2%  6.4%
[libx264 @ 0x7f9872005c00] mb I  I16..4: 23.7% 67.4%  8.9%
[libx264 @ 0x7f9872005c00] mb P  I16..4: 10.0% 19.9%  0.5%  P16..4: 36.4%  6.9%  2.2%  0.0%  0.0%    skip:24.2%
[libx264 @ 0x7f9872005c00] mb B  I16..4:  0.5%  1.1%  0.0%  B16..8: 29.2%  2.6%  0.2%  direct: 1.8%  skip:64.5%  L0:51.5% L1:44.6% BI: 4.0%
[libx264 @ 0x7f9872005c00] 8x8 transform intra:66.0% inter:88.7%
[libx264 @ 0x7f9872005c00] coded y,uvDC,uvAC intra: 25.4% 58.7% 11.2% inter: 8.9% 22.4% 1.6%
[libx264 @ 0x7f9872005c00] i16 v,h,dc,p: 20% 39% 11% 30%
[libx264 @ 0x7f9872005c00] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 21% 24% 39%  2%  2%  2%  4%  2%  3%
[libx264 @ 0x7f9872005c00] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 31% 28% 12%  4%  6%  6%  6%  4%  3%
[libx264 @ 0x7f9872005c00] i8c dc,h,v,p: 56% 20% 19%  5%
[libx264 @ 0x7f9872005c00] Weighted P-Frames: Y:13.6% UV:1.2%
[libx264 @ 0x7f9872005c00] ref P L0: 56.9% 11.2% 24.3%  7.3%  0.3%
[libx264 @ 0x7f9872005c00] ref B L0: 88.8% 10.7%  0.5%
[libx264 @ 0x7f9872005c00] ref B L1: 89.7% 10.3%
[libx264 @ 0x7f9872005c00] kb/s:4500.75

The file is on the FTP as nb-frames.avi.

Change History (1)

comment:1 Changed 4 years ago by michael

  • Resolution set to invalid
  • Status changed from new to closed

what do you mean by frames ? if its raw bitmaps thats 120, if you mean how many frames in constant fps output thats 125, AVI supports duplicating the last frame without storing it thats where the difference comes from i suspect.
There does not seem to be a bug, the 120/125 difference for variable vs constant fps is just how it is
if you have an idea on how to improve the documentation or program output to make this clearer ...

Note: See TracTickets for help on using tickets.