[FFmpeg-devel] [PATCH] libavformat: fix inputs initialization in mpegts muxer with filters
This patch solves the initialization of the inputs when using filters (a graph filter) with the mpegts muxer. This bug seems to be generated by a simple forgetting to copy. The same code is repeated two times, but only in one case the variable “inputs_done” is initialized. Compare the two blocks: - Correct: https://github.com/FFmpeg/FFmpeg/blob/a0559fcd81f42f446c93357a943699f9d44eeb79/fftools/ffmpeg.c#L4627 - Incorrect: https://github.com/FFmpeg/FFmpeg/blob/a0559fcd81f42f446c93357a943699f9d44eeb79/fftools/ffmpeg.c#L4616 In addition, the patch includes a more detailed version of two LOG lines. These lines include useful information to detect this error. And they can help to discover other related errors (specifically related to the “cur_dts is invalid” bug that often appears in some user logs). Regards. A.H.From af81338c21c67c0ef2c30ab2009c7094b32327f4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20H=C3=A5kon?= Date: Wed, 17 Apr 2019 21:22:43 +0100 Subject: [PATCH] libavformat: input init fix mpegts filters --- fftools/ffmpeg.c|8 ++-- libavformat/utils.c |4 ++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c index 0f157d6..b74a209 100644 --- a/fftools/ffmpeg.c +++ b/fftools/ffmpeg.c @@ -3875,7 +3875,9 @@ static OutputStream *choose_output(void) av_rescale_q(ost->st->cur_dts, ost->st->time_base, AV_TIME_BASE_Q); if (ost->st->cur_dts == AV_NOPTS_VALUE) -av_log(NULL, AV_LOG_DEBUG, "cur_dts is invalid (this is harmless if it occurs once at the start per stream)\n"); +av_log(NULL, AV_LOG_DEBUG, +"cur_dts is invalid st:%d (%d) [init:%d i_done:%d finish:%d] (this is harmless if it occurs once at the start per stream)\n", +ost->st->index, ost->st->id, ost->initialized, ost->inputs_done, ost->finished); if (!ost->initialized && !ost->inputs_done) return ost; @@ -4613,8 +4615,10 @@ static int transcode_step(void) } if ((ret = transcode_from_filter(ost->filter->graph, &ist)) < 0) return ret; -if (!ist) +if (!ist) { +ost->inputs_done = 1; return 0; +} } else if (ost->filter) { int i; for (i = 0; i < ost->filter->graph->nb_inputs; i++) { diff --git a/libavformat/utils.c b/libavformat/utils.c index 9b3f0d2..6ef9423 100644 --- a/libavformat/utils.c +++ b/libavformat/utils.c @@ -1402,8 +1402,8 @@ static void compute_pkt_fields(AVFormatContext *s, AVStream *st, st->cur_dts = pkt->dts; if (s->debug & FF_FDEBUG_TS) -av_log(s, AV_LOG_DEBUG, "OUTdelayed:%d/%d pts:%s, dts:%s cur_dts:%s\n", -presentation_delayed, delay, av_ts2str(pkt->pts), av_ts2str(pkt->dts), av_ts2str(st->cur_dts)); +av_log(s, AV_LOG_DEBUG, "OUTdelayed:%d/%d pts:%s, dts:%s cur_dts:%s st:%d (%d)\n", +presentation_delayed, delay, av_ts2str(pkt->pts), av_ts2str(pkt->dts), av_ts2str(st->cur_dts), st->index, st->id); /* update flags */ if (st->codecpar->codec_type == AVMEDIA_TYPE_DATA || is_intra_only(st->codecpar->codec_id)) -- 1.7.10.4 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH] libavformat: fix inputs initialization in mpegts muxer with filters
Hi Carl, > > Please split the patch. > > Carl Eugen > OK. Here the relevant part regargind the bug fix. I'll send another new with the log enhancement. Regards. A.H. From af81338c21c67c0ef2c30ab2009c7094b32327f4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20H=C3=A5kon?= Date: Wed, 17 Apr 2019 21:22:43 +0100 Subject: [PATCH] libavformat: input init fix mpegts filters --- fftools/ffmpeg.c|8 ++-- libavformat/utils.c |4 ++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c index 0f157d6..b74a209 100644 --- a/fftools/ffmpeg.c +++ b/fftools/ffmpeg.c @@ -4613,9 +4613,10 @@ static int transcode_step(void) } if ((ret = transcode_from_filter(ost->filter->graph, &ist)) < 0) return ret; -if (!ist) +if (!ist) { +ost->inputs_done = 1; return 0; +} } else if (ost->filter) { int i; for (i = 0; i < ost->filter->graph->nb_inputs; i++) { -- 1.7.10.4 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH] libavformat: improve logs with cur_dts
Hi, This is the second part of my previous patch: https://patchwork.ffmpeg.org/patch/12783/ It improves the logs when the message "cur_dts is invalid" appears. If helps to identify which stream generates the trouble, and the status of the stream. A lot of users suffers with the message, and the origin varies. The improved message can help to discover the cause. Regards. A.H.From af81338c21c67c0ef2c30ab2009c7094b32327f4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20H=C3=A5kon?= Date: Wed, 17 Apr 2019 21:22:43 +0100 Subject: [PATCH] libavformat: input init fix mpegts filters --- fftools/ffmpeg.c|8 ++-- libavformat/utils.c |4 ++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c index 0f157d6..b74a209 100644 --- a/fftools/ffmpeg.c +++ b/fftools/ffmpeg.c @@ -3875,7 +3875,9 @@ static OutputStream *choose_output(void) av_rescale_q(ost->st->cur_dts, ost->st->time_base, AV_TIME_BASE_Q); if (ost->st->cur_dts == AV_NOPTS_VALUE) -av_log(NULL, AV_LOG_DEBUG, "cur_dts is invalid (this is harmless if it occurs once at the start per stream)\n"); +av_log(NULL, AV_LOG_DEBUG, +"cur_dts is invalid st:%d (%d) [init:%d i_done:%d finish:%d] (this is harmless if it occurs once at the start per stream)\n", +ost->st->index, ost->st->id, ost->initialized, ost->inputs_done, ost->finished); if (!ost->initialized && !ost->inputs_done) return ost; diff --git a/libavformat/utils.c b/libavformat/utils.c index 9b3f0d2..6ef9423 100644 --- a/libavformat/utils.c +++ b/libavformat/utils.c @@ -1402,9 +1402,8 @@ static void compute_pkt_fields(AVFormatContext *s, AVStream *st, st->cur_dts = pkt->dts; if (s->debug & FF_FDEBUG_TS) -av_log(s, AV_LOG_DEBUG, "OUTdelayed:%d/%d pts:%s, dts:%s cur_dts:%s\n", -presentation_delayed, delay, av_ts2str(pkt->pts), av_ts2str(pkt->dts), av_ts2str(st->cur_dts)); +av_log(s, AV_LOG_DEBUG, "OUTdelayed:%d/%d pts:%s, dts:%s cur_dts:%s st:%d (%d)\n", +presentation_delayed, delay, av_ts2str(pkt->pts), av_ts2str(pkt->dts), av_ts2str(st->cur_dts), st->index, st->id); /* update flags */ if (st->codecpar->codec_type == AVMEDIA_TYPE_DATA || is_intra_only(st->codecpar->codec_id)) -- 1.7.10.4 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH] libavformat: fix inputs initialization in mpegts muxer with filters
> Hi Carl, > > > Please split the patch. > > Carl Eugen > > OK. Here the relevant part regargind the bug fix. > I'll send another new with the log enhancement. > > Regards. > A.H. > This supersedes my previous PATCH: https://patchwork.ffmpeg.org/patch/12783/ So, please, mark it as superseded. Regards. A.H. Note: The second part is that: https://patchwork.ffmpeg.org/patch/12791/ Only as reference. . ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH] libavformat: fix copyts and muxrate in mpegts muxer
Hi, This patch resolves one very specific use case: - When you use the mpegts muxer; - And use the global parameter “-copyts”; - And use the parameter “-muxrate” for the mpegts muxer; - And use too the parameter “-mpegts_copyts”. The problem is created because the member “first_pcr” of the MpegTSWrite struct isn’t initialized with a correct timestamp (so when copying the timestamps the initial value is 0). And in this case an infinite loop is created because the code never writes PES packets when the “mux_rate” isn’t VBR (equals to 1). See the block that creates the loop here (note the "continue" command at end): https://github.com/FFmpeg/FFmpeg/blob/a0559fcd81f42f446c93357a943699f9d44eeb79/libavformat/mpegtsenc.c#L1211 So, this patch fixes the problem initializing the “first_pcr” with the first DTS value that comes when using the incoming timestamps. Regards. A.H. ---From 225f3de248625c588b2e8bb169cdff28705db8f5 Mon Sep 17 00:00:00 2001 From: Andreas Hakon Date: Thu, 18 Apr 2019 09:53:30 +0100 Subject: [PATCH] libavformat: fix copyts with muxrate --- libavformat/mpegtsenc.c | 10 +- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/libavformat/mpegtsenc.c b/libavformat/mpegtsenc.c index fc0ea22..7e94326 100644 --- a/libavformat/mpegtsenc.c +++ b/libavformat/mpegtsenc.c @@ -971,6 +971,9 @@ static int mpegts_init(AVFormatContext *s) if (ts->copyts < 1) ts->first_pcr = av_rescale(s->max_delay, PCR_TIME_BASE, AV_TIME_BASE); +else +ts->first_pcr = AV_NOPTS_VALUE; + } else { /* Arbitrary values, PAT/PMT will also be written on video key frames */ ts->sdt_packet_period = 200; @@ -1186,12 +1189,16 @@ static void mpegts_write_pes(AVFormatContext *s, AVStream *st, int64_t pcr = -1; /* avoid warning */ int64_t delay = av_rescale(s->max_delay, 9, AV_TIME_BASE); int force_pat = st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO && key && !ts_st->prev_payload_key; +int last_payload_size = 0; av_assert0(ts_st->payload != buf || st->codecpar->codec_type != AVMEDIA_TYPE_VIDEO); if (ts->flags & MPEGTS_FLAG_PAT_PMT_AT_FRAMES && st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) { force_pat = 1; } +if (ts->mux_rate > 1 && dts != AV_NOPTS_VALUE && ts->first_pcr == AV_NOPTS_VALUE) +ts->first_pcr = (dts - 1) * 300; + is_start = 1; while (payload_size > 0) { retransmit_si_info(s, force_pat, dts); @@ -1209,12 +1216,13 @@ static void mpegts_write_pes(AVFormatContext *s, AVStream *st, } if (ts->mux_rate > 1 && dts != AV_NOPTS_VALUE && -(dts - get_pcr(ts, s->pb) / 300) > delay) { +last_payload_size != payload_size && (dts - get_pcr(ts, s->pb) / 300) > delay) { /* pcr insert gets priority over null packet insert */ if (write_pcr) mpegts_insert_pcr_only(s, st); else mpegts_insert_null_packet(s); +last_payload_size = payload_size; /* recalculate write_pcr and possibly retransmit si_info */ continue; } -- 1.7.10.4 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH] libavcodec: QSV protect GPB code with CO3 define
Hi, In response to this ticket I provide the first part of the patch: https://trac.ffmpeg.org/ticket/7839 This QSV_HAVE_GPB code needs to be protected by QSV_HAVE_CO3. Regards. A.H. ---From d43c81f5bba49e55ea867bd6afd2eef878dc0ad3 Mon Sep 17 00:00:00 2001 From: Andreas Hakon Date: Thu, 18 Apr 2019 10:40:38 +0100 Subject: [PATCH] libavcodec: qsv protect gpb with co3 --- libavcodec/qsvenc.c |2 ++ 1 file changed, 2 insertions(+) diff --git a/libavcodec/qsvenc.c b/libavcodec/qsvenc.c index a03ab69..9583d62 100644 --- a/libavcodec/qsvenc.c +++ b/libavcodec/qsvenc.c @@ -267,10 +267,12 @@ static void dump_video_param(AVCodecContext *avctx, QSVEncContext *q, #endif #endif +#if QSV_HAVE_CO3 #if QSV_HAVE_GPB if (avctx->codec_id == AV_CODEC_ID_HEVC) av_log(avctx, AV_LOG_VERBOSE,"GPB: %s\n", print_threestate(co3->GPB)); #endif +#endif if (avctx->codec_id == AV_CODEC_ID_H264) { av_log(avctx, AV_LOG_VERBOSE, "Entropy coding: %s; MaxDecFrameBuffering: %"PRIu16"\n", -- 1.7.10.4 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH] libavformat: fix inputs initialization in mpegts muxer with filters
> On Wed, Apr 17, 2019 at 08:28:39PM +0000, Andreas Håkon via ffmpeg-devel > wrote: > > > This patch solves the initialization of the inputs when using filters (a > > graph filter) with the mpegts muxer. > > This bug seems to be generated by a simple forgetting to copy. The same > > code is repeated two times, but only in one case the variable “inputs_done” > > is initialized. Compare the two blocks: > > This text should be in the commit message. > also a testcase would be usefull, a fate test even better > Done! Regards. A.H. --- From af81338c21c67c0ef2c30ab2009c7094b32327f4 Mon Sep 17 00:00:00 2001 From: Andreas Hakon Date: Wed, 17 Apr 2019 21:22:43 +0100 Subject: [PATCH] libavformat: input init fix mpegts filters This patch solves the initialization of the inputs when using filters (a graph filter) with the mpegts muxer. This bug seems to be generated by a simple forgetting to copy. The same code is repeated two times, but only in one case the variable inputs_done is initialized. Testcase: $ ffmpeg -f mpegts -i mpeg.ts \ -filter_complex "[i:100]fps=fps=25[out]" \ -map "[out]" -c:v libx264 -f mpegts out.ts Signed-off-by: Andreas Hakon --- fftools/ffmpeg.c|8 ++-- libavformat/utils.c |4 ++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c index 0f157d6..b74a209 100644 --- a/fftools/ffmpeg.c +++ b/fftools/ffmpeg.c @@ -4613,9 +4613,10 @@ static int transcode_step(void) } if ((ret = transcode_from_filter(ost->filter->graph, &ist)) < 0) return ret; -if (!ist) +if (!ist) { +ost->inputs_done = 1; return 0; +} } else if (ost->filter) { int i; for (i = 0; i < ost->filter->graph->nb_inputs; i++) { -- 1.7.10.4 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH] libavformat: fix inputs initialization in mpegts muxer with filters
‐‐‐ Original Message ‐‐‐ On Thursday, 18 de April de 2019 13:14, Andreas Håkon wrote: > > On Wed, Apr 17, 2019 at 08:28:39PM +, Andreas Håkon via ffmpeg-devel > > wrote: > > > > > This patch solves the initialization of the inputs when using filters (a > > > graph filter) with the mpegts muxer. > > > This bug seems to be generated by a simple forgetting to copy. The same > > > code is repeated two times, but only in one case the variable > > > “inputs_done” is initialized. Compare the two blocks: > > > > This text should be in the commit message. > > also a testcase would be usefull, a fate test even better > > Done! > > Regards. > A.H. > Hi Michael, Your request is now here: https://patchwork.ffmpeg.org/patch/12794/ Mark as superseded both: https://patchwork.ffmpeg.org/patch/12783/ https://patchwork.ffmpeg.org/patch/12790/ And please review the second part: https://patchwork.ffmpeg.org/patch/12791/ Regards. A.H. --- ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH] libavformat: improve logs with cur_dts
‐‐‐ Original Message ‐‐‐ On Thursday, 18 de April de 2019 22:13, Michael Niedermayer wrote: > On Thu, Apr 18, 2019 at 07:46:43AM +0000, Andreas Håkon via ffmpeg-devel > wrote: > > > Hi, > > This is the second part of my previous patch: > > https://patchwork.ffmpeg.org/patch/12783/ > > It improves the logs when the message "cur_dts is invalid" appears. > > If helps to identify which stream generates the trouble, > > and the status of the stream. > > A lot of users suffers with the message, and the origin varies. > > The improved message can help to discover the cause. > > Regards. > > A.H. > > > "git am" doesnt accept this patch > > Applying: libavformat: input init fix mpegts filters > Using index info to reconstruct a base tree... > error: patch failed: libavformat/utils.c:1402 > error: libavformat/utils.c: patch does not apply > error: Did you hand edit your patch? > It does not apply to blobs recorded in its index. > Patch failed at 0001 libavformat: input init fix mpegts filters > hint: Use 'git am --show-current-patch' to see the failed patch > When you have resolved this problem, run "git am --continue". > If you prefer to skip this patch, run "git am --skip" instead. > To restore the original branch and stop patching, run "git am --abort". > Sorry Michael! I re-created the patch with a clean copy. Here it is. Regards. A.H. --- From 88dd030ddcde04b425bf1896ea6c1a2f263dc2ac Mon Sep 17 00:00:00 2001 From: Andreas Hakon Date: Fri, 19 Apr 2019 08:58:37 +0100 Subject: [PATCH] libavformat: improve logs with cur_dts v2 This patch improves the logs when the message "cur_dts is invalid" appears. If helps to identify which stream generates the trouble, and the status of the stream. A lot of users suffers with the message, and the origin varies. The improved message can help to discover the cause. Signed-off-by: Andreas Hakon --- fftools/ffmpeg.c|4 +++- libavformat/utils.c |4 ++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c index 0f157d6..01f0410 100644 --- a/fftools/ffmpeg.c +++ b/fftools/ffmpeg.c @@ -3875,7 +3875,9 @@ static OutputStream *choose_output(void) av_rescale_q(ost->st->cur_dts, ost->st->time_base, AV_TIME_BASE_Q); if (ost->st->cur_dts == AV_NOPTS_VALUE) -av_log(NULL, AV_LOG_DEBUG, "cur_dts is invalid (this is harmless if it occurs once at the start per stream)\n"); +av_log(NULL, AV_LOG_DEBUG, +"cur_dts is invalid st:%d (%d) [init:%d i_done:%d finish:%d] (this is harmless if it occurs once at the start per stream)\n", +ost->st->index, ost->st->id, ost->initialized, ost->inputs_done, ost->finished); if (!ost->initialized && !ost->inputs_done) return ost; diff --git a/libavformat/utils.c b/libavformat/utils.c index 9b3f0d2..6ef9423 100644 --- a/libavformat/utils.c +++ b/libavformat/utils.c @@ -1402,8 +1402,8 @@ static void compute_pkt_fields(AVFormatContext *s, AVStream *st, st->cur_dts = pkt->dts; if (s->debug & FF_FDEBUG_TS) -av_log(s, AV_LOG_DEBUG, "OUTdelayed:%d/%d pts:%s, dts:%s cur_dts:%s\n", -presentation_delayed, delay, av_ts2str(pkt->pts), av_ts2str(pkt->dts), av_ts2str(st->cur_dts)); +av_log(s, AV_LOG_DEBUG, "OUTdelayed:%d/%d pts:%s, dts:%s cur_dts:%s st:%d (%d)\n", +presentation_delayed, delay, av_ts2str(pkt->pts), av_ts2str(pkt->dts), av_ts2str(st->cur_dts), st->index, st->id); /* update flags */ if (st->codecpar->codec_type == AVMEDIA_TYPE_DATA || is_intra_only(st->codecpar->codec_id)) -- 1.7.10.4 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH] libavformat: fix inputs initialization in mpegts muxer with filters
‐‐‐ Original Message ‐‐‐ On Thursday, 18 de April de 2019 22:07, Michael Niedermayer wrote: > > fails to apply cleanly > > Applying: libavformat: fix inputs initialization in mpegts muxer with filters > Using index info to reconstruct a base tree... > error: patch failed: fftools/ffmpeg.c:4613 > error: fftools/ffmpeg.c: patch does not apply > error: Did you hand edit your patch? > It does not apply to blobs recorded in its index. > Patch failed at 0001 libavformat: fix inputs initialization in mpegts muxer > with filters > Sorry Michael another time! Here a new version from a clean copy. Regards. A.H. --- From 936740731c17a9757aa093bdb35d9772df1e64a8 Mon Sep 17 00:00:00 2001 From: Andreas Hakon Date: Fri, 19 Apr 2019 09:17:32 +0100 Subject: [PATCH] libavformat: input init mpegts with filters v2 This patch solves the initialization of the inputs when using filters (a graph filter) with the mpegts muxer. This bug seems to be generated by a simple forgetting to copy. The same code is repeated two times, but only in one case the variable inputs_done is initialized. Testcase: $ ffmpeg -f mpegts -i mpeg.ts \ -filter_complex "[i:100]fps=fps=25[out]" \ -map "[out]" -c:v libx264 -f mpegts out.ts Signed-off-by: Andreas Hakon --- fftools/ffmpeg.c |4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c index 0f157d6..7399a19 100644 --- a/fftools/ffmpeg.c +++ b/fftools/ffmpeg.c @@ -4613,8 +4613,10 @@ static int transcode_step(void) } if ((ret = transcode_from_filter(ost->filter->graph, &ist)) < 0) return ret; -if (!ist) +if (!ist) { +ost->inputs_done = 1; return 0; +} } else if (ost->filter) { int i; for (i = 0; i < ost->filter->graph->nb_inputs; i++) { -- 1.7.10.4 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH] libavformat: fix copyts and muxrate in mpegts muxer
‐‐‐ Original Message ‐‐‐ On Thursday, 18 de April de 2019 11:01, Andreas Håkon via ffmpeg-devel wrote: > Hi, > > This patch resolves one very specific use case: > > - When you use the mpegts muxer; > - And use the global parameter “-copyts”; > - And use the parameter “-muxrate” for the mpegts muxer; > - And use too the parameter “-mpegts_copyts”. > > The problem is created because the member “first_pcr” of the MpegTSWrite > struct isn’t initialized with a correct timestamp (so when copying the > timestamps the initial value is 0). And in this case an infinite loop is > created because the code never writes PES packets when the “mux_rate” isn’t > VBR (equals to 1). See the block that creates the loop here (note the > "continue" command at end): > > https://github.com/FFmpeg/FFmpeg/blob/a0559fcd81f42f446c93357a943699f9d44eeb79/libavformat/mpegtsenc.c#L1211 > > So, this patch fixes the problem initializing the “first_pcr” with the > first DTS value that comes when using the incoming timestamps. > > Regards. > A.H. > Hi, Here a new version of the patch. The "fist_pcr" value is now derived from DTS in a more consistent way. Regards, A.H. --- From c59569ca9426fef455edabfa648cb2ff678c1640 Mon Sep 17 00:00:00 2001 From: Andreas Hakon Date: Fri, 19 Apr 2019 09:32:33 +0100 Subject: [PATCH] libavformat: fix copyts and muxrate in mpegts muxer v2 When using "-copyts" and "-muxrate" with the mpegts muxer the muxing fails because the member "first_pcr" of the MpegTSWrite struct isn't initialized with a correct timestamp. The behaviour of the error is an infinite loop created in the function mpegts_write_pes() because the code never writes PES packets. This patch resolves the problem initializing the "first_pcr" with a value derived from the first DTS value seen. Signed-off-by: Andreas Hakon --- libavformat/mpegtsenc.c | 10 +- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/libavformat/mpegtsenc.c b/libavformat/mpegtsenc.c index fc0ea22..858b0d7 100644 --- a/libavformat/mpegtsenc.c +++ b/libavformat/mpegtsenc.c @@ -971,6 +971,9 @@ static int mpegts_init(AVFormatContext *s) if (ts->copyts < 1) ts->first_pcr = av_rescale(s->max_delay, PCR_TIME_BASE, AV_TIME_BASE); +else +ts->first_pcr = AV_NOPTS_VALUE; + } else { /* Arbitrary values, PAT/PMT will also be written on video key frames */ ts->sdt_packet_period = 200; @@ -1186,12 +1189,16 @@ static void mpegts_write_pes(AVFormatContext *s, AVStream *st, int64_t pcr = -1; /* avoid warning */ int64_t delay = av_rescale(s->max_delay, 9, AV_TIME_BASE); int force_pat = st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO && key && !ts_st->prev_payload_key; +int last_payload_size = 0; av_assert0(ts_st->payload != buf || st->codecpar->codec_type != AVMEDIA_TYPE_VIDEO); if (ts->flags & MPEGTS_FLAG_PAT_PMT_AT_FRAMES && st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) { force_pat = 1; } +if (ts->mux_rate > 1 && dts != AV_NOPTS_VALUE && ts->first_pcr == AV_NOPTS_VALUE) +ts->first_pcr = (dts * 300) - av_rescale(s->max_delay, PCR_TIME_BASE, AV_TIME_BASE); + is_start = 1; while (payload_size > 0) { retransmit_si_info(s, force_pat, dts); @@ -1209,12 +1216,13 @@ static void mpegts_write_pes(AVFormatContext *s, AVStream *st, } if (ts->mux_rate > 1 && dts != AV_NOPTS_VALUE && -(dts - get_pcr(ts, s->pb) / 300) > delay) { +last_payload_size != payload_size && (dts - get_pcr(ts, s->pb) / 300) > delay) { /* pcr insert gets priority over null packet insert */ if (write_pcr) mpegts_insert_pcr_only(s, st); else mpegts_insert_null_packet(s); +last_payload_size = payload_size; /* recalculate write_pcr and possibly retransmit si_info */ continue; } -- 1.7.10.4 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".