mirror of https://github.com/mpv-player/mpv
demux_lavf: set PTS of first packet for formats with no timestamps
Makes time display work for some raw audio formats (*.shn).
This commit is contained in:
parent
5b69b76609
commit
9479daa13e
|
@ -101,6 +101,7 @@ typedef struct lavf_priv {
|
|||
AVFormatContext *avfc;
|
||||
AVIOContext *pb;
|
||||
int64_t last_pts;
|
||||
bool init_pts;
|
||||
struct sh_stream **streams; // NULL for unknown streams
|
||||
int num_streams;
|
||||
int cur_program;
|
||||
|
@ -832,6 +833,12 @@ static int demux_lavf_fill_buffer(demuxer_t *demux)
|
|||
return 1;
|
||||
}
|
||||
|
||||
if (!priv->init_pts && (priv->avfc->flags & AVFMT_NOTIMESTAMPS)) {
|
||||
if (pkt->pts == AV_NOPTS_VALUE && pkt->dts == AV_NOPTS_VALUE)
|
||||
pkt->dts = 0;
|
||||
priv->init_pts = true;
|
||||
}
|
||||
|
||||
if (pkt->pts != AV_NOPTS_VALUE)
|
||||
dp->pts = pkt->pts * av_q2d(st->time_base);
|
||||
if (pkt->dts != AV_NOPTS_VALUE)
|
||||
|
@ -856,6 +863,8 @@ static void demux_seek_lavf(demuxer_t *demuxer, double rel_seek_secs, int flags)
|
|||
lavf_priv_t *priv = demuxer->priv;
|
||||
int avsflags = 0;
|
||||
|
||||
priv->init_pts = false;
|
||||
|
||||
if (flags & SEEK_ABSOLUTE)
|
||||
priv->last_pts = 0;
|
||||
else if (rel_seek_secs < 0)
|
||||
|
|
Loading…
Reference in New Issue