[FFmpeg-user] Non-keyframes included in cut video displaying unpredictably?

Ted Park kumowoon1025 at gmail.com
Tue Apr 30 21:29:37 EEST 2019


Hi, I split a video file by timestamp on a non-keyframe, and I notice inconsistent behavior on playback.

The frames required to decode the “first” frame that are included in the resulting file display inconsistently, depending on the framework the player is based upon.

Here is a sample file: https://storage.googleapis.com/media.kumowoon1025.com/sample.mov <https://storage.googleapis.com/media.kumowoon1025.com/sample.mov>

The beginning of the video is different when you compare ffplay, compared to something based on apple’s AVFoundation (Quicktime, Safari, etc)

ffprobe output is puzzling also. When I read the first 22 frames (or try to, at least), this is the result.

Teds-rMBP:~ kumowoon1025$ ffprobe "$FILE" -select_streams v -show_frames -read_intervals %+#22
ffprobe version git-2019-04-28-ea80af659 Copyright (c) 2007-2019 the FFmpeg developers
  built with Apple LLVM version 10.0.1 (clang-1001.0.46.4)
  configuration: --prefix=/usr/local/Cellar/ffmpeg/HEAD-ea80af6_1 --enable-gpl --enable-version3 --enable-nonfree --enable-libass --enable-libtesseract --enable-libx264 --enable-libx265 --enable-shared --enable-lto --disable-stripping
  libavutil      56. 26.100 / 56. 26.100
  libavcodec     58. 52.100 / 58. 52.100
  libavformat    58. 27.103 / 58. 27.103
  libavdevice    58.  7.100 / 58.  7.100
  libavfilter     7. 50.100 /  7. 50.100
  libswscale      5.  4.100 /  5.  4.100
  libswresample   3.  4.100 /  3.  4.100
  libpostproc    55.  4.100 / 55.  4.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '/Volumes/Network Storage/TV Shows/That Time I Got Reincarnated as a Slime/02 Meeting the Goblins_CON.mov':
  Metadata:
    major_brand     : qt  
    minor_version   : 512
    compatible_brands: qt  
    encoder         : Lavf58.26.101
  Duration: 00:20:36.07, start: 0.000000, bitrate: 5018 kb/s
    Stream #0:0(eng): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 1920x1080 [SAR 1:1 DAR 16:9], 4882 kb/s, 23.98 fps, 23.98 tbr, 90k tbn, 47.95 tbc (default)
    Metadata:
      handler_name    : VideoHandler
    Stream #0:1(eng): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 128 kb/s (default)
    Metadata:
      handler_name    : SoundHandler


When I increase it to 23 frames, only then do I start getting frame info.

Teds-rMBP:~ kumowoon1025$ ffprobe "$FILE" -select_streams v -show_frames -read_intervals %+#23
ffprobe version git-2019-04-28-ea80af659 Copyright (c) 2007-2019 the FFmpeg developers
  built with Apple LLVM version 10.0.1 (clang-1001.0.46.4)
  configuration: --prefix=/usr/local/Cellar/ffmpeg/HEAD-ea80af6_1 --enable-gpl --enable-version3 --enable-nonfree --enable-libass --enable-libtesseract --enable-libx264 --enable-libx265 --enable-shared --enable-lto --disable-stripping
  libavutil      56. 26.100 / 56. 26.100
  libavcodec     58. 52.100 / 58. 52.100
  libavformat    58. 27.103 / 58. 27.103
  libavdevice    58.  7.100 / 58.  7.100
  libavfilter     7. 50.100 /  7. 50.100
  libswscale      5.  4.100 /  5.  4.100
  libswresample   3.  4.100 /  3.  4.100
  libpostproc    55.  4.100 / 55.  4.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '/Volumes/Network Storage/TV Shows/That Time I Got Reincarnated as a Slime/02 Meeting the Goblins_CON.mov':
  Metadata:
    major_brand     : qt  
    minor_version   : 512
    compatible_brands: qt  
    encoder         : Lavf58.26.101
  Duration: 00:20:36.07, start: 0.000000, bitrate: 5018 kb/s
    Stream #0:0(eng): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 1920x1080 [SAR 1:1 DAR 16:9], 4882 kb/s, 23.98 fps, 23.98 tbr, 90k tbn, 47.95 tbc (default)
    Metadata:
      handler_name    : VideoHandler
    Stream #0:1(eng): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 128 kb/s (default)
    Metadata:
      handler_name    : SoundHandler
