* [FFmpeg-devel] [PATCH] avformat/mpegtsenc: add pcr_at_keyframe flag
@ 2022-09-27 20:37 Zhao Zhili
2022-09-28 19:42 ` Marton Balint
0 siblings, 1 reply; 5+ messages in thread
From: Zhao Zhili @ 2022-09-27 20:37 UTC (permalink / raw)
To: ffmpeg-devel; +Cc: Zhao Zhili
From: Zhao Zhili <zhilizhao@tencent.com>
Add PCR at keyframe can be undesirable when -pcr_period is
specified. Add an flag to disable this behavior.
Signed-off-by: Zhao Zhili <zhilizhao@tencent.com>
---
doc/muxers.texi | 2 ++
libavformat/mpegtsenc.c | 8 ++++++--
2 files changed, 8 insertions(+), 2 deletions(-)
diff --git a/doc/muxers.texi b/doc/muxers.texi
index b2f4326aae..0f576d8096 100644
--- a/doc/muxers.texi
+++ b/doc/muxers.texi
@@ -1915,6 +1915,8 @@ Conform to System B (DVB) instead of System A (ATSC).
Mark the initial packet of each stream as discontinuity.
@item nit
Emit NIT table.
+@item pcr_at_keyframe
+Write PCR at key frame.
@end table
@item mpegts_copyts @var{boolean}
diff --git a/libavformat/mpegtsenc.c b/libavformat/mpegtsenc.c
index 5148a6aecd..808d2c04a2 100644
--- a/libavformat/mpegtsenc.c
+++ b/libavformat/mpegtsenc.c
@@ -112,6 +112,7 @@ typedef struct MpegTSWrite {
#define MPEGTS_FLAG_SYSTEM_B 0x08
#define MPEGTS_FLAG_DISCONT 0x10
#define MPEGTS_FLAG_NIT 0x20
+#define MPEGTS_FLAG_PCR_AT_KEYFRAME 0x40
int flags;
int copyts;
int tables_version;
@@ -1566,7 +1567,8 @@ static void mpegts_write_pes(AVFormatContext *s, AVStream *st,
q = get_ts_payload_start(buf);
ts_st->discontinuity = 0;
}
- if (key && is_start && pts != AV_NOPTS_VALUE &&
+ if ((ts->flags & MPEGTS_FLAG_PCR_AT_KEYFRAME) &&
+ key && is_start && pts != AV_NOPTS_VALUE &&
!is_dvb_teletext /* adaptation+payload forbidden for teletext (ETSI EN 300 472 V1.3.1 4.1) */) {
// set Random Access for key frames
if (ts_st->pcr_period)
@@ -2269,7 +2271,7 @@ static const AVOption options[] = {
{ "muxrate", NULL, OFFSET(mux_rate), AV_OPT_TYPE_INT, { .i64 = 1 }, 0, INT_MAX, ENC },
{ "pes_payload_size", "Minimum PES packet payload in bytes",
OFFSET(pes_payload_size), AV_OPT_TYPE_INT, { .i64 = DEFAULT_PES_PAYLOAD_SIZE }, 0, INT_MAX, ENC },
- { "mpegts_flags", "MPEG-TS muxing flags", OFFSET(flags), AV_OPT_TYPE_FLAGS, { .i64 = 0 }, 0, INT_MAX, ENC, "mpegts_flags" },
+ { "mpegts_flags", "MPEG-TS muxing flags", OFFSET(flags), AV_OPT_TYPE_FLAGS, { .i64 = MPEGTS_FLAG_PCR_AT_KEYFRAME }, 0, INT_MAX, ENC, "mpegts_flags" },
{ "resend_headers", "Reemit PAT/PMT before writing the next packet",
0, AV_OPT_TYPE_CONST, { .i64 = MPEGTS_FLAG_REEMIT_PAT_PMT }, 0, INT_MAX, ENC, "mpegts_flags" },
{ "latm", "Use LATM packetization for AAC",
@@ -2282,6 +2284,8 @@ static const AVOption options[] = {
0, AV_OPT_TYPE_CONST, { .i64 = MPEGTS_FLAG_DISCONT }, 0, INT_MAX, ENC, "mpegts_flags" },
{ "nit", "Enable NIT transmission",
0, AV_OPT_TYPE_CONST, { .i64 = MPEGTS_FLAG_NIT}, 0, INT_MAX, ENC, "mpegts_flags" },
+ { "pcr_at_keyframe", "Write PCR at key frame",
+ 0, AV_OPT_TYPE_CONST, { .i64 = MPEGTS_FLAG_PCR_AT_KEYFRAME }, 0, INT_MAX, ENC, "mpegts_flags" },
{ "mpegts_copyts", "don't offset dts/pts", OFFSET(copyts), AV_OPT_TYPE_BOOL, { .i64 = -1 }, -1, 1, ENC },
{ "tables_version", "set PAT, PMT, SDT and NIT version", OFFSET(tables_version), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 31, ENC },
{ "omit_video_pes_length", "Omit the PES packet length for video packets",
--
2.25.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".
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [FFmpeg-devel] [PATCH] avformat/mpegtsenc: add pcr_at_keyframe flag
2022-09-27 20:37 [FFmpeg-devel] [PATCH] avformat/mpegtsenc: add pcr_at_keyframe flag Zhao Zhili
@ 2022-09-28 19:42 ` Marton Balint
2022-09-29 18:00 ` [FFmpeg-devel] [PATCH v2] avformat/mpegtsenc: add omit_rai flag Zhao Zhili
0 siblings, 1 reply; 5+ messages in thread
From: Marton Balint @ 2022-09-28 19:42 UTC (permalink / raw)
To: FFmpeg development discussions and patches
On Wed, 28 Sep 2022, Zhao Zhili wrote:
> From: Zhao Zhili <zhilizhao@tencent.com>
>
> Add PCR at keyframe can be undesirable when -pcr_period is
> specified. Add an flag to disable this behavior.
Actually you are disabling the writing of random access indicators, not
only PCRs. PCR's are just there because it is mandatory when RAI is set
for PCR pids. In the help text you can mention that it affects writing of
PCR as well, but in principle you disable RAI, so the option name should
reflect that instead. Also I kind of prefer not to change the default of
mpegts_flags from zero, use a negative option instead, like "omit_rai".
Thanks,
Marton
>
> Signed-off-by: Zhao Zhili <zhilizhao@tencent.com>
> ---
> doc/muxers.texi | 2 ++
> libavformat/mpegtsenc.c | 8 ++++++--
> 2 files changed, 8 insertions(+), 2 deletions(-)
>
> diff --git a/doc/muxers.texi b/doc/muxers.texi
> index b2f4326aae..0f576d8096 100644
> --- a/doc/muxers.texi
> +++ b/doc/muxers.texi
> @@ -1915,6 +1915,8 @@ Conform to System B (DVB) instead of System A (ATSC).
> Mark the initial packet of each stream as discontinuity.
> @item nit
> Emit NIT table.
> +@item pcr_at_keyframe
> +Write PCR at key frame.
> @end table
>
> @item mpegts_copyts @var{boolean}
> diff --git a/libavformat/mpegtsenc.c b/libavformat/mpegtsenc.c
> index 5148a6aecd..808d2c04a2 100644
> --- a/libavformat/mpegtsenc.c
> +++ b/libavformat/mpegtsenc.c
> @@ -112,6 +112,7 @@ typedef struct MpegTSWrite {
> #define MPEGTS_FLAG_SYSTEM_B 0x08
> #define MPEGTS_FLAG_DISCONT 0x10
> #define MPEGTS_FLAG_NIT 0x20
> +#define MPEGTS_FLAG_PCR_AT_KEYFRAME 0x40
> int flags;
> int copyts;
> int tables_version;
> @@ -1566,7 +1567,8 @@ static void mpegts_write_pes(AVFormatContext *s, AVStream *st,
> q = get_ts_payload_start(buf);
> ts_st->discontinuity = 0;
> }
> - if (key && is_start && pts != AV_NOPTS_VALUE &&
> + if ((ts->flags & MPEGTS_FLAG_PCR_AT_KEYFRAME) &&
> + key && is_start && pts != AV_NOPTS_VALUE &&
> !is_dvb_teletext /* adaptation+payload forbidden for teletext (ETSI EN 300 472 V1.3.1 4.1) */) {
> // set Random Access for key frames
> if (ts_st->pcr_period)
> @@ -2269,7 +2271,7 @@ static const AVOption options[] = {
> { "muxrate", NULL, OFFSET(mux_rate), AV_OPT_TYPE_INT, { .i64 = 1 }, 0, INT_MAX, ENC },
> { "pes_payload_size", "Minimum PES packet payload in bytes",
> OFFSET(pes_payload_size), AV_OPT_TYPE_INT, { .i64 = DEFAULT_PES_PAYLOAD_SIZE }, 0, INT_MAX, ENC },
> - { "mpegts_flags", "MPEG-TS muxing flags", OFFSET(flags), AV_OPT_TYPE_FLAGS, { .i64 = 0 }, 0, INT_MAX, ENC, "mpegts_flags" },
> + { "mpegts_flags", "MPEG-TS muxing flags", OFFSET(flags), AV_OPT_TYPE_FLAGS, { .i64 = MPEGTS_FLAG_PCR_AT_KEYFRAME }, 0, INT_MAX, ENC, "mpegts_flags" },
> { "resend_headers", "Reemit PAT/PMT before writing the next packet",
> 0, AV_OPT_TYPE_CONST, { .i64 = MPEGTS_FLAG_REEMIT_PAT_PMT }, 0, INT_MAX, ENC, "mpegts_flags" },
> { "latm", "Use LATM packetization for AAC",
> @@ -2282,6 +2284,8 @@ static const AVOption options[] = {
> 0, AV_OPT_TYPE_CONST, { .i64 = MPEGTS_FLAG_DISCONT }, 0, INT_MAX, ENC, "mpegts_flags" },
> { "nit", "Enable NIT transmission",
> 0, AV_OPT_TYPE_CONST, { .i64 = MPEGTS_FLAG_NIT}, 0, INT_MAX, ENC, "mpegts_flags" },
> + { "pcr_at_keyframe", "Write PCR at key frame",
> + 0, AV_OPT_TYPE_CONST, { .i64 = MPEGTS_FLAG_PCR_AT_KEYFRAME }, 0, INT_MAX, ENC, "mpegts_flags" },
> { "mpegts_copyts", "don't offset dts/pts", OFFSET(copyts), AV_OPT_TYPE_BOOL, { .i64 = -1 }, -1, 1, ENC },
> { "tables_version", "set PAT, PMT, SDT and NIT version", OFFSET(tables_version), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 31, ENC },
> { "omit_video_pes_length", "Omit the PES packet length for video packets",
> --
> 2.25.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".
^ permalink raw reply [flat|nested] 5+ messages in thread
* [FFmpeg-devel] [PATCH v2] avformat/mpegtsenc: add omit_rai flag
2022-09-28 19:42 ` Marton Balint
@ 2022-09-29 18:00 ` Zhao Zhili
2022-10-02 19:16 ` Marton Balint
0 siblings, 1 reply; 5+ messages in thread
From: Zhao Zhili @ 2022-09-29 18:00 UTC (permalink / raw)
To: ffmpeg-devel; +Cc: Zhao Zhili
From: Zhao Zhili <zhilizhao@tencent.com>
Add PCR at keyframe can be undesirable when -pcr_period is
specified. Add an flag to disable this behavior.
Signed-off-by: Zhao Zhili <zhilizhao@tencent.com>
---
v2: change pcr_at_keyframe to omit_rai
doc/muxers.texi | 2 ++
libavformat/mpegtsenc.c | 6 +++++-
2 files changed, 7 insertions(+), 1 deletion(-)
diff --git a/doc/muxers.texi b/doc/muxers.texi
index b2f4326aae..4edbb22b00 100644
--- a/doc/muxers.texi
+++ b/doc/muxers.texi
@@ -1915,6 +1915,8 @@ Conform to System B (DVB) instead of System A (ATSC).
Mark the initial packet of each stream as discontinuity.
@item nit
Emit NIT table.
+@item omit_rai
+Disable writing of random access indicator.
@end table
@item mpegts_copyts @var{boolean}
diff --git a/libavformat/mpegtsenc.c b/libavformat/mpegtsenc.c
index 5148a6aecd..48d39e6a7d 100644
--- a/libavformat/mpegtsenc.c
+++ b/libavformat/mpegtsenc.c
@@ -112,6 +112,7 @@ typedef struct MpegTSWrite {
#define MPEGTS_FLAG_SYSTEM_B 0x08
#define MPEGTS_FLAG_DISCONT 0x10
#define MPEGTS_FLAG_NIT 0x20
+#define MPEGTS_FLAG_OMIT_RAI 0x40
int flags;
int copyts;
int tables_version;
@@ -1566,7 +1567,8 @@ static void mpegts_write_pes(AVFormatContext *s, AVStream *st,
q = get_ts_payload_start(buf);
ts_st->discontinuity = 0;
}
- if (key && is_start && pts != AV_NOPTS_VALUE &&
+ if (!(ts->flags & MPEGTS_FLAG_OMIT_RAI) &&
+ key && is_start && pts != AV_NOPTS_VALUE &&
!is_dvb_teletext /* adaptation+payload forbidden for teletext (ETSI EN 300 472 V1.3.1 4.1) */) {
// set Random Access for key frames
if (ts_st->pcr_period)
@@ -2282,6 +2284,8 @@ static const AVOption options[] = {
0, AV_OPT_TYPE_CONST, { .i64 = MPEGTS_FLAG_DISCONT }, 0, INT_MAX, ENC, "mpegts_flags" },
{ "nit", "Enable NIT transmission",
0, AV_OPT_TYPE_CONST, { .i64 = MPEGTS_FLAG_NIT}, 0, INT_MAX, ENC, "mpegts_flags" },
+ { "omit_rai", "Disable writing of random access indicator",
+ 0, AV_OPT_TYPE_CONST, { .i64 = MPEGTS_FLAG_OMIT_RAI }, 0, INT_MAX, ENC, "mpegts_flags" },
{ "mpegts_copyts", "don't offset dts/pts", OFFSET(copyts), AV_OPT_TYPE_BOOL, { .i64 = -1 }, -1, 1, ENC },
{ "tables_version", "set PAT, PMT, SDT and NIT version", OFFSET(tables_version), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 31, ENC },
{ "omit_video_pes_length", "Omit the PES packet length for video packets",
--
2.25.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".
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [FFmpeg-devel] [PATCH v2] avformat/mpegtsenc: add omit_rai flag
2022-09-29 18:00 ` [FFmpeg-devel] [PATCH v2] avformat/mpegtsenc: add omit_rai flag Zhao Zhili
@ 2022-10-02 19:16 ` Marton Balint
2022-10-08 16:39 ` Zhao Zhili
0 siblings, 1 reply; 5+ messages in thread
From: Marton Balint @ 2022-10-02 19:16 UTC (permalink / raw)
To: FFmpeg development discussions and patches
On Fri, 30 Sep 2022, Zhao Zhili wrote:
> From: Zhao Zhili <zhilizhao@tencent.com>
>
> Add PCR at keyframe can be undesirable when -pcr_period is
> specified. Add an flag to disable this behavior.
>
> Signed-off-by: Zhao Zhili <zhilizhao@tencent.com>
> ---
> v2: change pcr_at_keyframe to omit_rai
LGTM with libavformat micro version bump, thanks.
Marton
>
> doc/muxers.texi | 2 ++
> libavformat/mpegtsenc.c | 6 +++++-
> 2 files changed, 7 insertions(+), 1 deletion(-)
>
> diff --git a/doc/muxers.texi b/doc/muxers.texi
> index b2f4326aae..4edbb22b00 100644
> --- a/doc/muxers.texi
> +++ b/doc/muxers.texi
> @@ -1915,6 +1915,8 @@ Conform to System B (DVB) instead of System A (ATSC).
> Mark the initial packet of each stream as discontinuity.
> @item nit
> Emit NIT table.
> +@item omit_rai
> +Disable writing of random access indicator.
> @end table
>
> @item mpegts_copyts @var{boolean}
> diff --git a/libavformat/mpegtsenc.c b/libavformat/mpegtsenc.c
> index 5148a6aecd..48d39e6a7d 100644
> --- a/libavformat/mpegtsenc.c
> +++ b/libavformat/mpegtsenc.c
> @@ -112,6 +112,7 @@ typedef struct MpegTSWrite {
> #define MPEGTS_FLAG_SYSTEM_B 0x08
> #define MPEGTS_FLAG_DISCONT 0x10
> #define MPEGTS_FLAG_NIT 0x20
> +#define MPEGTS_FLAG_OMIT_RAI 0x40
> int flags;
> int copyts;
> int tables_version;
> @@ -1566,7 +1567,8 @@ static void mpegts_write_pes(AVFormatContext *s, AVStream *st,
> q = get_ts_payload_start(buf);
> ts_st->discontinuity = 0;
> }
> - if (key && is_start && pts != AV_NOPTS_VALUE &&
> + if (!(ts->flags & MPEGTS_FLAG_OMIT_RAI) &&
> + key && is_start && pts != AV_NOPTS_VALUE &&
> !is_dvb_teletext /* adaptation+payload forbidden for teletext (ETSI EN 300 472 V1.3.1 4.1) */) {
> // set Random Access for key frames
> if (ts_st->pcr_period)
> @@ -2282,6 +2284,8 @@ static const AVOption options[] = {
> 0, AV_OPT_TYPE_CONST, { .i64 = MPEGTS_FLAG_DISCONT }, 0, INT_MAX, ENC, "mpegts_flags" },
> { "nit", "Enable NIT transmission",
> 0, AV_OPT_TYPE_CONST, { .i64 = MPEGTS_FLAG_NIT}, 0, INT_MAX, ENC, "mpegts_flags" },
> + { "omit_rai", "Disable writing of random access indicator",
> + 0, AV_OPT_TYPE_CONST, { .i64 = MPEGTS_FLAG_OMIT_RAI }, 0, INT_MAX, ENC, "mpegts_flags" },
> { "mpegts_copyts", "don't offset dts/pts", OFFSET(copyts), AV_OPT_TYPE_BOOL, { .i64 = -1 }, -1, 1, ENC },
> { "tables_version", "set PAT, PMT, SDT and NIT version", OFFSET(tables_version), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 31, ENC },
> { "omit_video_pes_length", "Omit the PES packet length for video packets",
> --
> 2.25.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".
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [FFmpeg-devel] [PATCH v2] avformat/mpegtsenc: add omit_rai flag
2022-10-02 19:16 ` Marton Balint
@ 2022-10-08 16:39 ` Zhao Zhili
0 siblings, 0 replies; 5+ messages in thread
From: Zhao Zhili @ 2022-10-08 16:39 UTC (permalink / raw)
To: ffmpeg-devel
On Sun, 2022-10-02 at 21:16 +0200, Marton Balint wrote:
>
> On Fri, 30 Sep 2022, Zhao Zhili wrote:
>
> > From: Zhao Zhili <zhilizhao@tencent.com>
> >
> > Add PCR at keyframe can be undesirable when -pcr_period is
> > specified. Add an flag to disable this behavior.
> >
> > Signed-off-by: Zhao Zhili <zhilizhao@tencent.com>
> > ---
> > v2: change pcr_at_keyframe to omit_rai
>
> LGTM with libavformat micro version bump, thanks.
Pushed with micro version bump, thanks for review.
_______________________________________________
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".
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2022-10-08 16:39 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-09-27 20:37 [FFmpeg-devel] [PATCH] avformat/mpegtsenc: add pcr_at_keyframe flag Zhao Zhili
2022-09-28 19:42 ` Marton Balint
2022-09-29 18:00 ` [FFmpeg-devel] [PATCH v2] avformat/mpegtsenc: add omit_rai flag Zhao Zhili
2022-10-02 19:16 ` Marton Balint
2022-10-08 16:39 ` Zhao Zhili
Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
This inbox may be cloned and mirrored by anyone:
git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git
# If you have public-inbox 1.1+ installed, you may
# initialize and index your mirror using the following commands:
public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \
ffmpegdev@gitmailbox.com
public-inbox-index ffmpegdev
Example config snippet for mirrors.
AGPL code for this site: git clone https://public-inbox.org/public-inbox.git