1

I have videos which missing initial keyframe. Thus when I open the video file with VLC player, nothing happens on the screen until the first key frame.

Example picture: https://i.stack.imgur.com/nBYrR.png (I cannot add image on question because i need at least 10 reputation points.)

Usually, it encounters the first key frame within the first 10 seconds and the video starts playing. Then I can rewind and watch the first 10 seconds too.

With ffprobe, I examined the location and time between key frames.

ffprobe -loglevel error -skip_frame nokey -select_streams v:0 -show_entries frame=pkt_pts_time -of csv=print_section=0 5-1601984964095.ts

3610.187967
3620.185489
3630.193133
3640.187944
3650.185311
3660.182822
3670.188500
3680.184133
3690.185078
3700.182911
3710.183367
3720.182778
3730.184022
3740.184567
3750.182689
3760.185767
3770.184700
3780.190100
3790.189033
3800.184422
3810.195578
3820.184767
3830.189644
3840.191533
3850.200800
3860.189211
3870.186956
3880.182989
3890.187878
3900.180167
3910.179522
3920.181411
3930.182022
3940.186422
3950.185778
3960.189856
3970.192444
3980.182833
3990.182367
4000.181000
4010.184000
4020.183622
4030.184178
4040.186367
4050.180144
4060.177833
4070.194067
4080.197444
4090.197700
4100.178944
4110.185444
4120.180544
4130.186956
4140.184967
4150.188178
4160.202444
4170.193300

I can solve this problem by adding keyframe to the beginning of the videos (during encoding). But the solution I need is to solve this problem without making any changes to the videos.

My question is How can I fix this problem? I must watch this video from very beginning! Is there a setting in Vlc player to play video up to the first key frame? I tampered with all the settings of VLC but could not find anything usefull.

EDİT: The result of the ffprobe -show_streams 5-1601984964095.tscommand as requested by @gyan .

>ffprobe -show_streams 5-1601984964095.ts
ffprobe version N-99830-g112fe0ff19 Copyright (c) 2007-2020 the FFmpeg developers
  built with gcc 9.3-win32 (GCC) 20200320
  configuration: --prefix=/ffbuild/prefix --pkg-config-flags=--static --pkg-config=pkg-config --cross-prefix=x86_64-w64-mingw32- --arch=x86_64 --target-os=mingw32 --enable-gpl --enable-version3 --disable-debug --enable-iconv --enable-zlib --enable-libxml2 --enable-libfreetype --enable-libfribidi --enable-gmp --enable-lzma --enable-fontconfig --enable-opencl --enable-libvmaf --disable-vulkan --enable-libvorbis --enable-amf --enable-libaom --enable-avisynth --enable-libdav1d --enable-libdavs2 --enable-ffnvcodec --enable-cuda-llvm --disable-libglslang --enable-libass --enable-libbluray --enable-libmp3lame --enable-libopus --enable-libtheora --enable-libvpx --enable-libwebp --enable-libmfx --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-librav1e --enable-librubberband --enable-schannel --enable-sdl2 --enable-libsoxr --enable-libsrt --enable-libsvtav1 --enable-libtwolame --enable-libuavs3d --enable-libvidstab --enable-libx264 --enable-libx265 --enable-libxavs2 --enable-libxvid --enable-libzimg --extra-cflags=-DLIBTWOLAME_STATIC --extra-cxxflags= --extra-ldflags=-pthread --extra-libs=-lgomp
  libavutil      56. 60.100 / 56. 60.100
  libavcodec     58.112.101 / 58.112.101
  libavformat    58. 64.100 / 58. 64.100
  libavdevice    58. 11.102 / 58. 11.102
  libavfilter     7. 88.100 /  7. 88.100
  libswscale      5.  8.100 /  5.  8.100
  libswresample   3.  8.100 /  3.  8.100
  libpostproc    55.  8.100 / 55.  8.100
Input #0, mpegts, from '5-1601984964095.ts':
  Duration: 00:09:28.41, start: 3610.187967, bitrate: 1656 kb/s
  Program 1
    Stream #0:0[0x41]: Video: h264 (High 4:2:2) (HDMV / 0x564D4448), yuv422p(tv, bt470bg/smpte170m/bt709, progressive), 720x576 [SAR 1:1 DAR 5:4], 25 fps, 25 tbr, 90k tbn, 50 tbc
[STREAM]
index=0
codec_name=h264
codec_long_name=H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10
profile=High 4:2:2
codec_type=video
codec_time_base=1/50
codec_tag_string=HDMV
codec_tag=0x564d4448
width=720
height=576
coded_width=720
coded_height=576
closed_captions=0
has_b_frames=2
sample_aspect_ratio=1:1
display_aspect_ratio=5:4
pix_fmt=yuv422p
level=30
color_range=tv
color_space=bt470bg
color_transfer=bt709
color_primaries=smpte170m
chroma_location=left
field_order=progressive
timecode=N/A
refs=1
is_avc=false
nal_length_size=0
id=0x41
r_frame_rate=25/1
avg_frame_rate=25/1
time_base=1/90000
start_pts=324916917
start_time=3610.187967
duration_ts=51156594
duration=568.406600
bit_rate=N/A
max_bit_rate=N/A
bits_per_raw_sample=8
nb_frames=N/A
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
DISPOSITION:timed_thumbnails=0
[/STREAM]
3
  • Share full output of ffprobe -show_streams 5-1601984964095.ts and how does ffplay handle the file?
    – Gyan
    Nov 8, 2020 at 16:50
  • Thanks for comment. I will be able to access the video files tomorrow. I will write the result here when I apply the relevant command. Nov 8, 2020 at 17:57
  • @gyan I shared the full output in edit section of question as requested. Thank you for helping. Nov 9, 2020 at 8:06

1 Answer 1

0

If you've lost a key picture, then usually the prediction will be broken, meaning other pictures cannot be decoded and the player will skip them.

There are several ways to handle this, depending on your requirements.

  • If you have the original video, then include the latest key picture before you require playback to start.
  • If you have the original video but the above is not acceptable, then you would need to re-encode the video in order to position the key frame at the start of the bit stream.
  • If you don't have the original and the key picture is really lost unrecoverably, then you cannot play the pictures which are predicted from it - essential information required to decode them is gone.
  • You can trim the bit stream up to the next key frame; this will not start playback any earlier but should avoid the black (unplayable) time at the start.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .