summaryrefslogtreecommitdiffstats
path: root/common
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2019-07-10 21:34:01 +0200
committerwm4 <wm4@nowhere>2019-09-19 20:37:05 +0200
commitf7678575a5d7f598abf267cb303e0a74db276f27 (patch)
tree3d152efc7353fb840e021c92ab8279464181d180 /common
parent9d97c4d814bc63b456513c9a0e8c0ee4fd47a2c5 (diff)
downloadmpv-f7678575a5d7f598abf267cb303e0a74db276f27.tar.bz2
mpv-f7678575a5d7f598abf267cb303e0a74db276f27.tar.xz
recorder: always mux all packets on discont/close
This is the muxer used by all 3 stream recording features (why are there so many?). It tried hard to avoid writing broken files. In particular, it buffered packets until it new there was a keyframe packet (which, in mpv's/FFmpeg's definition, mean seek points from which decoding can resume), or final EOF. The danger that was probably considered here was that due to video frame reordering, not muxing some trailing, missing packets of a keyframe range could lead to broken decoding or skipped frames, so better discard packets belonging to an incomplete range. Sounds like a good idea so far. Unfortunately, this will drop an entire keyframe range even if the current packet run is complete and mp_recorder_mark_discontinuity() is called, simply because recorder.c can not know that the next packet would have been a keyframe. It seems better to mux all packets to avoid losing valid data, even if it means that sometimes packets/frames will be missing from the file. It benefits especially the dump-cache command, which will call the function to signal a discontinuity after every range. Before this commit, it discarded the last packets, even if they were perfectly fine. (An alternative solution for dump-cache would have been a second discontinuity marker function, that communicates that the current packet range is complete. But this commit's solution is simpler and overall more robust, at the danger of producing more semi-broken files.) This may make some of the complex buffering/waiting logic in recorder.c pointless. Untested (in this final form).
Diffstat (limited to 'common')
-rw-r--r--common/recorder.c3
1 files changed, 1 insertions, 2 deletions
diff --git a/common/recorder.c b/common/recorder.c
index 213caab6cb..ad9c34e24c 100644
--- a/common/recorder.c
+++ b/common/recorder.c
@@ -293,8 +293,6 @@ void mp_recorder_destroy(struct mp_recorder *priv)
if (priv->opened) {
for (int n = 0; n < priv->num_streams; n++) {
struct mp_recorder_sink *rst = priv->streams[n];
- if (!rst->proper_eof)
- continue;
mux_packets(rst, true);
}
@@ -320,6 +318,7 @@ void mp_recorder_mark_discontinuity(struct mp_recorder *priv)
for (int n = 0; n < priv->num_streams; n++) {
struct mp_recorder_sink *rst = priv->streams[n];
+ mux_packets(rst, true);
rst->discont = true;
rst->proper_eof = false;
}