Commit ffa28da1 authored by Reimar Döffinger's avatar Reimar Döffinger

Support dropping audio dts/pts via -async -1.

Allows working around issue #605.
Note: as a side effect this fixes that -vsync drop
as far as I could tell would not drop pts/dts values
when duplicating frames or when flushing encoder delay.
Signed-off-by: 's avatarReimar Döffinger <Reimar.Doeffinger@gmx.de>
parent 179a5920
...@@ -999,6 +999,10 @@ static void write_frame(AVFormatContext *s, AVPacket *pkt, OutputStream *ost) ...@@ -999,6 +999,10 @@ static void write_frame(AVFormatContext *s, AVPacket *pkt, OutputStream *ost)
AVCodecContext *avctx = ost->st->codec; AVCodecContext *avctx = ost->st->codec;
int ret; int ret;
if ((avctx->codec_type == AVMEDIA_TYPE_VIDEO && video_sync_method == VSYNC_DROP) ||
(avctx->codec_type == AVMEDIA_TYPE_AUDIO && audio_sync_method < 0))
pkt->pts = pkt->dts = AV_NOPTS_VALUE;
/* /*
* Audio encoders may split the packets -- #frames in != #packets out. * Audio encoders may split the packets -- #frames in != #packets out.
* But there is no reordering, so we can limit the number of output packets * But there is no reordering, so we can limit the number of output packets
...@@ -1227,7 +1231,7 @@ need_realloc: ...@@ -1227,7 +1231,7 @@ need_realloc:
av_assert0(ost->audio_resample || dec->sample_fmt==enc->sample_fmt); av_assert0(ost->audio_resample || dec->sample_fmt==enc->sample_fmt);
if (audio_sync_method) { if (audio_sync_method > 0) {
double delta = get_sync_ipts(ost, ist->pts) * enc->sample_rate - ost->sync_opts - double delta = get_sync_ipts(ost, ist->pts) * enc->sample_rate - ost->sync_opts -
av_fifo_size(ost->fifo) / (enc->channels * osize); av_fifo_size(ost->fifo) / (enc->channels * osize);
int idelta = delta * dec->sample_rate / enc->sample_rate; int idelta = delta * dec->sample_rate / enc->sample_rate;
...@@ -1652,9 +1656,6 @@ static void do_video_out(AVFormatContext *s, OutputStream *ost, ...@@ -1652,9 +1656,6 @@ static void do_video_out(AVFormatContext *s, OutputStream *ost,
av_ts2str(pkt.dts), av_ts2timestr(pkt.dts, &ost->st->time_base)); av_ts2str(pkt.dts), av_ts2timestr(pkt.dts, &ost->st->time_base));
} }
if (format_video_sync == VSYNC_DROP)
pkt.pts = pkt.dts = AV_NOPTS_VALUE;
write_frame(s, &pkt, ost); write_frame(s, &pkt, ost);
frame_size = pkt.size; frame_size = pkt.size;
video_size += pkt.size; video_size += pkt.size;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment