Message ID | 1603709736-2482-1-git-send-email-lance.lmwang@gmail.com |
---|---|
State | Accepted |
Commit | 6f36eb0da71d22aadf8f056f0966bd86656ea57e |
Headers | show |
Series | None | expand |
On Mon, 26 Oct 2020, lance.lmwang@gmail.com wrote: > From: Limin Wang <lance.lmwang@gmail.com> > > now first_pts assume dts will start from zero, if it's not true(copyts is enable), > too many null packet will be inserted for cbr output. > > Please test with below command, you'll get huge test.ts without the patch: > ./ffmpeg -y -copyts -i ../fate-suite/mpegts/loewe.ts -c:v libx264 -x264opts \ > nal-hrd=cbr:force-cfr=1 -b:v 3500k -minrate 3500k -maxrate 3500k -bufsize \ > 1000k -c:a mp2 -muxrate 4500k -vframes 1000 test.ts > > Signed-off-by: Limin Wang <lance.lmwang@gmail.com> > --- > libavformat/mpegtsenc.c | 6 ++++++ > 1 file changed, 6 insertions(+) > > diff --git a/libavformat/mpegtsenc.c b/libavformat/mpegtsenc.c > index 5c97d63..29dcaf6 100644 > --- a/libavformat/mpegtsenc.c > +++ b/libavformat/mpegtsenc.c > @@ -81,6 +81,7 @@ typedef struct MpegTSWrite { > int64_t pat_period; /* PAT/PMT period in PCR time base */ > int nb_services; > int64_t first_pcr; > + int first_dts_checked; > int64_t next_pcr; > int mux_rate; ///< set to 1 when VBR > int pes_payload_size; > @@ -1688,6 +1689,11 @@ static int mpegts_write_packet_internal(AVFormatContext *s, AVPacket *pkt) > stream_id = side_data[0]; > > if (ts->copyts < 1) { > + if (!ts->first_dts_checked && dts != AV_NOPTS_VALUE) { > + ts->first_pcr += dts * 300; > + ts->first_dts_checked = 1; > + } > + LGTM, thanks. Regards, Marton > if (pts != AV_NOPTS_VALUE) > pts += delay; > if (dts != AV_NOPTS_VALUE) > -- > 1.8.3.1 > > _______________________________________________ > ffmpeg-devel mailing list > ffmpeg-devel@ffmpeg.org > https://ffmpeg.org/mailman/listinfo/ffmpeg-devel > > To unsubscribe, visit link above, or email > ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
On Mon, Oct 26, 2020 at 09:13:08PM +0100, Marton Balint wrote: > > > On Mon, 26 Oct 2020, lance.lmwang@gmail.com wrote: > > > From: Limin Wang <lance.lmwang@gmail.com> > > > > now first_pts assume dts will start from zero, if it's not true(copyts is enable), > > too many null packet will be inserted for cbr output. > > > > Please test with below command, you'll get huge test.ts without the patch: > > ./ffmpeg -y -copyts -i ../fate-suite/mpegts/loewe.ts -c:v libx264 -x264opts \ > > nal-hrd=cbr:force-cfr=1 -b:v 3500k -minrate 3500k -maxrate 3500k -bufsize \ > > 1000k -c:a mp2 -muxrate 4500k -vframes 1000 test.ts > > > > Signed-off-by: Limin Wang <lance.lmwang@gmail.com> > > --- > > libavformat/mpegtsenc.c | 6 ++++++ > > 1 file changed, 6 insertions(+) > > > > diff --git a/libavformat/mpegtsenc.c b/libavformat/mpegtsenc.c > > index 5c97d63..29dcaf6 100644 > > --- a/libavformat/mpegtsenc.c > > +++ b/libavformat/mpegtsenc.c > > @@ -81,6 +81,7 @@ typedef struct MpegTSWrite { > > int64_t pat_period; /* PAT/PMT period in PCR time base */ > > int nb_services; > > int64_t first_pcr; > > + int first_dts_checked; > > int64_t next_pcr; > > int mux_rate; ///< set to 1 when VBR > > int pes_payload_size; > > @@ -1688,6 +1689,11 @@ static int mpegts_write_packet_internal(AVFormatContext *s, AVPacket *pkt) > > stream_id = side_data[0]; > > > > if (ts->copyts < 1) { > > + if (!ts->first_dts_checked && dts != AV_NOPTS_VALUE) { > > + ts->first_pcr += dts * 300; > > + ts->first_dts_checked = 1; > > + } > > + > > LGTM, thanks. thanks, will apply the patch#2, patch#3. > > Regards, > Marton > > > if (pts != AV_NOPTS_VALUE) > > pts += delay; > > if (dts != AV_NOPTS_VALUE) > > -- > > 1.8.3.1 > > > > _______________________________________________ > > ffmpeg-devel mailing list > > ffmpeg-devel@ffmpeg.org > > https://ffmpeg.org/mailman/listinfo/ffmpeg-devel > > > > To unsubscribe, visit link above, or email > > ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe". > _______________________________________________ > ffmpeg-devel mailing list > ffmpeg-devel@ffmpeg.org > https://ffmpeg.org/mailman/listinfo/ffmpeg-devel > > To unsubscribe, visit link above, or email > ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
diff --git a/libavformat/mpegtsenc.c b/libavformat/mpegtsenc.c index 5c97d63..29dcaf6 100644 --- a/libavformat/mpegtsenc.c +++ b/libavformat/mpegtsenc.c @@ -81,6 +81,7 @@ typedef struct MpegTSWrite { int64_t pat_period; /* PAT/PMT period in PCR time base */ int nb_services; int64_t first_pcr; + int first_dts_checked; int64_t next_pcr; int mux_rate; ///< set to 1 when VBR int pes_payload_size; @@ -1688,6 +1689,11 @@ static int mpegts_write_packet_internal(AVFormatContext *s, AVPacket *pkt) stream_id = side_data[0]; if (ts->copyts < 1) { + if (!ts->first_dts_checked && dts != AV_NOPTS_VALUE) { + ts->first_pcr += dts * 300; + ts->first_dts_checked = 1; + } + if (pts != AV_NOPTS_VALUE) pts += delay; if (dts != AV_NOPTS_VALUE)