[FRAME]
media_type=video
stream_index=0
key_frame=0
pkt_pts=3754
pkt_pts_time=0.041711
pkt_dts=N/A
pkt_dts_time=N/A
best_effort_timestamp=3754
best_effort_timestamp_time=0.041711
pkt_duration=3753
pkt_duration_time=0.041700
pkt_pos=489447
pkt_size=347021
width=1920
height=1080
pix_fmt=yuv420p
sample_aspect_ratio=1:1
pict_type=P
coded_picture_number=22
display_picture_number=0
interlaced_frame=0
top_field_first=0
repeat_pict=0
color_range=unknown
color_space=unknown
color_primaries=unknown
color_transfer=unknown
chroma_location=left
[/FRAME]



Also, from the stream metadata, the start_pts is 0, but I don’t think that’s relevant.

Teds-rMBP:~ kumowoon1025$ ffprobe "$FILE" -select_streams v -show_streams
ffprobe version git-2019-04-28-ea80af659 Copyright (c) 2007-2019 the FFmpeg developers
  built with Apple LLVM version 10.0.1 (clang-1001.0.46.4)
  configuration: --prefix=/usr/local/Cellar/ffmpeg/HEAD-ea80af6_1 --enable-gpl --enable-version3 --enable-nonfree --enable-libass --enable-libtesseract --enable-libx264 --enable-libx265 --enable-shared --enable-lto --disable-stripping
  libavutil      56. 26.100 / 56. 26.100
  libavcodec     58. 52.100 / 58. 52.100
  libavformat    58. 27.103 / 58. 27.103
  libavdevice    58.  7.100 / 58.  7.100
  libavfilter     7. 50.100 /  7. 50.100
  libswscale      5.  4.100 /  5.  4.100
  libswresample   3.  4.100 /  3.  4.100
  libpostproc    55.  4.100 / 55.  4.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '/Volumes/Network Storage/TV Shows/That Time I Got Reincarnated as a Slime/02 Meeting the Goblins_CON.mov':
  Metadata:
    major_brand     : qt  
    minor_version   : 512
    compatible_brands: qt  
    encoder         : Lavf58.26.101
  Duration: 00:20:36.07, start: 0.000000, bitrate: 5018 kb/s
    Stream #0:0(eng): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 1920x1080 [SAR 1:1 DAR 16:9], 4882 kb/s, 23.98 fps, 23.98 tbr, 90k tbn, 47.95 tbc (default)
    Metadata:
      handler_name    : VideoHandler
    Stream #0:1(eng): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 128 kb/s (default)
    Metadata:
      handler_name    : SoundHandler
[STREAM]
index=0
codec_name=h264
codec_long_name=H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10
profile=High
codec_type=video
codec_time_base=6180347/296360000
codec_tag_string=avc1
codec_tag=0x31637661
width=1920
height=1080
coded_width=1920
coded_height=1088
has_b_frames=2
sample_aspect_ratio=1:1
display_aspect_ratio=16:9
pix_fmt=yuv420p
level=40
color_range=unknown
color_space=unknown
color_transfer=unknown
color_primaries=unknown
chroma_location=left
field_order=unknown
timecode=N/A
refs=1
is_avc=true
nal_length_size=4
id=N/A
r_frame_rate=24000/1001
avg_frame_rate=148180000/6180347
time_base=1/90000
start_pts=0
start_time=0.000000
duration_ts=111162870
duration=1235.143000
bit_rate=4882975
max_bit_rate=N/A
bits_per_raw_sample=8
nb_frames=29636
nb_read_frames=N/A
nb_read_packets=N/A
DISPOSITION:default=1
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
DISPOSITION:timed_thumbnails=0
TAG:language=eng
TAG:handler_name=VideoHandler
[/STREAM]



Is this just a difference in implementation? If so, are they both correct?


More information about the ffmpeg-user mailing list