1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2025-11-23 21:54:53 +02:00

fftools/ffmpeg: rework keeping track of file duration for -stream_loop

Current code tracks min/max pts for each stream separately; then when
the file ends it combines them with last frame's duration to compute the
total duration of each stream; finally it selects the longest of those
durations as the file duration.

This is incorrect - the total file duration is the largest timestamp
difference between any frames, regardless of the stream.

Also change the way the last frame information is reported from decoders
to the muxer - previously it would be just the last frame's duration,
now the end timestamp is sent, which is simpler.

Changes the result of the fate-ffmpeg-streamloop-transcode-av test,
where the timestamps are shifted slightly forward. Note that the
matroska demuxer does not return the first audio packet after seeking
(due to buggy interaction betwen the generic code and the demuxer), so
there is a gap in audio.
This commit is contained in:
Anton Khirnov
2023-10-11 17:43:51 +02:00
parent 87016e031f
commit 889a022cce
5 changed files with 141 additions and 167 deletions

View File

@@ -23,9 +23,15 @@
#include "libavutil/common.h"
#include "libavutil/frame.h"
#include "libavutil/rational.h"
#include "libavcodec/packet.h"
typedef struct Timestamp {
int64_t ts;
AVRational tb;
} Timestamp;
/**
* Merge two return codes - return one of the error codes if at least one of
* them was negative, 0 otherwise.