aboutsummaryrefslogtreecommitdiffstats
path: root/fftools
diff options
context:
space:
mode:
authorAnton Khirnov <anton@khirnov.net>2023-04-14 11:16:02 +0200
committerAnton Khirnov <anton@khirnov.net>2023-04-19 21:12:03 +0200
commitc17e33c0589c64354d6daf2b19f0134329c9407f (patch)
tree3b54a37ab97af06cd46c2df8ba71dfdb029a222a /fftools
parentaf286f17a1c79b6d543c586cf020d08d4e84f0eb (diff)
downloadffmpeg-c17e33c0589c64354d6daf2b19f0134329c9407f.tar.gz
fftools/ffmpeg: propagate frame durations to packets when encoding
Remove now-obsolete code setting packet durations pre-muxing for CFR encoded video. Changes output in the following FATE tests: * numerous adpcm tests * ffmpeg-filter_complex_audio * lavf-asf * lavf-mkv * lavf-mkv_attachment * matroska-encoding-delay All of these change due to the fact that the output duration is now the actual input data duration and does not include padding added by the encoder. * apng-osample: less wrong packet durations are now passed to the muxer. They are not entirely correct, because the first frame duration should be 3 rather than 2. This is caused by the vsync code and should be addressed later, but this change is a step in the right direction. * tscc2-mov: last output frame has a duration of 11 rather than 1 - this corresponds to the duration actually returned by the demuxer. * film-cvid: video frame durations are now 2 rather than 1 - this corresponds to durations actually returned by the demuxer and matches the timestamps. * mpeg2-ticket6677: durations of some video frames are now 2 rather than 1 - this matches the timestamps.
Diffstat (limited to 'fftools')
-rw-r--r--fftools/ffmpeg_enc.c2
-rw-r--r--fftools/ffmpeg_mux.c9
2 files changed, 2 insertions, 9 deletions
diff --git a/fftools/ffmpeg_enc.c b/fftools/ffmpeg_enc.c
index a35c9f60e5..e3dc858bc3 100644
--- a/fftools/ffmpeg_enc.c
+++ b/fftools/ffmpeg_enc.c
@@ -325,6 +325,8 @@ int enc_open(OutputStream *ost, AVFrame *frame)
return ret;
}
+ av_dict_set(&ost->encoder_opts, "flags", "+frame_duration", AV_DICT_MULTIKEY);
+
ret = hw_device_setup_for_encode(ost);
if (ret < 0) {
av_log(ost, AV_LOG_ERROR,
diff --git a/fftools/ffmpeg_mux.c b/fftools/ffmpeg_mux.c
index 7778510d2c..a2e8873ad2 100644
--- a/fftools/ffmpeg_mux.c
+++ b/fftools/ffmpeg_mux.c
@@ -76,15 +76,6 @@ static int write_packet(Muxer *mux, OutputStream *ost, AVPacket *pkt)
if (ost->type == AVMEDIA_TYPE_VIDEO && ost->vsync_method == VSYNC_DROP)
pkt->pts = pkt->dts = AV_NOPTS_VALUE;
- if (ost->type == AVMEDIA_TYPE_VIDEO) {
- if (ost->frame_rate.num && ost->is_cfr) {
- if (pkt->duration > 0)
- av_log(ost, AV_LOG_WARNING, "Overriding packet duration by frame rate, this should not happen\n");
- pkt->duration = av_rescale_q(1, av_inv_q(ost->frame_rate),
- pkt->time_base);
- }
- }
-
av_packet_rescale_ts(pkt, pkt->time_base, ost->st->time_base);
pkt->time_base = ost->st->time_base;