0

I'm decoding/encoding the same mp4 (video/mp4) file using ffmpeg (libAV library) + libx264 encoder. For example, the original video file contains 182 frames:

[libx264 @ 0x7fb4a843ce00] frame I:2     Avg QP:17.95  size: 13834
[libx264 @ 0x7fb4a843ce00] frame P:180   Avg QP:19.90  size:  6297

but after the followig decoding/encoding I'm getting file contains 181 frames:

[libx264 @ 0x7fb4ac421dc0] frame I:2     Avg QP:17.93  size: 13627
[libx264 @ 0x7fb4ac421dc0] frame P:179   Avg QP:19.77  size:  5946

I've already tried to change AVCodecContext gop_size/max_b_frames/priv_data (profile, preset, tune, x264opts) and I've also read these posts and tried to solve my problem:

ffpmeg drops last frame when compressing from MP4 to MP4 (libx264)

ffmpeg/libx264 C API: frames dropped from end of short MP4

UPD: If I set framerate and timebase = 26/1 and 1/26 and more - frame doesn't drop.

UPD2: Solved!

//in function avformat_open_input() add AVDictionary *options:
av_dict_set(&options, "r", "25", 0);
av_dict_set(&options, "ignore_editlist", "1", 0);

I expected decoding/encoding videos with all the frames (without changed parameters).

Dzmitry
  • 87
  • 1
  • 1
  • 7
  • 1
    You should post the working solution as Answer, could help future readers. – VC.One Jul 05 '19 at 07:08
  • @VC.One just add this for decoder in function avformat_open_input(): AVDictionary *options: av_dict_set(&options, "r", "25", 0); av_dict_set(&options, "ignore_editlist", "1", 0); – Dzmitry Jul 05 '19 at 09:02

0 Answers0