[FFmpeg-devel] [PATCH] Support dropping audio dts/pts via -async -1.

Reimar Döffinger Reimar.Doeffinger at gmx.de
Thu Mar 22 20:18:19 CET 2012


Allows working around issue #605.

Signed-off-by: Reimar Döffinger <Reimar.Doeffinger at gmx.de>
---
 ffmpeg.c |    9 +++++----
 1 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/ffmpeg.c b/ffmpeg.c
index 2a64182..0f6bc30 100644
--- a/ffmpeg.c
+++ b/ffmpeg.c
@@ -999,6 +999,10 @@ static void write_frame(AVFormatContext *s, AVPacket *pkt, OutputStream *ost)
     AVCodecContext          *avctx = ost->st->codec;
     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.
      * But there is no reordering, so we can limit the number of output packets
@@ -1227,7 +1231,7 @@ need_realloc:
 
     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 -
                        av_fifo_size(ost->fifo) / (enc->channels * osize);
         int idelta = delta * dec->sample_rate / enc->sample_rate;
@@ -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));
                 }
 
-                if (format_video_sync == VSYNC_DROP)
-                    pkt.pts = pkt.dts = AV_NOPTS_VALUE;
-
                 write_frame(s, &pkt, ost);
                 frame_size = pkt.size;
                 video_size += pkt.size;
-- 
1.7.9.1



More information about the ffmpeg-devel mailing list