From 96a45a16af5594900ca94e7d4abb18d1e6d5ed4a Mon Sep 17 00:00:00 2001 From: wm4 Date: Tue, 7 Feb 2017 17:05:17 +0100 Subject: 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". --- video/decode/dec_video.c | 19 ++++++++++++++----- video/decode/dec_video.h | 2 ++ 2 files changed, 16 insertions(+), 5 deletions(-) (limited to 'video/decode') 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 -- cgit v1.2.3