summaryrefslogtreecommitdiffstats
path: root/video/decode
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2017-02-07 17:05:17 +0100
committerwm4 <wm4@nowhere>2017-02-07 17:05:17 +0100
commit96a45a16af5594900ca94e7d4abb18d1e6d5ed4a (patch)
treed08473b07adfa7963ce6735c72af1e5d220930a9 /video/decode
parent061b752217d15d41496ca6e4777835fcd945e237 (diff)
downloadmpv-96a45a16af5594900ca94e7d4abb18d1e6d5ed4a.tar.bz2
mpv-96a45a16af5594900ca94e7d4abb18d1e6d5ed4a.tar.xz
player: add experimental stream recording feature
This is basically a WIP, but it can't remain in a branch forever. A warning is print when using it as it's still a bit "shaky".
Diffstat (limited to 'video/decode')
-rw-r--r--video/decode/dec_video.c19
-rw-r--r--video/decode/dec_video.h2
2 files changed, 16 insertions, 5 deletions
diff --git a/video/decode/dec_video.c b/video/decode/dec_video.c
index 273b80c3c9..23aba81709 100644
--- a/video/decode/dec_video.c
+++ b/video/decode/dec_video.c
@@ -33,6 +33,7 @@
#include "demux/packet.h"
#include "common/codecs.h"
+#include "common/recorder.h"
#include "video/out/vo.h"
#include "video/csputils.h"
@@ -259,6 +260,12 @@ static bool send_packet(struct dec_video *d_video, struct demux_packet *packet)
if (pkt_pts == MP_NOPTS_VALUE)
d_video->has_broken_packet_pts = 1;
+ bool dts_replaced = false;
+ if (packet && packet->dts == MP_NOPTS_VALUE && !d_video->codec->avi_dts) {
+ packet->dts = packet->pts;
+ dts_replaced = true;
+ }
+
double pkt_pdts = pkt_pts == MP_NOPTS_VALUE ? pkt_dts : pkt_pts;
if (pkt_pdts != MP_NOPTS_VALUE && d_video->first_packet_pdts == MP_NOPTS_VALUE)
d_video->first_packet_pdts = pkt_pdts;
@@ -269,6 +276,10 @@ static bool send_packet(struct dec_video *d_video, struct demux_packet *packet)
MP_STATS(d_video, "end decode video");
+ // Stream recording can't deal with almost surely wrong fake DTS.
+ if (dts_replaced)
+ packet->dts = MP_NOPTS_VALUE;
+
return res;
}
@@ -396,11 +407,6 @@ void video_work(struct dec_video *d_video)
return;
}
- if (d_video->packet) {
- if (d_video->packet->dts == MP_NOPTS_VALUE && !d_video->codec->avi_dts)
- d_video->packet->dts = d_video->packet->pts;
- }
-
if (d_video->packet && d_video->packet->new_segment) {
assert(!d_video->new_segment);
d_video->new_segment = d_video->packet;
@@ -423,6 +429,9 @@ void video_work(struct dec_video *d_video)
d_video->vd_driver->control(d_video, VDCTRL_SET_FRAMEDROP, &framedrop_type);
if (send_packet(d_video, d_video->packet)) {
+ if (d_video->recorder_sink)
+ mp_recorder_feed_packet(d_video->recorder_sink, d_video->packet);
+
talloc_free(d_video->packet);
d_video->packet = NULL;
}
diff --git a/video/decode/dec_video.h b/video/decode/dec_video.h
index 9155a76155..5ef1f9252a 100644
--- a/video/decode/dec_video.h
+++ b/video/decode/dec_video.h
@@ -42,6 +42,8 @@ struct dec_video {
int dropped_frames;
+ struct mp_recorder_sink *recorder_sink;
+
// Internal (shared with vd_lavc.c).
void *priv; // for free use by vd_driver