Re: [FFmpeg-devel] [PATCH] avformat/mpegtsenc: correct bitstream check

2024-03-16 Thread Gyan Doshi



On 2024-03-16 02:02 pm, Marton Balint wrote:



On Sat, 16 Mar 2024, Gyan Doshi wrote:


8559cce3c3 made the bitstream check generic using a LUT.
However, one of the comparisons which involves a bitwise AND
and equality check is faulty due to operator precedence.

First reported and analysed at
https://github.com/streamlink/streamlink/issues/5876

Fixes #10908
---
libavformat/mpegtsenc.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavformat/mpegtsenc.c b/libavformat/mpegtsenc.c
index 06e88e9879..b8efc535a7 100644
--- a/libavformat/mpegtsenc.c
+++ b/libavformat/mpegtsenc.c
@@ -2319,7 +2319,7 @@ static int 
mpegts_check_bitstream(AVFormatContext *s, AVStream *st,

    pkt->size >= 5 && AV_RB32(pkt->data) != 0x001 &&
    (AV_RB24(pkt->data) != 0x01 ||
    (st->codecpar->extradata_size > 0 &&
-    (st->codecpar->extradata[0] & e->mask == 
e->value
+    ((st->codecpar->extradata[0] & e->mask) == 
e->value
    return ff_stream_add_bitstream_filter(st, e->bsf_name, 
NULL);

    }
    return 1;
--


LGTM, thanks.


Thanks. Pushed as f5441e441f9b0d235e49bdccc69e141ccd92e854

Regards,
Gyan

___
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] avformat/mpegtsenc: correct bitstream check

2024-03-16 Thread Marton Balint




On Sat, 16 Mar 2024, Gyan Doshi wrote:


8559cce3c3 made the bitstream check generic using a LUT.
However, one of the comparisons which involves a bitwise AND
and equality check is faulty due to operator precedence.

First reported and analysed at
https://github.com/streamlink/streamlink/issues/5876

Fixes #10908
---
libavformat/mpegtsenc.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavformat/mpegtsenc.c b/libavformat/mpegtsenc.c
index 06e88e9879..b8efc535a7 100644
--- a/libavformat/mpegtsenc.c
+++ b/libavformat/mpegtsenc.c
@@ -2319,7 +2319,7 @@ static int mpegts_check_bitstream(AVFormatContext *s, 
AVStream *st,
pkt->size >= 5 && AV_RB32(pkt->data) != 0x001 &&
(AV_RB24(pkt->data) != 0x01 ||
(st->codecpar->extradata_size > 0 &&
-(st->codecpar->extradata[0] & e->mask == e->value
+((st->codecpar->extradata[0] & e->mask) == e->value
return ff_stream_add_bitstream_filter(st, e->bsf_name, NULL);
}
return 1;
--


LGTM, thanks.

Marton
___
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] avformat/mpegtsenc: correct bitstream check

2024-03-15 Thread Gyan Doshi
8559cce3c3 made the bitstream check generic using a LUT.
However, one of the comparisons which involves a bitwise AND
and equality check is faulty due to operator precedence.

First reported and analysed at
https://github.com/streamlink/streamlink/issues/5876

Fixes #10908
---
 libavformat/mpegtsenc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavformat/mpegtsenc.c b/libavformat/mpegtsenc.c
index 06e88e9879..b8efc535a7 100644
--- a/libavformat/mpegtsenc.c
+++ b/libavformat/mpegtsenc.c
@@ -2319,7 +2319,7 @@ static int mpegts_check_bitstream(AVFormatContext *s, 
AVStream *st,
 pkt->size >= 5 && AV_RB32(pkt->data) != 0x001 &&
 (AV_RB24(pkt->data) != 0x01 ||
 (st->codecpar->extradata_size > 0 &&
-(st->codecpar->extradata[0] & e->mask == e->value
+((st->codecpar->extradata[0] & e->mask) == e->value
 return ff_stream_add_bitstream_filter(st, e->bsf_name, NULL);
 }
 return 1;
-- 
2.44.0

___
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] avformat/mpegtsenc: Always output a minimum of 32 packets.

2022-11-29 Thread Derek Buitenhuis
On 11/28/2022 10:25 PM, Marton Balint wrote:
> This looks like a demuxer bug, which should be fixed in the demuxer, and 
> not in the muxer.

+1.

I had to re-read the commit message twice because I coulndn't figure out why
the muxer would care about lavf specific demuxer probing.

- Derek
___
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] avformat/mpegtsenc: Always output a minimum of 32 packets.

2022-11-28 Thread Marton Balint




On Mon, 28 Nov 2022, James Almer wrote:


From: Thierry Foucu 

Otherwise, if you just output a PAT/PMT and a single TS packets, the
demuxer will not be able to detect TS.


This looks like a demuxer bug, which should be fixed in the demuxer, and 
not in the muxer.


Regards,
Marton



Signed-off-by: James Almer 
---
libavformat/mpegtsenc.c | 11 ---
tests/ref/acodec/s302m  |  4 ++--
tests/ref/lavf/ts   |  4 ++--
3 files changed, 8 insertions(+), 11 deletions(-)

diff --git a/libavformat/mpegtsenc.c b/libavformat/mpegtsenc.c
index 48d39e6a7d..760e5fd8c6 100644
--- a/libavformat/mpegtsenc.c
+++ b/libavformat/mpegtsenc.c
@@ -2147,8 +2147,7 @@ static int mpegts_write_packet_internal(AVFormatContext 
*s, AVPacket *pkt)

static void mpegts_write_flush(AVFormatContext *s)
{
-MpegTSWrite *ts = s->priv_data;
-int i;
+int packets, i;

/* flush current packets */
for (i = 0; i < s->nb_streams; i++) {
@@ -2163,11 +2162,9 @@ static void mpegts_write_flush(AVFormatContext *s)
}
}

-if (ts->m2ts_mode) {
-int packets = (avio_tell(s->pb) / (TS_PACKET_SIZE + 4)) % 32;
-while (packets++ < 32)
-mpegts_insert_null_packet(s);
-}
+packets = (avio_tell(s->pb) / (TS_PACKET_SIZE + 4)) % 32;
+while (packets++ < 32)
+mpegts_insert_null_packet(s);
}

static int mpegts_write_packet(AVFormatContext *s, AVPacket *pkt)
diff --git a/tests/ref/acodec/s302m b/tests/ref/acodec/s302m
index 2919ed6e55..5c12d5ff69 100644
--- a/tests/ref/acodec/s302m
+++ b/tests/ref/acodec/s302m
@@ -1,4 +1,4 @@
-0bf5457fd41a22fc5cdd99ae5ad4e273 *tests/data/fate/acodec-s302m.mpegts
-1527688 tests/data/fate/acodec-s302m.mpegts
+51fdac8dddb34b067f458b8114e3a32c *tests/data/fate/acodec-s302m.mpegts
+1529944 tests/data/fate/acodec-s302m.mpegts
31f25a0020fd9017de9c3c608316854b *tests/data/fate/acodec-s302m.out.wav
stddev:  986.94 PSNR: 36.44 MAXDIFF:18571 bytes:  1058400/  1056708
diff --git a/tests/ref/lavf/ts b/tests/ref/lavf/ts
index b004fc1b1c..cb5395abbc 100644
--- a/tests/ref/lavf/ts
+++ b/tests/ref/lavf/ts
@@ -1,3 +1,3 @@
-371dc016eb3155116bea27e3b4eeb928 *tests/data/lavf/lavf.ts
-389160 tests/data/lavf/lavf.ts
+cf342532317c4ae802c4f95f7d1f2459 *tests/data/lavf/lavf.ts
+393296 tests/data/lavf/lavf.ts
tests/data/lavf/lavf.ts CRC=0x71287e25
--
2.38.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-requ...@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-requ...@ffmpeg.org with subject "unsubscribe".


[FFmpeg-devel] [PATCH] avformat/mpegtsenc: Always output a minimum of 32 packets.

2022-11-28 Thread James Almer
From: Thierry Foucu 

Otherwise, if you just output a PAT/PMT and a single TS packets, the
demuxer will not be able to detect TS.

Signed-off-by: James Almer 
---
 libavformat/mpegtsenc.c | 11 ---
 tests/ref/acodec/s302m  |  4 ++--
 tests/ref/lavf/ts   |  4 ++--
 3 files changed, 8 insertions(+), 11 deletions(-)

diff --git a/libavformat/mpegtsenc.c b/libavformat/mpegtsenc.c
index 48d39e6a7d..760e5fd8c6 100644
--- a/libavformat/mpegtsenc.c
+++ b/libavformat/mpegtsenc.c
@@ -2147,8 +2147,7 @@ static int mpegts_write_packet_internal(AVFormatContext 
*s, AVPacket *pkt)
 
 static void mpegts_write_flush(AVFormatContext *s)
 {
-MpegTSWrite *ts = s->priv_data;
-int i;
+int packets, i;
 
 /* flush current packets */
 for (i = 0; i < s->nb_streams; i++) {
@@ -2163,11 +2162,9 @@ static void mpegts_write_flush(AVFormatContext *s)
 }
 }
 
-if (ts->m2ts_mode) {
-int packets = (avio_tell(s->pb) / (TS_PACKET_SIZE + 4)) % 32;
-while (packets++ < 32)
-mpegts_insert_null_packet(s);
-}
+packets = (avio_tell(s->pb) / (TS_PACKET_SIZE + 4)) % 32;
+while (packets++ < 32)
+mpegts_insert_null_packet(s);
 }
 
 static int mpegts_write_packet(AVFormatContext *s, AVPacket *pkt)
diff --git a/tests/ref/acodec/s302m b/tests/ref/acodec/s302m
index 2919ed6e55..5c12d5ff69 100644
--- a/tests/ref/acodec/s302m
+++ b/tests/ref/acodec/s302m
@@ -1,4 +1,4 @@
-0bf5457fd41a22fc5cdd99ae5ad4e273 *tests/data/fate/acodec-s302m.mpegts
-1527688 tests/data/fate/acodec-s302m.mpegts
+51fdac8dddb34b067f458b8114e3a32c *tests/data/fate/acodec-s302m.mpegts
+1529944 tests/data/fate/acodec-s302m.mpegts
 31f25a0020fd9017de9c3c608316854b *tests/data/fate/acodec-s302m.out.wav
 stddev:  986.94 PSNR: 36.44 MAXDIFF:18571 bytes:  1058400/  1056708
diff --git a/tests/ref/lavf/ts b/tests/ref/lavf/ts
index b004fc1b1c..cb5395abbc 100644
--- a/tests/ref/lavf/ts
+++ b/tests/ref/lavf/ts
@@ -1,3 +1,3 @@
-371dc016eb3155116bea27e3b4eeb928 *tests/data/lavf/lavf.ts
-389160 tests/data/lavf/lavf.ts
+cf342532317c4ae802c4f95f7d1f2459 *tests/data/lavf/lavf.ts
+393296 tests/data/lavf/lavf.ts
 tests/data/lavf/lavf.ts CRC=0x71287e25
-- 
2.38.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-requ...@ffmpeg.org with subject "unsubscribe".


Re: [FFmpeg-devel] [PATCH] avformat/mpegtsenc: add pcr_at_keyframe flag

2022-09-28 Thread Marton Balint




On Wed, 28 Sep 2022, Zhao Zhili wrote:


From: Zhao Zhili 

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 
---
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_B0x08
#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-requ...@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-requ...@ffmpeg.org with subject "unsubscribe".


[FFmpeg-devel] [PATCH] avformat/mpegtsenc: add pcr_at_keyframe flag

2022-09-27 Thread Zhao Zhili
From: Zhao Zhili 

Add PCR at keyframe can be undesirable when -pcr_period is
specified. Add an flag to disable this behavior.

Signed-off-by: Zhao Zhili 
---
 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_B0x08
 #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-requ...@ffmpeg.org with subject "unsubscribe".


Re: [FFmpeg-devel] [PATCH] avformat/mpegtsenc: Implement muxing SCTE-35 and EPG packets

2021-11-08 Thread Maksym Veremeyenko

On 08.11.2021 17:31, Kieran Kunhya wrote:
[...]

The positioning of the packet relative to the PCR matters. Also
splice_time() is relative to the new PCR and timestamps which I don't think
the mux here can guarantee?


i could be wrong, but time_signal() carry splice_time() what carry 
pts_time that /indicates time in terms of ticks of the program’s 90 kHz 
clock/, it does not relates to PCR but relates to PTS of video stream.


--
Maksym Veremeyenko

___
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] avformat/mpegtsenc: Implement muxing SCTE-35 and EPG packets

2021-11-08 Thread Kieran Kunhya
On Mon, 8 Nov 2021 at 15:17, Maksym Veremeyenko  wrote:

> On 08.11.2021 16:41, Kieran Kunhya wrote:
> > On Mon, 8 Nov 2021 at 06:35, Maksym Veremeyenko 
> wrote:
> >
> >> Hi,
> >>
> >> Attached patch implement muxing SCTE-35 and EPG packets into mpegts
> stream.
> >>
> >
> > SCTE Markers need timestamping, no?
> >
>
> SCTE markers has no timestamping, during reading at mpegts.c it
> timestamps recovered from PCR.
>

The positioning of the packet relative to the PCR matters. Also
splice_time() is relative to the new PCR and timestamps which I don't think
the mux here can guarantee?

Kieran
___
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] avformat/mpegtsenc: Implement muxing SCTE-35 and EPG packets

2021-11-08 Thread Maksym Veremeyenko

On 08.11.2021 16:41, Kieran Kunhya wrote:

On Mon, 8 Nov 2021 at 06:35, Maksym Veremeyenko  wrote:


Hi,

Attached patch implement muxing SCTE-35 and EPG packets into mpegts stream.



SCTE Markers need timestamping, no?



SCTE markers has no timestamping, during reading at mpegts.c it 
timestamps recovered from PCR.


--
Maksym Veremeyenko

___
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] avformat/mpegtsenc: Implement muxing SCTE-35 and EPG packets

2021-11-08 Thread Kieran Kunhya
On Mon, 8 Nov 2021 at 06:35, Maksym Veremeyenko  wrote:

> Hi,
>
> Attached patch implement muxing SCTE-35 and EPG packets into mpegts stream.
>

SCTE Markers need timestamping, no?

Kieran
___
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] avformat/mpegtsenc: Implement muxing SCTE-35 and EPG packets

2021-11-07 Thread Maksym Veremeyenko

Hi,

Attached patch implement muxing SCTE-35 and EPG packets into mpegts stream.


--
Maksym Veremeyenko
From dc1b87f5e34c688bb3691767f8026a2815aab03e Mon Sep 17 00:00:00 2001
From: Maksym Veremeyenko 
Date: Mon, 8 Nov 2021 08:10:59 +0200
Subject: [PATCH] avformat/mpegtsenc: Implement muxing SCTE-35 and EPG packets

---
 libavformat/mpegtsenc.c | 47 +++
 1 file changed, 47 insertions(+)

diff --git a/libavformat/mpegtsenc.c b/libavformat/mpegtsenc.c
index e3fba54..1fe3f55 100644
--- a/libavformat/mpegtsenc.c
+++ b/libavformat/mpegtsenc.c
@@ -429,6 +429,12 @@ static int get_dvb_stream_type(AVFormatContext *s, 
AVStream *st)
 stream_type = STREAM_TYPE_PRIVATE_DATA;
 }
 break;
+case AV_CODEC_ID_SCTE_35:
+stream_type = 0x86;
+break;
+case AV_CODEC_ID_EPG:
+stream_type = 0;
+break;
 default:
 av_log_once(s, AV_LOG_WARNING, AV_LOG_DEBUG, &ts_st->data_st_warning,
 "Stream %d, codec %s, is muxed as a private data stream "
@@ -514,6 +520,16 @@ static int mpegts_write_pmt(AVFormatContext *s, 
MpegTSService *service)
 *q++ = 0xfc;// private_data_byte
 }
 
+/* put scte-35 registration tag */
+for (i = 0; i < s->nb_streams; i++) {
+AVStream *st = s->streams[i];
+
+if (st->codecpar->codec_id == AV_CODEC_ID_SCTE_35) {
+put_registration_descriptor(&q, MKTAG('C', 'U', 'E', 'I'));
+break;
+}
+}
+
 val = 0xf000 | (q - program_info_length_ptr - 2);
 program_info_length_ptr[0] = val >> 8;
 program_info_length_ptr[1] = val;
@@ -547,6 +563,9 @@ static int mpegts_write_pmt(AVFormatContext *s, 
MpegTSService *service)
 
 stream_type = ts->m2ts_mode ? get_m2ts_stream_type(s, st) : 
get_dvb_stream_type(s, st);
 
+if (!stream_type)
+continue;
+
 *q++ = stream_type;
 put16(&q, 0xe000 | ts_st->pid);
 desc_length_ptr = q;
@@ -2099,6 +2118,34 @@ static int mpegts_write_packet_internal(AVFormatContext 
*s, AVPacket *pkt)
 ts_st->dvb_ac3_desc = dvb_ac3_desc;
 }
 av_free(hdr);
+} else if (st->codecpar->codec_id == AV_CODEC_ID_SCTE_35) {
+MpegTSSection sec;
+
+sec.pid = ts_st->pid;
+sec.cc = ts_st->payload_size;
+sec.discontinuity= ts->flags & MPEGTS_FLAG_DISCONT;
+sec.write_packet = section_write_packet;
+sec.opaque   = s;
+
+mpegts_write_section(&sec, pkt->data, pkt->size);
+
+ts_st->payload_size = sec.cc;
+
+return 0;
+} else if (st->codecpar->codec_id == AV_CODEC_ID_EPG) {
+MpegTSSection sec;
+
+sec.pid = EIT_PID;
+sec.cc = ts_st->payload_size;
+sec.discontinuity= ts->flags & MPEGTS_FLAG_DISCONT;
+sec.write_packet = section_write_packet;
+sec.opaque   = s;
+
+mpegts_write_section(&sec, pkt->data, pkt->size);
+
+ts_st->payload_size = sec.cc;
+
+return 0;
 }
 
 if (ts_st->payload_size && (ts_st->payload_size + size > 
ts->pes_payload_size ||
-- 
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-requ...@ffmpeg.org with subject "unsubscribe".


Re: [FFmpeg-devel] [PATCH] avformat/mpegtsenc: Dont include adaptation field in teletext TS packets.

2021-11-06 Thread Marton Balint




On Thu, 21 Oct 2021, Alex Shumsky wrote:


From ETSI EN 300 472 V1.3.1 (2003-05) Specification for conveying ITU-R System 
B Teletext in DVB bitstreams:

4.1 Transport Stream (TS) packet format
The standard TS packet syntax and semantics are followed, noting the following 
constraint:
- adaptation_field_control only the values "01" and "10" are permitted.

Some set top boxes (Motorola, Arris, Zyxel) refuse non-conforming packets.

Signed-off-by: Alex Shumsky 
---
libavformat/mpegtsenc.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/libavformat/mpegtsenc.c b/libavformat/mpegtsenc.c
index 184bb52f75..3d630e2500 100644
--- a/libavformat/mpegtsenc.c
+++ b/libavformat/mpegtsenc.c
@@ -1564,7 +1564,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 (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)
write_pcr = 1;


Thanks, will apply.

Regards,
Marton
___
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] avformat/mpegtsenc: Dont include adaptation field in teletext TS packets.

2021-10-21 Thread Alex Shumsky
>From ETSI EN 300 472 V1.3.1 (2003-05) Specification for conveying ITU-R System 
>B Teletext in DVB bitstreams:
4.1 Transport Stream (TS) packet format
The standard TS packet syntax and semantics are followed, noting the following 
constraint:
- adaptation_field_control only the values "01" and "10" are permitted.

Some set top boxes (Motorola, Arris, Zyxel) refuse non-conforming packets.

Signed-off-by: Alex Shumsky 
---
 libavformat/mpegtsenc.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/libavformat/mpegtsenc.c b/libavformat/mpegtsenc.c
index 184bb52f75..3d630e2500 100644
--- a/libavformat/mpegtsenc.c
+++ b/libavformat/mpegtsenc.c
@@ -1564,7 +1564,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 (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)
 write_pcr = 1;
-- 
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-requ...@ffmpeg.org with subject "unsubscribe".


Re: [FFmpeg-devel] [PATCH] avformat/mpegtsenc: Fix mpegts_write_pes() for private_stream_2 and other types

2021-04-19 Thread Marton Balint




On Tue, 20 Apr 2021, zheng qian wrote:


According to the PES packet definition defined in Table 2-17
of ISO_IEC_13818-1 specification, some fields like PTS/DTS or
pes_extension could only appears if the stream_id meets the
condition:

if (stream_id != 0xBC &&  // program_stream_map
stream_id != 0xBE &&  // padding_stream
stream_id != 0xBF &&  // private_stream_2
stream_id != 0xF0 &&  // ECM
stream_id != 0xF1 &&  // EMM
stream_id != 0xFF &&  // program_stream_directory
stream_id != 0xF2 &&  // DSMCC_stream
stream_id != 0xF8) // ITU-T Rec. H.222.1 type E stream

And the following stream_id types don't have fields like PTS/DTS:

else if ( stream_id == program_stream_map
|| stream_id == private_stream_2
|| stream_id == ECM
|| stream_id == EMM
|| stream_id == program_stream_directory
|| stream_id == DSMCC_stream
|| stream_id == ITU-T Rec. H.222.1 type E stream ) {
   for (i = 0; i < PES_packet_length; i++) {
   PES_packet_data_byte
   }
}

Current implementation skipped the judgement of stream_id
causing some kind of stream like private_stream_2 to be
incorrectly written with PTS/DTS field. For example,
Japan DTV transmits news and alerts through ARIB superimpose
that utilizes private_stream_2 still could not be remuxed
correctly for now.

This patch fixes the remuxing of private_stream_2 and other
stream_id types.

Signed-off-by: zheng qian 
---
libavformat/mpegtsenc.c | 108 ++--
1 file changed, 60 insertions(+), 48 deletions(-)

diff --git a/libavformat/mpegtsenc.c b/libavformat/mpegtsenc.c
index f302af84ff..da8fb381e5 100644
--- a/libavformat/mpegtsenc.c
+++ b/libavformat/mpegtsenc.c
@@ -1445,28 +1445,28 @@ static void mpegts_write_pes(AVFormatContext *s, 
AVStream *st,
is_dvb_teletext = 0;
if (st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) {
if (st->codecpar->codec_id == AV_CODEC_ID_DIRAC)
-*q++ = STREAM_ID_EXTENDED_STREAM_ID;
+stream_id = STREAM_ID_EXTENDED_STREAM_ID;
else
-*q++ = STREAM_ID_VIDEO_STREAM_0;
+stream_id = STREAM_ID_VIDEO_STREAM_0;
} else if (st->codecpar->codec_type == AVMEDIA_TYPE_AUDIO &&
   (st->codecpar->codec_id == AV_CODEC_ID_MP2 ||
st->codecpar->codec_id == AV_CODEC_ID_MP3 ||
st->codecpar->codec_id == AV_CODEC_ID_AAC)) {
-*q++ = STREAM_ID_AUDIO_STREAM_0;
+stream_id = STREAM_ID_AUDIO_STREAM_0;
} else if (st->codecpar->codec_type == AVMEDIA_TYPE_AUDIO &&
st->codecpar->codec_id == AV_CODEC_ID_AC3 &&
ts->m2ts_mode) {
-*q++ = STREAM_ID_EXTENDED_STREAM_ID;
+stream_id = STREAM_ID_EXTENDED_STREAM_ID;
} else if (st->codecpar->codec_type == AVMEDIA_TYPE_DATA &&
   st->codecpar->codec_id == AV_CODEC_ID_TIMED_ID3) {
-*q++ = STREAM_ID_PRIVATE_STREAM_1;
+stream_id = STREAM_ID_PRIVATE_STREAM_1;
} else if (st->codecpar->codec_type == AVMEDIA_TYPE_DATA) {
-*q++ = stream_id != -1 ? stream_id : STREAM_ID_METADATA_STREAM;
+stream_id = stream_id != -1 ? stream_id : 
STREAM_ID_METADATA_STREAM;

if (stream_id == STREAM_ID_PRIVATE_STREAM_1) /* asynchronous 
KLV */
pts = dts = AV_NOPTS_VALUE;
} else {
-*q++ = STREAM_ID_PRIVATE_STREAM_1;
+stream_id = STREAM_ID_PRIVATE_STREAM_1;
if (st->codecpar->codec_type == AVMEDIA_TYPE_SUBTITLE) {
if (st->codecpar->codec_id == AV_CODEC_ID_DVB_SUBTITLE) {
is_dvb_subtitle = 1;
@@ -1475,6 +1475,7 @@ static void mpegts_write_pes(AVFormatContext *s, AVStream 
*st,
}
}
}
+*q++ = stream_id;


This is a purley cosmetic change so far, so it should be a separate patch 
from the functional change.



header_len = 0;
flags  = 0;
if (pts != AV_NOPTS_VALUE) {
@@ -1524,50 +1525,61 @@ static void mpegts_write_pes(AVFormatContext *s, 
AVStream *st,
}
*q++ = len >> 8;
*q++ = len;
-val  = 0x80;
-/* data alignment indicator is required for subtitle and data 
streams */
-if (st->codecpar->codec_type == AVMEDIA_TYPE_SUBTITLE || 
st->codecpar->codec_type == AVMEDIA_TYPE_DATA)
-val |= 0x04;
-*q++ = val;
-*q++ = flags;
-*q++ = header_len;
-if (pts != AV_NOPTS_VALUE) {
-write_pts(q, flags >> 6, pts);
-q += 5;
-}
-if (dts != AV_NOPTS_VALUE && pts != AV_NOPTS_VALUE && dts != pts) {
-write_pts(q, 1, dts);
-q += 5;
-}
-if (pes_extension 

Re: [FFmpeg-devel] [PATCH] avformat/mpegtsenc: private_stream_1 is not asynchronous KLV

2021-04-19 Thread Mao Hata

On 2021/04/20 1:36, zheng qian wrote:

I'm working on ARIB related patches for mpegtsenc.c and later
I would like to provide a patch to fix the bug of private_stream_2.

In current situation, mpegts_write_pes() incorrectly writes
private_stream_2 with actually a private_stream_1-like PES header
that shouldn't appear according to the ISO/IEC 13818-1 standard.

Regards,
zheng



Oh, thank you! (and I should have searched the mailing list carefully 
before submitting my patch..)
Your posted patches might be close to what I'm wishing for. I will check 
them.

___
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] avformat/mpegtsenc: Fix mpegts_write_pes() for private_stream_2 and other types

2021-04-19 Thread zheng qian
According to the PES packet definition defined in Table 2-17
of ISO_IEC_13818-1 specification, some fields like PTS/DTS or
pes_extension could only appears if the stream_id meets the
condition:

if (stream_id != 0xBC &&  // program_stream_map
stream_id != 0xBE &&  // padding_stream
stream_id != 0xBF &&  // private_stream_2
stream_id != 0xF0 &&  // ECM
stream_id != 0xF1 &&  // EMM
stream_id != 0xFF &&  // program_stream_directory
stream_id != 0xF2 &&  // DSMCC_stream
stream_id != 0xF8) // ITU-T Rec. H.222.1 type E stream

And the following stream_id types don't have fields like PTS/DTS:

else if ( stream_id == program_stream_map
|| stream_id == private_stream_2
|| stream_id == ECM
|| stream_id == EMM
|| stream_id == program_stream_directory
|| stream_id == DSMCC_stream
|| stream_id == ITU-T Rec. H.222.1 type E stream ) {
for (i = 0; i < PES_packet_length; i++) {
PES_packet_data_byte
}
}

Current implementation skipped the judgement of stream_id
causing some kind of stream like private_stream_2 to be
incorrectly written with PTS/DTS field. For example,
Japan DTV transmits news and alerts through ARIB superimpose
that utilizes private_stream_2 still could not be remuxed
correctly for now.

This patch fixes the remuxing of private_stream_2 and other
stream_id types.

Signed-off-by: zheng qian 
---
 libavformat/mpegtsenc.c | 108 ++--
 1 file changed, 60 insertions(+), 48 deletions(-)

diff --git a/libavformat/mpegtsenc.c b/libavformat/mpegtsenc.c
index f302af84ff..da8fb381e5 100644
--- a/libavformat/mpegtsenc.c
+++ b/libavformat/mpegtsenc.c
@@ -1445,28 +1445,28 @@ static void mpegts_write_pes(AVFormatContext *s, 
AVStream *st,
 is_dvb_teletext = 0;
 if (st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) {
 if (st->codecpar->codec_id == AV_CODEC_ID_DIRAC)
-*q++ = STREAM_ID_EXTENDED_STREAM_ID;
+stream_id = STREAM_ID_EXTENDED_STREAM_ID;
 else
-*q++ = STREAM_ID_VIDEO_STREAM_0;
+stream_id = STREAM_ID_VIDEO_STREAM_0;
 } else if (st->codecpar->codec_type == AVMEDIA_TYPE_AUDIO &&
(st->codecpar->codec_id == AV_CODEC_ID_MP2 ||
 st->codecpar->codec_id == AV_CODEC_ID_MP3 ||
 st->codecpar->codec_id == AV_CODEC_ID_AAC)) {
-*q++ = STREAM_ID_AUDIO_STREAM_0;
+stream_id = STREAM_ID_AUDIO_STREAM_0;
 } else if (st->codecpar->codec_type == AVMEDIA_TYPE_AUDIO &&
 st->codecpar->codec_id == AV_CODEC_ID_AC3 &&
 ts->m2ts_mode) {
-*q++ = STREAM_ID_EXTENDED_STREAM_ID;
+stream_id = STREAM_ID_EXTENDED_STREAM_ID;
 } else if (st->codecpar->codec_type == AVMEDIA_TYPE_DATA &&
st->codecpar->codec_id == AV_CODEC_ID_TIMED_ID3) {
-*q++ = STREAM_ID_PRIVATE_STREAM_1;
+stream_id = STREAM_ID_PRIVATE_STREAM_1;
 } else if (st->codecpar->codec_type == AVMEDIA_TYPE_DATA) {
-*q++ = stream_id != -1 ? stream_id : STREAM_ID_METADATA_STREAM;
+stream_id = stream_id != -1 ? stream_id : 
STREAM_ID_METADATA_STREAM;
 
 if (stream_id == STREAM_ID_PRIVATE_STREAM_1) /* asynchronous 
KLV */
 pts = dts = AV_NOPTS_VALUE;
 } else {
-*q++ = STREAM_ID_PRIVATE_STREAM_1;
+stream_id = STREAM_ID_PRIVATE_STREAM_1;
 if (st->codecpar->codec_type == AVMEDIA_TYPE_SUBTITLE) {
 if (st->codecpar->codec_id == AV_CODEC_ID_DVB_SUBTITLE) {
 is_dvb_subtitle = 1;
@@ -1475,6 +1475,7 @@ static void mpegts_write_pes(AVFormatContext *s, AVStream 
*st,
 }
 }
 }
+*q++ = stream_id;
 header_len = 0;
 flags  = 0;
 if (pts != AV_NOPTS_VALUE) {
@@ -1524,50 +1525,61 @@ static void mpegts_write_pes(AVFormatContext *s, 
AVStream *st,
 }
 *q++ = len >> 8;
 *q++ = len;
-val  = 0x80;
-/* data alignment indicator is required for subtitle and data 
streams */
-if (st->codecpar->codec_type == AVMEDIA_TYPE_SUBTITLE || 
st->codecpar->codec_type == AVMEDIA_TYPE_DATA)
-val |= 0x04;
-*q++ = val;
-*q++ = flags;
-*q++ = header_len;
-if (pts != AV_NOPTS_VALUE) {
-write_pts(q, flags >> 6, pts);
-q += 5;
-}
-if (dts != AV_NOPTS_VALUE && pts != AV_NOPTS_VALUE && dts != pts) {
-write_pts(q, 1, dts);
-q += 5;
-}
-if (pes_extension && st->codecpar->codec_id == AV_CODEC_ID_DIRAC) {
-flags = 0x01;  /* set PES_extension_flag_2 */
-

Re: [FFmpeg-devel] [PATCH] avformat/mpegtsenc: private_stream_1 is not asynchronous KLV

2021-04-19 Thread zheng qian
On Tue, Apr 20, 2021 at 12:44 AM Mao Hata  wrote:
>
> The reason I created the patch was to fix the problem: when I transcode
> a transport stream based on ARIB-STD-B24, the PTS/DTS is removed from
> private_stream_1 streams, and, conversely, it is added to private_stream_2.
> "ISO/IEC 13818-1 Table 2-17 - PES packet" (sorry, the table number may
> have been shifted) defines the conditions under which PTS/DTS can exist
> as follows:
>
>  >if (stream_id != program_stream_map
>  > && stream_id != padding_stream
>  > && stream_id != private_stream_2
>  > && stream_id != ECM
>  > && stream_id != EMM
>  > && stream_id != program_stream_directory
>  > && stream_id != DSMCC_stream
>  > && stream_id != ITU-T Rec. H.222.1 type E stream) {
>
> So, private_stream_2 can not insert PTS/DTS. In addition, "ARIB-STD-B24,
> VOLUME3, Chapter5" defines private_stream_1 as "Synchronized PES"
> (mainly used for subtitles, with PTS/DTS inserted) and
> private_stream_2 as "Asynchronous PES" (mainly used for superinpose, no
> PTS/DTS inserted).

I'm working on ARIB related patches for mpegtsenc.c and later
I would like to provide a patch to fix the bug of private_stream_2.

In current situation, mpegts_write_pes() incorrectly writes
private_stream_2 with actually a private_stream_1-like PES header
that shouldn't appear according to the ISO/IEC 13818-1 standard.

Regards,
zheng

>  From these things, I misunderstood like that " PTS/DTS is generally
> inserted for private_stream_1, so the `if (stream_id ==
> STREAM_ID_PRIVATE_STREAM_1)` statement (I patched) must be a mistake! " ...
>
> Anyway, as I read the related code, I now understand that the problem
> should be solved specifically for ARIB-based transport stream (at
> "mpegts.c" or so.).
> Thank you again.
> ___
> 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 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] avformat/mpegtsenc: private_stream_1 is not asynchronous KLV

2021-04-19 Thread Mao Hata

On 2021/04/19 5:25, Marton Balint wrote:



On Sat, 17 Apr 2021, Mao Hata wrote:


According to ISO/IEC 13818-1, private_stream_1 is a synchronous
(has PTS/DTS) stream. Asynchronous one is private_stream_2.


Which section describes this?

Also keep in mind that code was added so that AV_CODEC_ID_SMPTE_KLV is 
handled in mpegts, and SMPTE RP 217 promotes the usage of 
private_stream_1, so I don't think this can be simply changed.


Regards,
Marton


Thank you for your reply. And I was not considering SMPTE (I misread the 
word "KLV" just an abbreviation for "Key-Length-Value"). Oh... I 
withdraw this patch.


The reason I created the patch was to fix the problem: when I transcode 
a transport stream based on ARIB-STD-B24, the PTS/DTS is removed from 
private_stream_1 streams, and, conversely, it is added to private_stream_2.
"ISO/IEC 13818-1 Table 2-17 - PES packet" (sorry, the table number may 
have been shifted) defines the conditions under which PTS/DTS can exist 
as follows:


>if (stream_id != program_stream_map
> && stream_id != padding_stream
> && stream_id != private_stream_2
> && stream_id != ECM
> && stream_id != EMM
> && stream_id != program_stream_directory
> && stream_id != DSMCC_stream
> && stream_id != ITU-T Rec. H.222.1 type E stream) {

So, private_stream_2 can not insert PTS/DTS. In addition, "ARIB-STD-B24, 
VOLUME3, Chapter5" defines private_stream_1 as "Synchronized PES" 
(mainly used for subtitles, with PTS/DTS inserted) and
private_stream_2 as "Asynchronous PES" (mainly used for superinpose, no 
PTS/DTS inserted).


From these things, I misunderstood like that " PTS/DTS is generally 
inserted for private_stream_1, so the `if (stream_id == 
STREAM_ID_PRIVATE_STREAM_1)` statement (I patched) must be a mistake! " ...


Anyway, as I read the related code, I now understand that the problem 
should be solved specifically for ARIB-based transport stream (at 
"mpegts.c" or so.).

Thank you again.
___
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] avformat/mpegtsenc: private_stream_1 is not asynchronous KLV

2021-04-18 Thread Marton Balint




On Sat, 17 Apr 2021, Mao Hata wrote:


According to ISO/IEC 13818-1, private_stream_1 is a synchronous
(has PTS/DTS) stream. Asynchronous one is private_stream_2.


Which section describes this?

Also keep in mind that code was added so that AV_CODEC_ID_SMPTE_KLV is 
handled in mpegts, and SMPTE RP 217 promotes the usage of 
private_stream_1, so I don't think this can be simply changed.


Regards,
Marton
___
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] avformat/mpegtsenc: private_stream_1 is not asynchronous KLV

2021-04-17 Thread Mao Hata

According to ISO/IEC 13818-1, private_stream_1 is a synchronous
(has PTS/DTS) stream. Asynchronous one is private_stream_2.

From c1663cbdbbd2178cb199e079ec9bb712d1d757d8 Mon Sep 17 00:00:00 2001
From: Mao Hata 
Date: Sat, 17 Apr 2021 19:55:22 +0900
Subject: [PATCH] avformat/mpegtsenc: private_stream_1 is not asynchronous KLV

This fixes inappropriately removing PTS/DTS from "bin_data" output.

Signed-off-by: Mao Hata 
---
 libavformat/mpegts.h| 1 +
 libavformat/mpegtsenc.c | 2 +-
 2 files changed, 2 insertions(+), 1 deletion(-)

diff --git a/libavformat/mpegts.h b/libavformat/mpegts.h
index 04874e0f42..ed640733e3 100644
--- a/libavformat/mpegts.h
+++ b/libavformat/mpegts.h
@@ -139,6 +139,7 @@
 
 /* ISO/IEC 13818-1 Table 2-22 */
 #define STREAM_ID_PRIVATE_STREAM_1   0xbd
+#define STREAM_ID_PRIVATE_STREAM_2   0xbf
 #define STREAM_ID_AUDIO_STREAM_0 0xc0
 #define STREAM_ID_VIDEO_STREAM_0 0xe0
 #define STREAM_ID_METADATA_STREAM0xfc
diff --git a/libavformat/mpegtsenc.c b/libavformat/mpegtsenc.c
index a357f3a6aa..9982089d0f 100644
--- a/libavformat/mpegtsenc.c
+++ b/libavformat/mpegtsenc.c
@@ -1434,7 +1434,7 @@ static void mpegts_write_pes(AVFormatContext *s, AVStream 
*st,
 } else if (st->codecpar->codec_type == AVMEDIA_TYPE_DATA) {
 *q++ = stream_id != -1 ? stream_id : STREAM_ID_METADATA_STREAM;
 
-if (stream_id == STREAM_ID_PRIVATE_STREAM_1) /* asynchronous 
KLV */
+if (stream_id == STREAM_ID_PRIVATE_STREAM_2) /* asynchronous 
KLV */
 pts = dts = AV_NOPTS_VALUE;
 } else {
 *q++ = STREAM_ID_PRIVATE_STREAM_1;
-- 
2.31.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-requ...@ffmpeg.org with subject "unsubscribe".


Re: [FFmpeg-devel] [PATCH] avformat/mpegtsenc: Preserve disposition in the absence of language

2021-04-04 Thread Marton Balint



On Sun, 4 Apr 2021, Andreas Rheinhardt wrote:


Marton Balint:



On Sat, 3 Apr 2021, Andreas Rheinhardt wrote:


Implements ticket #9113.

Signed-off-by: Andreas Rheinhardt 
---
libavformat/mpegtsenc.c | 18 +-
1 file changed, 9 insertions(+), 9 deletions(-)

diff --git a/libavformat/mpegtsenc.c b/libavformat/mpegtsenc.c
index 35c835c484..dbd3bb148a 100644
--- a/libavformat/mpegtsenc.c
+++ b/libavformat/mpegtsenc.c
@@ -459,6 +459,8 @@ static int mpegts_write_pmt(AVFormatContext *s,
MpegTSService *service)
    AVStream *st = s->streams[i];
    MpegTSWriteStream *ts_st = st->priv_data;
    AVDictionaryEntry *lang = av_dict_get(st->metadata,
"language", NULL, 0);
+    const char default_language[] = "und";
+    const char *language = lang && strlen(lang->value) >= 3 ?
lang->value : default_language;
    enum AVCodecID codec_id = st->codecpar->codec_id;

    if (s->nb_programs) {
@@ -598,16 +600,19 @@ static int mpegts_write_pmt(AVFormatContext *s,
MpegTSService *service)
    }
    }

-    if (lang) {
-    char *p;
-    char *next = lang->value;
+    if (language != default_language ||
+    st->disposition & (AV_DISPOSITION_CLEAN_EFFECTS    |
+   AV_DISPOSITION_HEARING_IMPAIRED |
+   AV_DISPOSITION_VISUAL_IMPAIRED)) {
+    const char *p;
+    const char *next = language;
    uint8_t *len_ptr;

    *q++ = ISO_639_LANGUAGE_DESCRIPTOR;
    len_ptr  = q++;
    *len_ptr = 0;

-    for (p = lang->value; next && *len_ptr < 255 / 4 * 4;
p = next + 1) {
+    for (p = next; next && *len_ptr < 255 / 4 * 4; p =
next + 1) {


Maybe it would make the code more readable to do both initializations in
the for() statement, e.g.: for (p = next = language; ...)



The reason I didn't do so is that it would make the line above 80
characters. So the alternatives to my current patch would be:

   for (p = next = language; next && *len_ptr < 255 / 4 * 4;
p = next + 1) {


I like this the most wrapped to a single line. I don't think adhereing to 
the 80 char limit makes the code more readable here, so I'd simply ignore 
it.


Regards,
Marton



or

   for (const char *p = language, *next = p;
next && *len_ptr < 255 / 4 * 4; p = next + 1) {

or factoring out writing the ISO 639 language descriptor into a function
of its own or just ignoring the 80 chars line limit.
What do you prefer?


LGTM otherwise.

Thanks,
Marton


    if (q - data > SECTION_LENGTH - 4) {
    err = 1;
    break;
@@ -637,10 +642,6 @@ static int mpegts_write_pmt(AVFormatContext *s,
MpegTSService *service)
    }
    break;
    case AVMEDIA_TYPE_SUBTITLE:
-    {
-   const char default_language[] = "und";
-   const char *language = lang && strlen(lang->value) >= 3 ?
lang->value : default_language;
-
   if (codec_id == AV_CODEC_ID_DVB_SUBTITLE) {
   uint8_t *len_ptr;
   int extradata_copied = 0;
@@ -715,7 +716,6 @@ static int mpegts_write_pmt(AVFormatContext *s,
MpegTSService *service)

   *len_ptr = q - len_ptr - 1;
    }
-    }
    break;
    case AVMEDIA_TYPE_VIDEO:
    if (stream_type == STREAM_TYPE_VIDEO_DIRAC) {
-- 
2.27.0

___
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 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 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 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] avformat/mpegtsenc: Preserve disposition in the absence of language

2021-04-04 Thread Andreas Rheinhardt
Marton Balint:
> 
> 
> On Sat, 3 Apr 2021, Andreas Rheinhardt wrote:
> 
>> Implements ticket #9113.
>>
>> Signed-off-by: Andreas Rheinhardt 
>> ---
>> libavformat/mpegtsenc.c | 18 +-
>> 1 file changed, 9 insertions(+), 9 deletions(-)
>>
>> diff --git a/libavformat/mpegtsenc.c b/libavformat/mpegtsenc.c
>> index 35c835c484..dbd3bb148a 100644
>> --- a/libavformat/mpegtsenc.c
>> +++ b/libavformat/mpegtsenc.c
>> @@ -459,6 +459,8 @@ static int mpegts_write_pmt(AVFormatContext *s,
>> MpegTSService *service)
>>     AVStream *st = s->streams[i];
>>     MpegTSWriteStream *ts_st = st->priv_data;
>>     AVDictionaryEntry *lang = av_dict_get(st->metadata,
>> "language", NULL, 0);
>> +    const char default_language[] = "und";
>> +    const char *language = lang && strlen(lang->value) >= 3 ?
>> lang->value : default_language;
>>     enum AVCodecID codec_id = st->codecpar->codec_id;
>>
>>     if (s->nb_programs) {
>> @@ -598,16 +600,19 @@ static int mpegts_write_pmt(AVFormatContext *s,
>> MpegTSService *service)
>>     }
>>     }
>>
>> -    if (lang) {
>> -    char *p;
>> -    char *next = lang->value;
>> +    if (language != default_language ||
>> +    st->disposition & (AV_DISPOSITION_CLEAN_EFFECTS    |
>> +   AV_DISPOSITION_HEARING_IMPAIRED |
>> +   AV_DISPOSITION_VISUAL_IMPAIRED)) {
>> +    const char *p;
>> +    const char *next = language;
>>     uint8_t *len_ptr;
>>
>>     *q++ = ISO_639_LANGUAGE_DESCRIPTOR;
>>     len_ptr  = q++;
>>     *len_ptr = 0;
>>
>> -    for (p = lang->value; next && *len_ptr < 255 / 4 * 4;
>> p = next + 1) {
>> +    for (p = next; next && *len_ptr < 255 / 4 * 4; p =
>> next + 1) {
> 
> Maybe it would make the code more readable to do both initializations in
> the for() statement, e.g.: for (p = next = language; ...)
> 

The reason I didn't do so is that it would make the line above 80
characters. So the alternatives to my current patch would be:

for (p = next = language; next && *len_ptr < 255 / 4 * 4;
 p = next + 1) {

or

for (const char *p = language, *next = p;
 next && *len_ptr < 255 / 4 * 4; p = next + 1) {

or factoring out writing the ISO 639 language descriptor into a function
of its own or just ignoring the 80 chars line limit. What do you prefer?

> LGTM otherwise.
> 
> Thanks,
> Marton
> 
>>     if (q - data > SECTION_LENGTH - 4) {
>>     err = 1;
>>     break;
>> @@ -637,10 +642,6 @@ static int mpegts_write_pmt(AVFormatContext *s,
>> MpegTSService *service)
>>     }
>>     break;
>>     case AVMEDIA_TYPE_SUBTITLE:
>> -    {
>> -   const char default_language[] = "und";
>> -   const char *language = lang && strlen(lang->value) >= 3 ?
>> lang->value : default_language;
>> -
>>    if (codec_id == AV_CODEC_ID_DVB_SUBTITLE) {
>>    uint8_t *len_ptr;
>>    int extradata_copied = 0;
>> @@ -715,7 +716,6 @@ static int mpegts_write_pmt(AVFormatContext *s,
>> MpegTSService *service)
>>
>>    *len_ptr = q - len_ptr - 1;
>>     }
>> -    }
>>     break;
>>     case AVMEDIA_TYPE_VIDEO:
>>     if (stream_type == STREAM_TYPE_VIDEO_DIRAC) {
>> -- 
>> 2.27.0
>>
>> ___
>> 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 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 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] avformat/mpegtsenc: Preserve disposition in the absence of language

2021-04-04 Thread Marton Balint



On Sat, 3 Apr 2021, Andreas Rheinhardt wrote:


Implements ticket #9113.

Signed-off-by: Andreas Rheinhardt 
---
libavformat/mpegtsenc.c | 18 +-
1 file changed, 9 insertions(+), 9 deletions(-)

diff --git a/libavformat/mpegtsenc.c b/libavformat/mpegtsenc.c
index 35c835c484..dbd3bb148a 100644
--- a/libavformat/mpegtsenc.c
+++ b/libavformat/mpegtsenc.c
@@ -459,6 +459,8 @@ static int mpegts_write_pmt(AVFormatContext *s, 
MpegTSService *service)
AVStream *st = s->streams[i];
MpegTSWriteStream *ts_st = st->priv_data;
AVDictionaryEntry *lang = av_dict_get(st->metadata, "language", NULL, 
0);
+const char default_language[] = "und";
+const char *language = lang && strlen(lang->value) >= 3 ? lang->value 
: default_language;
enum AVCodecID codec_id = st->codecpar->codec_id;

if (s->nb_programs) {
@@ -598,16 +600,19 @@ static int mpegts_write_pmt(AVFormatContext *s, 
MpegTSService *service)
}
}

-if (lang) {
-char *p;
-char *next = lang->value;
+if (language != default_language ||
+st->disposition & (AV_DISPOSITION_CLEAN_EFFECTS|
+   AV_DISPOSITION_HEARING_IMPAIRED |
+   AV_DISPOSITION_VISUAL_IMPAIRED)) {
+const char *p;
+const char *next = language;
uint8_t *len_ptr;

*q++ = ISO_639_LANGUAGE_DESCRIPTOR;
len_ptr  = q++;
*len_ptr = 0;

-for (p = lang->value; next && *len_ptr < 255 / 4 * 4; p = next 
+ 1) {
+for (p = next; next && *len_ptr < 255 / 4 * 4; p = next + 1) {


Maybe it would make the code more readable to do both initializations in 
the for() statement, e.g.: for (p = next = language; ...)


LGTM otherwise.

Thanks,
Marton


if (q - data > SECTION_LENGTH - 4) {
err = 1;
break;
@@ -637,10 +642,6 @@ static int mpegts_write_pmt(AVFormatContext *s, 
MpegTSService *service)
}
break;
case AVMEDIA_TYPE_SUBTITLE:
-{
-   const char default_language[] = "und";
-   const char *language = lang && strlen(lang->value) >= 3 ? 
lang->value : default_language;
-
   if (codec_id == AV_CODEC_ID_DVB_SUBTITLE) {
   uint8_t *len_ptr;
   int extradata_copied = 0;
@@ -715,7 +716,6 @@ static int mpegts_write_pmt(AVFormatContext *s, 
MpegTSService *service)

   *len_ptr = q - len_ptr - 1;
}
-}
break;
case AVMEDIA_TYPE_VIDEO:
if (stream_type == STREAM_TYPE_VIDEO_DIRAC) {
--
2.27.0

___
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 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] avformat/mpegtsenc: Preserve disposition in the absence of language

2021-04-03 Thread Andreas Rheinhardt
stephen douglas:
>  ISO 639 language descriptors used by DVB are the 3 charecter variants hence 
> const char *language = lang && strlen(lang->value) >= 3 ? lang->value : 
> default_language;should beconst char *language = lang && strlen(lang->value) 
> > 3 ? lang->value : default_language;

1. Stop top-posting.
2. Are you even aware that strlen does not include the trailing \0?

>On Saturday, 3 April 2021, 06:53:20 BST, Andreas Rheinhardt 
>  wrote:  
>  
>  Implements ticket #9113.
> 
> Signed-off-by: Andreas Rheinhardt 
> ---
___
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] avformat/mpegtsenc: Preserve disposition in the absence of language

2021-04-02 Thread stephen douglas
 ISO 639 language descriptors used by DVB are the 3 charecter variants hence 
const char *language = lang && strlen(lang->value) >= 3 ? lang->value : 
default_language;should beconst char *language = lang && strlen(lang->value) > 
3 ? lang->value : default_language;
   On Saturday, 3 April 2021, 06:53:20 BST, Andreas Rheinhardt 
 wrote:  
 
 Implements ticket #9113.

Signed-off-by: Andreas Rheinhardt 
---
 libavformat/mpegtsenc.c | 18 +-
 1 file changed, 9 insertions(+), 9 deletions(-)

diff --git a/libavformat/mpegtsenc.c b/libavformat/mpegtsenc.c
index 35c835c484..dbd3bb148a 100644
--- a/libavformat/mpegtsenc.c
+++ b/libavformat/mpegtsenc.c
@@ -459,6 +459,8 @@ static int mpegts_write_pmt(AVFormatContext *s, 
MpegTSService *service)
        AVStream *st = s->streams[i];
        MpegTSWriteStream *ts_st = st->priv_data;
        AVDictionaryEntry *lang = av_dict_get(st->metadata, "language", NULL, 
0);
+        const char default_language[] = "und";
+        const char *language = lang && strlen(lang->value) >= 3 ? lang->value 
: default_language;
        enum AVCodecID codec_id = st->codecpar->codec_id;
 
        if (s->nb_programs) {
@@ -598,16 +600,19 @@ static int mpegts_write_pmt(AVFormatContext *s, 
MpegTSService *service)
                }
            }
 
-            if (lang) {
-                char *p;
-                char *next = lang->value;
+            if (language != default_language ||
+                st->disposition & (AV_DISPOSITION_CLEAN_EFFECTS    |
+                                  AV_DISPOSITION_HEARING_IMPAIRED |
+                                  AV_DISPOSITION_VISUAL_IMPAIRED)) {
+                const char *p;
+                const char *next = language;
                uint8_t *len_ptr;
 
                *q++    = ISO_639_LANGUAGE_DESCRIPTOR;
                len_ptr  = q++;
                *len_ptr = 0;
 
-                for (p = lang->value; next && *len_ptr < 255 / 4 * 4; p = next 
+ 1) {
+                for (p = next; next && *len_ptr < 255 / 4 * 4; p = next + 1) {
                    if (q - data > SECTION_LENGTH - 4) {
                        err = 1;
                        break;
@@ -637,10 +642,6 @@ static int mpegts_write_pmt(AVFormatContext *s, 
MpegTSService *service)
            }
            break;
        case AVMEDIA_TYPE_SUBTITLE:
-        {
-          const char default_language[] = "und";
-          const char *language = lang && strlen(lang->value) >= 3 ? 
lang->value : default_language;
-
            if (codec_id == AV_CODEC_ID_DVB_SUBTITLE) {
                uint8_t *len_ptr;
                int extradata_copied = 0;
@@ -715,7 +716,6 @@ static int mpegts_write_pmt(AVFormatContext *s, 
MpegTSService *service)
 
                *len_ptr = q - len_ptr - 1;
            }
-        }
        break;
        case AVMEDIA_TYPE_VIDEO:
            if (stream_type == STREAM_TYPE_VIDEO_DIRAC) {
-- 
2.27.0

___
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 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] avformat/mpegtsenc: Preserve disposition in the absence of language

2021-04-02 Thread Andreas Rheinhardt
Implements ticket #9113.

Signed-off-by: Andreas Rheinhardt 
---
 libavformat/mpegtsenc.c | 18 +-
 1 file changed, 9 insertions(+), 9 deletions(-)

diff --git a/libavformat/mpegtsenc.c b/libavformat/mpegtsenc.c
index 35c835c484..dbd3bb148a 100644
--- a/libavformat/mpegtsenc.c
+++ b/libavformat/mpegtsenc.c
@@ -459,6 +459,8 @@ static int mpegts_write_pmt(AVFormatContext *s, 
MpegTSService *service)
 AVStream *st = s->streams[i];
 MpegTSWriteStream *ts_st = st->priv_data;
 AVDictionaryEntry *lang = av_dict_get(st->metadata, "language", NULL, 
0);
+const char default_language[] = "und";
+const char *language = lang && strlen(lang->value) >= 3 ? lang->value 
: default_language;
 enum AVCodecID codec_id = st->codecpar->codec_id;
 
 if (s->nb_programs) {
@@ -598,16 +600,19 @@ static int mpegts_write_pmt(AVFormatContext *s, 
MpegTSService *service)
 }
 }
 
-if (lang) {
-char *p;
-char *next = lang->value;
+if (language != default_language ||
+st->disposition & (AV_DISPOSITION_CLEAN_EFFECTS|
+   AV_DISPOSITION_HEARING_IMPAIRED |
+   AV_DISPOSITION_VISUAL_IMPAIRED)) {
+const char *p;
+const char *next = language;
 uint8_t *len_ptr;
 
 *q++ = ISO_639_LANGUAGE_DESCRIPTOR;
 len_ptr  = q++;
 *len_ptr = 0;
 
-for (p = lang->value; next && *len_ptr < 255 / 4 * 4; p = next 
+ 1) {
+for (p = next; next && *len_ptr < 255 / 4 * 4; p = next + 1) {
 if (q - data > SECTION_LENGTH - 4) {
 err = 1;
 break;
@@ -637,10 +642,6 @@ static int mpegts_write_pmt(AVFormatContext *s, 
MpegTSService *service)
 }
 break;
 case AVMEDIA_TYPE_SUBTITLE:
-{
-   const char default_language[] = "und";
-   const char *language = lang && strlen(lang->value) >= 3 ? 
lang->value : default_language;
-
if (codec_id == AV_CODEC_ID_DVB_SUBTITLE) {
uint8_t *len_ptr;
int extradata_copied = 0;
@@ -715,7 +716,6 @@ static int mpegts_write_pmt(AVFormatContext *s, 
MpegTSService *service)
 
*len_ptr = q - len_ptr - 1;
 }
-}
 break;
 case AVMEDIA_TYPE_VIDEO:
 if (stream_type == STREAM_TYPE_VIDEO_DIRAC) {
-- 
2.27.0

___
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] avformat/mpegtsenc: use av_log_once for data stream warning

2020-04-22 Thread Gyan Doshi



On 23-04-2020 01:33 am, Marton Balint wrote:



On Wed, 22 Apr 2020, Gyan Doshi wrote:


---
libavformat/mpegtsenc.c | 15 +++
1 file changed, 11 insertions(+), 4 deletions(-)

diff --git a/libavformat/mpegtsenc.c b/libavformat/mpegtsenc.c
index 4fe3d84c59..f2be6c6632 100644
--- a/libavformat/mpegtsenc.c
+++ b/libavformat/mpegtsenc.c
@@ -238,6 +238,7 @@ typedef struct MpegTSWriteStream {
    int payload_flags;
    uint8_t *payload;
    AVFormatContext *amux;
+    int data_st_warning;

    int64_t pcr_period; /* PCR period in PCR time base */
    int64_t last_pcr;
@@ -285,6 +286,7 @@ static void put_registration_descriptor(uint8_t 
**q_ptr, uint32_t tag)

static int get_dvb_stream_type(AVFormatContext *s, AVStream *st)
{
    MpegTSWrite *ts = s->priv_data;
+    MpegTSWriteStream *ts_st = st->priv_data;
    int stream_type;

    switch (st->codecpar->codec_id) {
@@ -354,8 +356,10 @@ static int get_dvb_stream_type(AVFormatContext 
*s, AVStream *st)

    stream_type = STREAM_TYPE_PRIVATE_DATA;
    break;
    default:
-    av_log(s, AV_LOG_WARNING, "Stream %d, codec %s, is muxed as 
a private data stream "
-   "and may not be recognized upon reading.\n", 
st->index, avcodec_get_name(st->codecpar->codec_id));
+    av_log_once(s, AV_LOG_WARNING, AV_LOG_DEBUG, 
&ts_st->data_st_warning,
+    "Stream %d, codec %s, is muxed as a private data 
stream "
+    "and may not be recognized upon reading.\n", 
st->index,

+ avcodec_get_name(st->codecpar->codec_id));
    stream_type = STREAM_TYPE_PRIVATE_DATA;
    break;
    }
@@ -366,6 +370,7 @@ static int get_dvb_stream_type(AVFormatContext 
*s, AVStream *st)

static int get_m2ts_stream_type(AVFormatContext *s, AVStream *st)
{
    int stream_type;
+    MpegTSWriteStream *ts_st = st->priv_data;

    switch (st->codecpar->codec_id) {
    case AV_CODEC_ID_MPEG2VIDEO:
@@ -402,8 +407,10 @@ static int get_m2ts_stream_type(AVFormatContext 
*s, AVStream *st)

    stream_type = 0x92;
    break;
    default:
-    av_log(s, AV_LOG_WARNING, "Stream %d, codec %s, is muxed as 
a private data stream "
-   "and may not be recognized upon reading.\n", 
st->index, avcodec_get_name(st->codecpar->codec_id));
+    av_log_once(s, AV_LOG_WARNING, AV_LOG_DEBUG, 
&ts_st->data_st_warning,
+    "Stream %d, codec %s, is muxed as a private data 
stream "
+    "and may not be recognized upon reading.\n", 
st->index,

+ avcodec_get_name(st->codecpar->codec_id));
    stream_type = STREAM_TYPE_PRIVATE_DATA;
    break;
    }


LGTM, thanks.


Thanks. Pushed as fc8a239e9d0a0eeadcd4f5e93a3de56bd68ac8ed

Gyan
___
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] avformat/mpegtsenc: use av_log_once for data stream warning

2020-04-22 Thread Marton Balint



On Wed, 22 Apr 2020, Gyan Doshi wrote:


---
libavformat/mpegtsenc.c | 15 +++
1 file changed, 11 insertions(+), 4 deletions(-)

diff --git a/libavformat/mpegtsenc.c b/libavformat/mpegtsenc.c
index 4fe3d84c59..f2be6c6632 100644
--- a/libavformat/mpegtsenc.c
+++ b/libavformat/mpegtsenc.c
@@ -238,6 +238,7 @@ typedef struct MpegTSWriteStream {
int payload_flags;
uint8_t *payload;
AVFormatContext *amux;
+int data_st_warning;

int64_t pcr_period; /* PCR period in PCR time base */
int64_t last_pcr;
@@ -285,6 +286,7 @@ static void put_registration_descriptor(uint8_t **q_ptr, 
uint32_t tag)
static int get_dvb_stream_type(AVFormatContext *s, AVStream *st)
{
MpegTSWrite *ts = s->priv_data;
+MpegTSWriteStream *ts_st = st->priv_data;
int stream_type;

switch (st->codecpar->codec_id) {
@@ -354,8 +356,10 @@ static int get_dvb_stream_type(AVFormatContext *s, 
AVStream *st)
stream_type = STREAM_TYPE_PRIVATE_DATA;
break;
default:
-av_log(s, AV_LOG_WARNING, "Stream %d, codec %s, is muxed as a private data 
stream "
-   "and may not be recognized upon reading.\n", st->index, 
avcodec_get_name(st->codecpar->codec_id));
+av_log_once(s, AV_LOG_WARNING, AV_LOG_DEBUG, &ts_st->data_st_warning,
+"Stream %d, codec %s, is muxed as a private data stream "
+"and may not be recognized upon reading.\n", st->index,
+avcodec_get_name(st->codecpar->codec_id));
stream_type = STREAM_TYPE_PRIVATE_DATA;
break;
}
@@ -366,6 +370,7 @@ static int get_dvb_stream_type(AVFormatContext *s, AVStream 
*st)
static int get_m2ts_stream_type(AVFormatContext *s, AVStream *st)
{
int stream_type;
+MpegTSWriteStream *ts_st = st->priv_data;

switch (st->codecpar->codec_id) {
case AV_CODEC_ID_MPEG2VIDEO:
@@ -402,8 +407,10 @@ static int get_m2ts_stream_type(AVFormatContext *s, 
AVStream *st)
stream_type = 0x92;
break;
default:
-av_log(s, AV_LOG_WARNING, "Stream %d, codec %s, is muxed as a private data 
stream "
-   "and may not be recognized upon reading.\n", st->index, 
avcodec_get_name(st->codecpar->codec_id));
+av_log_once(s, AV_LOG_WARNING, AV_LOG_DEBUG, &ts_st->data_st_warning,
+"Stream %d, codec %s, is muxed as a private data stream "
+"and may not be recognized upon reading.\n", st->index,
+avcodec_get_name(st->codecpar->codec_id));
stream_type = STREAM_TYPE_PRIVATE_DATA;
break;
}


LGTM, thanks.

Marton
___
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] avformat/mpegtsenc: use av_log_once for data stream warning

2020-04-22 Thread Gyan Doshi
---
 libavformat/mpegtsenc.c | 15 +++
 1 file changed, 11 insertions(+), 4 deletions(-)

diff --git a/libavformat/mpegtsenc.c b/libavformat/mpegtsenc.c
index 4fe3d84c59..f2be6c6632 100644
--- a/libavformat/mpegtsenc.c
+++ b/libavformat/mpegtsenc.c
@@ -238,6 +238,7 @@ typedef struct MpegTSWriteStream {
 int payload_flags;
 uint8_t *payload;
 AVFormatContext *amux;
+int data_st_warning;
 
 int64_t pcr_period; /* PCR period in PCR time base */
 int64_t last_pcr;
@@ -285,6 +286,7 @@ static void put_registration_descriptor(uint8_t **q_ptr, 
uint32_t tag)
 static int get_dvb_stream_type(AVFormatContext *s, AVStream *st)
 {
 MpegTSWrite *ts = s->priv_data;
+MpegTSWriteStream *ts_st = st->priv_data;
 int stream_type;
 
 switch (st->codecpar->codec_id) {
@@ -354,8 +356,10 @@ static int get_dvb_stream_type(AVFormatContext *s, 
AVStream *st)
 stream_type = STREAM_TYPE_PRIVATE_DATA;
 break;
 default:
-av_log(s, AV_LOG_WARNING, "Stream %d, codec %s, is muxed as a private 
data stream "
-   "and may not be recognized upon reading.\n", st->index, 
avcodec_get_name(st->codecpar->codec_id));
+av_log_once(s, AV_LOG_WARNING, AV_LOG_DEBUG, &ts_st->data_st_warning,
+"Stream %d, codec %s, is muxed as a private data stream "
+"and may not be recognized upon reading.\n", st->index,
+avcodec_get_name(st->codecpar->codec_id));
 stream_type = STREAM_TYPE_PRIVATE_DATA;
 break;
 }
@@ -366,6 +370,7 @@ static int get_dvb_stream_type(AVFormatContext *s, AVStream 
*st)
 static int get_m2ts_stream_type(AVFormatContext *s, AVStream *st)
 {
 int stream_type;
+MpegTSWriteStream *ts_st = st->priv_data;
 
 switch (st->codecpar->codec_id) {
 case AV_CODEC_ID_MPEG2VIDEO:
@@ -402,8 +407,10 @@ static int get_m2ts_stream_type(AVFormatContext *s, 
AVStream *st)
 stream_type = 0x92;
 break;
 default:
-av_log(s, AV_LOG_WARNING, "Stream %d, codec %s, is muxed as a private 
data stream "
-   "and may not be recognized upon reading.\n", st->index, 
avcodec_get_name(st->codecpar->codec_id));
+av_log_once(s, AV_LOG_WARNING, AV_LOG_DEBUG, &ts_st->data_st_warning,
+"Stream %d, codec %s, is muxed as a private data stream "
+"and may not be recognized upon reading.\n", st->index,
+avcodec_get_name(st->codecpar->codec_id));
 stream_type = STREAM_TYPE_PRIVATE_DATA;
 break;
 }
-- 
2.26.0

___
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] avformat/mpegtsenc: don't print warning for DVB text streams

2020-04-22 Thread Gyan Doshi



On 22-04-2020 01:21 am, Marton Balint wrote:



On Mon, 20 Apr 2020, Gyan Doshi wrote:


They can be demuxed by ffmpeg.
---
libavformat/mpegtsenc.c | 4 
1 file changed, 4 insertions(+)

diff --git a/libavformat/mpegtsenc.c b/libavformat/mpegtsenc.c
index ccb631d746..3818001976 100644
--- a/libavformat/mpegtsenc.c
+++ b/libavformat/mpegtsenc.c
@@ -381,6 +381,10 @@ static int mpegts_write_pmt(AVFormatContext *s, 
MpegTSService *service)

    case AV_CODEC_ID_TIMED_ID3:
    stream_type = STREAM_TYPE_METADATA;
    break;
+    case AV_CODEC_ID_DVB_SUBTITLE:
+    case AV_CODEC_ID_DVB_TELETEXT:
+    stream_type = STREAM_TYPE_PRIVATE_DATA;
+    break;


LGTM.


Will apply.




    default:
    av_log(s, AV_LOG_WARNING, "Stream %d, codec %s, is muxed 
as a private data stream "
   "and may not be recognized upon reading.\n", i, 
avcodec_get_name(st->codecpar->codec_id));


Preferably av_log_once should be used here with a state variable 
stored in MpegTSWriteStream because it is logged for every PMT...


In next patch.

Thanks,
Gyan
___
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] avformat/mpegtsenc: don't print warning for DVB text streams

2020-04-21 Thread Marton Balint



On Mon, 20 Apr 2020, Gyan Doshi wrote:


They can be demuxed by ffmpeg.
---
libavformat/mpegtsenc.c | 4 
1 file changed, 4 insertions(+)

diff --git a/libavformat/mpegtsenc.c b/libavformat/mpegtsenc.c
index ccb631d746..3818001976 100644
--- a/libavformat/mpegtsenc.c
+++ b/libavformat/mpegtsenc.c
@@ -381,6 +381,10 @@ static int mpegts_write_pmt(AVFormatContext *s, 
MpegTSService *service)
case AV_CODEC_ID_TIMED_ID3:
stream_type = STREAM_TYPE_METADATA;
break;
+case AV_CODEC_ID_DVB_SUBTITLE:
+case AV_CODEC_ID_DVB_TELETEXT:
+stream_type = STREAM_TYPE_PRIVATE_DATA;
+break;


LGTM.


default:
av_log(s, AV_LOG_WARNING, "Stream %d, codec %s, is muxed as a private 
data stream "
   "and may not be recognized upon reading.\n", i, 
avcodec_get_name(st->codecpar->codec_id));


Preferably av_log_once should be used here with a state variable stored in 
MpegTSWriteStream because it is logged for every PMT...


Thanks,
Marton
___
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] avformat/mpegtsenc: don't print warning for DVB text streams

2020-04-20 Thread Gyan Doshi
They can be demuxed by ffmpeg.
---
 libavformat/mpegtsenc.c | 4 
 1 file changed, 4 insertions(+)

diff --git a/libavformat/mpegtsenc.c b/libavformat/mpegtsenc.c
index ccb631d746..3818001976 100644
--- a/libavformat/mpegtsenc.c
+++ b/libavformat/mpegtsenc.c
@@ -381,6 +381,10 @@ static int mpegts_write_pmt(AVFormatContext *s, 
MpegTSService *service)
 case AV_CODEC_ID_TIMED_ID3:
 stream_type = STREAM_TYPE_METADATA;
 break;
+case AV_CODEC_ID_DVB_SUBTITLE:
+case AV_CODEC_ID_DVB_TELETEXT:
+stream_type = STREAM_TYPE_PRIVATE_DATA;
+break;
 default:
 av_log(s, AV_LOG_WARNING, "Stream %d, codec %s, is muxed as a 
private data stream "
"and may not be recognized upon reading.\n", i, 
avcodec_get_name(st->codecpar->codec_id));
-- 
2.26.0

___
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] avformat/mpegtsenc: warn users if codec isn't supported

2019-12-23 Thread Gyan



On 23-12-2019 08:45 pm, Limin Wang wrote:

On Fri, Dec 20, 2019 at 04:55:12PM +0530, Gyan wrote:

Regards,
Gyan
 From fbbd221b089f3b272cfd712c3d4824dd86b4eac0 Mon Sep 17 00:00:00 2001
From: Gyan Doshi 
Date: Fri, 20 Dec 2019 16:39:32 +0530
Subject: [PATCH] avformat/mpegtsenc: warn users if codec isn't supported

The MPEG-TS muxer will mux streams with unsupported codec id
as a private data stream; this usually makes the stream
not recognizable by ffmpeg and likely other tools.
---
  libavformat/mpegtsenc.c | 1 +
  1 file changed, 1 insertion(+)

diff --git a/libavformat/mpegtsenc.c b/libavformat/mpegtsenc.c
index 5b4694bfd1..f24112465a 100644
--- a/libavformat/mpegtsenc.c
+++ b/libavformat/mpegtsenc.c
@@ -382,6 +382,7 @@ static int mpegts_write_pmt(AVFormatContext *s, 
MpegTSService *service)
  stream_type = STREAM_TYPE_METADATA;
  break;
  default:
+av_log(s, AV_LOG_WARNING, "Stream %d, codec %s, is muxed as a private data 
stream and may not be recognized upon reading.\n", i, 
avcodec_get_name(st->codecpar->codec_id));

I suggest that you can split long code into two lines.


Done. And pushed as f0b3b55002b7ad024ef94f005cd718a14d85e485

Thanks,
Gyan
___
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] avformat/mpegtsenc: warn users if codec isn't supported

2019-12-23 Thread Limin Wang
On Fri, Dec 20, 2019 at 04:55:12PM +0530, Gyan wrote:
> 
> Regards,
> Gyan

> From fbbd221b089f3b272cfd712c3d4824dd86b4eac0 Mon Sep 17 00:00:00 2001
> From: Gyan Doshi 
> Date: Fri, 20 Dec 2019 16:39:32 +0530
> Subject: [PATCH] avformat/mpegtsenc: warn users if codec isn't supported
> 
> The MPEG-TS muxer will mux streams with unsupported codec id
> as a private data stream; this usually makes the stream
> not recognizable by ffmpeg and likely other tools.
> ---
>  libavformat/mpegtsenc.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/libavformat/mpegtsenc.c b/libavformat/mpegtsenc.c
> index 5b4694bfd1..f24112465a 100644
> --- a/libavformat/mpegtsenc.c
> +++ b/libavformat/mpegtsenc.c
> @@ -382,6 +382,7 @@ static int mpegts_write_pmt(AVFormatContext *s, 
> MpegTSService *service)
>  stream_type = STREAM_TYPE_METADATA;
>  break;
>  default:
> +av_log(s, AV_LOG_WARNING, "Stream %d, codec %s, is muxed as a 
> private data stream and may not be recognized upon reading.\n", i, 
> avcodec_get_name(st->codecpar->codec_id));

I suggest that you can split long code into two lines.

>  stream_type = STREAM_TYPE_PRIVATE_DATA;
>  break;
>  }
> -- 
> 2.24.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-requ...@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-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH] avformat/mpegtsenc: warn users if codec isn't supported

2019-12-22 Thread Gyan



On 20-12-2019 04:55 pm, Gyan wrote:


Regards,
Gyan


Will push tonight.

Gyan
___
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] avformat/mpegtsenc: warn users if codec isn't supported

2019-12-20 Thread Gyan


Regards,
Gyan
From fbbd221b089f3b272cfd712c3d4824dd86b4eac0 Mon Sep 17 00:00:00 2001
From: Gyan Doshi 
Date: Fri, 20 Dec 2019 16:39:32 +0530
Subject: [PATCH] avformat/mpegtsenc: warn users if codec isn't supported

The MPEG-TS muxer will mux streams with unsupported codec id
as a private data stream; this usually makes the stream
not recognizable by ffmpeg and likely other tools.
---
 libavformat/mpegtsenc.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/libavformat/mpegtsenc.c b/libavformat/mpegtsenc.c
index 5b4694bfd1..f24112465a 100644
--- a/libavformat/mpegtsenc.c
+++ b/libavformat/mpegtsenc.c
@@ -382,6 +382,7 @@ static int mpegts_write_pmt(AVFormatContext *s, 
MpegTSService *service)
 stream_type = STREAM_TYPE_METADATA;
 break;
 default:
+av_log(s, AV_LOG_WARNING, "Stream %d, codec %s, is muxed as a 
private data stream and may not be recognized upon reading.\n", i, 
avcodec_get_name(st->codecpar->codec_id));
 stream_type = STREAM_TYPE_PRIVATE_DATA;
 break;
 }
-- 
2.24.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-requ...@ffmpeg.org with subject "unsubscribe".

[FFmpeg-devel] [PATCH] avformat/mpegtsenc: do not write SDT for m2ts

2019-11-14 Thread Marton Balint
BDMV does not seem to use it.

Signed-off-by: Marton Balint 
---
 doc/muxers.texi | 3 ++-
 libavformat/mpegtsenc.c | 3 ++-
 2 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/doc/muxers.texi b/doc/muxers.texi
index 4e76b40151..aa4bde518d 100644
--- a/doc/muxers.texi
+++ b/doc/muxers.texi
@@ -1633,7 +1633,8 @@ is less than 100 ms is used for VBR streams.
 Maximum time in seconds between PAT/PMT tables. Default is @code{0.1}.
 
 @item sdt_period @var{duration}
-Maximum time in seconds between SDT tables. Default is @code{0.5}.
+Maximum time in seconds between SDT tables. Default is @code{0.5}. Regardless
+of this setting no SDT is written in m2ts mode.
 
 @item tables_version @var{integer}
 Set PAT, PMT and SDT version (default @code{0}, valid values are from 0 to 31, 
inclusively).
diff --git a/libavformat/mpegtsenc.c b/libavformat/mpegtsenc.c
index f37aa31915..a10a3e2450 100644
--- a/libavformat/mpegtsenc.c
+++ b/libavformat/mpegtsenc.c
@@ -1074,7 +1074,8 @@ static void retransmit_si_info(AVFormatContext *s, int 
force_pat, int force_sdt,
 ) {
 if (pcr != AV_NOPTS_VALUE)
 ts->last_sdt_ts = FFMAX(pcr, ts->last_sdt_ts);
-mpegts_write_sdt(s);
+if (!ts->m2ts_mode)
+mpegts_write_sdt(s);
 }
 if ((pcr != AV_NOPTS_VALUE && ts->last_pat_ts == AV_NOPTS_VALUE) ||
 (pcr != AV_NOPTS_VALUE && pcr - ts->last_pat_ts >= ts->pat_period) ||
-- 
2.16.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] avformat/mpegtsenc: fix PCR generation intervals

2019-08-06 Thread Andreas Håkon
Hi Marton,


‐‐‐ Original Message ‐‐‐
On Tuesday, 6 de August de 2019 0:20, Marton Balint  wrote:

> On Mon, 5 Aug 2019, Andreas Håkon wrote:
>
> > Hi Marton,
> > ‐‐‐ Original Message ‐‐‐
> > On Sunday, 4 de August de 2019 22:30, Marton Balint c...@passwd.hu wrote:
> >
> > > PCR generation was based on counting packets for both CBR and VBR streams.
> > > Couting packets might have worked for CBR streams (when muxrate was 
> > > specified)
> > > but it only took into account the packets of a service (or the packets of 
> > > the
> > > PCR stream lately), so even that was problematic for multi program 
> > > streams.
> > > The new code works on actual PCR for CBR and packet DTS values for VBR 
> > > streams,
> > > so the default 20ms PCR retransmission time is now respected for both CBR 
> > > and
> > > VBR.
> >
> > I do some tests with this patch and the previous 
> > https://patchwork.ffmpeg.org/patch/14210/
> > And the result is that the repetition rate of PCR is inconsistent: it's 
> > never
> > constant and varies between different PCR streams.
>
> Are you testing CRB or VBR? For VBR you get PCR at the start of every
> packet with the command line you provided, so PCR interval should be
> constant. DVB Inspector always shows the streams as if they were CBR, so
> the PCR/PTS/DTS view is not showing the intervals properly for VBR.

U... I'm testing with and without "-muxrate". However, I feel you're right 
and
every time I check it with VBR the results are wrong. I'll continue testing it.


> > > +  int64_t pcr = -1; /* avoid warning */
> > > +  retransmit_si_info(s, force_pat, dts);
> > >force_pat = 0;
> > >write_pcr = 0;
> > > +  if (ts_st->pcr_packet_period) {
> > > +  if (ts->mux_rate > 1 || is_start) // VBR pcr period is 
> > > based on frames
> > > +  ts_st->pcr_packet_count++;
> > > +  if (ts_st->pcr_packet_count >=
> > > +  ts_st->pcr_packet_period) {
> > > +  ts_st->pcr_packet_count = 0;
> > > +  write_pcr = 1;
> > > +  if (ts_st->pcr_period) {
> > > +  if (ts->mux_rate > 1) {
> > > +  pcr = get_pcr(ts, s->pb);
> > > +  if (pcr - ts_st->last_pcr >= ts_st->pcr_period)
> > > +  write_pcr = 1;
> > > +  } else if (dts != AV_NOPTS_VALUE) {
> > > +  pcr = (dts - delay) * 300;
> > > +  if (pcr - ts_st->last_pcr >= ts_st->pcr_period && 
> > > is_start)
> > > +  write_pcr = 1;
> > >}
> > > +  if (write_pcr)
> > > +  ts_st->last_pcr = FFMAX(pcr - ts_st->pcr_period, 
> > > ts_st->last_pcr + ts_st->pcr_period);
> > >}
> > >
> >
> > IMHO, here you return to make the same mistake of the previous code:
> > only consider one PCR stream. Instead of the "if (ts_st->pcr_period)" it's
> > required to iterate over all PCR streams and do the corresponding checks.
> > And if some PCR stream has exceeded the pcr_period limit then enforce to
> > write an empty TS packet with a PCR mark.
>
> For CBR, I agree, even if the extra PCR packets increase the bitrate
> slightly. I can try implementing this.

The increase in additional packages is negligible. PCR in empty TS packets is
a common practice. So don't worry about it.


> I am not sure what are we trying to achieve for VBR though. Since you
> don't know the bitrate you can't sensibly calculate PCR for non-start
> packets. So I believe for VBR the code works as it is supposed to.

My concern is about CBR streams (used for broadcasting), and not VBR.
So I prefer to fix the issue with such streams. However, I feel you're
right with VBR: the code works. And futhermore, when my interleaving
patch will be applied then the problem will be less problematic. The
reason will be that then each stream will be processed more or less at
the same time in parallel. Therefore, PCR calculations in a VBR streams
can only have minimum deviations.


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] avformat/mpegtsenc: fix PCR generation intervals

2019-08-05 Thread Marton Balint



On Mon, 5 Aug 2019, Andreas Håkon wrote:


Hi Marton,


‐‐‐ Original Message ‐‐‐
On Sunday, 4 de August de 2019 22:30, Marton Balint  wrote:


PCR generation was based on counting packets for both CBR and VBR streams.
Couting packets might have worked for CBR streams (when muxrate was specified)
but it only took into account the packets of a service (or the packets of the
PCR stream lately), so even that was problematic for multi program streams.

The new code works on actual PCR for CBR and packet DTS values for VBR streams,
so the default 20ms PCR retransmission time is now respected for both CBR and
VBR.



I do some tests with this patch and the previous 
https://patchwork.ffmpeg.org/patch/14210/

And the result is that the repetition rate of PCR is inconsistent: it's never
constant and varies between different PCR streams.


Are you testing CRB or VBR? For VBR you get PCR at the start of every 
packet with the command line you provided, so PCR interval should be 
constant. DVB Inspector always shows the streams as if they were CBR, so 
the PCR/PTS/DTS view is not showing the intervals properly for VBR.



+int64_t pcr = -1; /* avoid warning */
+
 retransmit_si_info(s, force_pat, dts);
 force_pat = 0;

 write_pcr = 0;
-if (ts_st->pcr_packet_period) {
-if (ts->mux_rate > 1 || is_start) // VBR pcr period is based on 
frames
-ts_st->pcr_packet_count++;
-if (ts_st->pcr_packet_count >=
-ts_st->pcr_packet_period) {
-ts_st->pcr_packet_count = 0;
-write_pcr = 1;
+if (ts_st->pcr_period) {
+if (ts->mux_rate > 1) {
+pcr = get_pcr(ts, s->pb);
+if (pcr - ts_st->last_pcr >= ts_st->pcr_period)
+write_pcr = 1;
+} else if (dts != AV_NOPTS_VALUE) {
+pcr = (dts - delay) * 300;
+if (pcr - ts_st->last_pcr >= ts_st->pcr_period && is_start)
+write_pcr = 1;
 }
+if (write_pcr)
+ts_st->last_pcr = FFMAX(pcr - ts_st->pcr_period, ts_st->last_pcr 
+ ts_st->pcr_period);
 }


IMHO, here you return to make the same mistake of the previous code:
only consider one PCR stream. Instead of the "if (ts_st->pcr_period)" it's
required to iterate over all PCR streams and do the corresponding checks.
And if some PCR stream has exceeded the pcr_period limit then enforce to
write an empty TS packet with a PCR mark.


For CBR, I agree, even if the extra PCR packets increase the bitrate 
slightly. I can try implementing this.


I am not sure what are we trying to achieve for VBR though. Since you 
don't know the bitrate you can't sensibly calculate PCR for non-start 
packets. So I believe for VBR the code works as it is supposed to.


Regards,
Marton
___
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] avformat/mpegtsenc: fix PCR generation intervals

2019-08-05 Thread Andreas Håkon
Hi Marton,


‐‐‐ Original Message ‐‐‐
On Sunday, 4 de August de 2019 22:30, Marton Balint  wrote:

> PCR generation was based on counting packets for both CBR and VBR streams.
> Couting packets might have worked for CBR streams (when muxrate was specified)
> but it only took into account the packets of a service (or the packets of the
> PCR stream lately), so even that was problematic for multi program streams.
>
> The new code works on actual PCR for CBR and packet DTS values for VBR 
> streams,
> so the default 20ms PCR retransmission time is now respected for both CBR and
> VBR.
>

I do some tests with this patch and the previous 
https://patchwork.ffmpeg.org/patch/14210/

And the result is that the repetition rate of PCR is inconsistent: it's never
constant and varies between different PCR streams.

But fortunately I have an idea...


> Signed-off-by: Marton Balint c...@passwd.hu
>
> libavformat/mpegtsenc.c | 60 +++--
> tests/ref/lavf/ts | 2 +-
> 2 files changed, 19 insertions(+), 43 deletions(-)
>
> diff --git a/libavformat/mpegtsenc.c b/libavformat/mpegtsenc.c

[...]

> @@ -1194,18 +1168,24 @@  static void mpegts_write_pes(AVFormatContext *s, 
> AVStream *st,
>
>  is_start = 1;
>  while (payload_size > 0) {
> +int64_t pcr = -1; /* avoid warning */
> +
>  retransmit_si_info(s, force_pat, dts);
>  force_pat = 0;
>
>  write_pcr = 0;
> -if (ts_st->pcr_packet_period) {
> -if (ts->mux_rate > 1 || is_start) // VBR pcr period is based on 
> frames
> -ts_st->pcr_packet_count++;
> -if (ts_st->pcr_packet_count >=
> -ts_st->pcr_packet_period) {
> -ts_st->pcr_packet_count = 0;
> -write_pcr = 1;
> +if (ts_st->pcr_period) {
> +if (ts->mux_rate > 1) {
> +pcr = get_pcr(ts, s->pb);
> +if (pcr - ts_st->last_pcr >= ts_st->pcr_period)
> +write_pcr = 1;
> +} else if (dts != AV_NOPTS_VALUE) {
> +pcr = (dts - delay) * 300;
> +if (pcr - ts_st->last_pcr >= ts_st->pcr_period && is_start)
> +write_pcr = 1;
>  }
> +if (write_pcr)
> +ts_st->last_pcr = FFMAX(pcr - ts_st->pcr_period, 
> ts_st->last_pcr + ts_st->pcr_period);
>  }

IMHO, here you return to make the same mistake of the previous code:
only consider one PCR stream. Instead of the "if (ts_st->pcr_period)" it's
required to iterate over all PCR streams and do the corresponding checks.
And if some PCR stream has exceeded the pcr_period limit then enforce to
write an empty TS packet with a PCR mark.

In fact, the root cause is the sequential PES writing on the MPEG-TS muxer.
And this is the reason for my interleaving mux patch:
https://patchwork.ffmpeg.org/patch/13745/

However, until I rebase your code for the interleave mux mode, the PCR
generation of this patch needs to be fixed.

[...]


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".

[FFmpeg-devel] [PATCH] avformat/mpegtsenc: fix PCR generation intervals

2019-08-04 Thread Marton Balint
PCR generation was based on counting packets for both CBR and VBR streams.
Couting packets might have worked for CBR streams (when muxrate was specified)
but it only took into account the packets of a service (or the packets of the
PCR stream lately), so even that was problematic for multi program streams.

The new code works on actual PCR for CBR and packet DTS values for VBR streams,
so the default 20ms PCR retransmission time is now respected for both CBR and
VBR.

Signed-off-by: Marton Balint 
---
 libavformat/mpegtsenc.c | 60 +++--
 tests/ref/lavf/ts   |  2 +-
 2 files changed, 19 insertions(+), 43 deletions(-)

diff --git a/libavformat/mpegtsenc.c b/libavformat/mpegtsenc.c
index 02651308f8..a501807711 100644
--- a/libavformat/mpegtsenc.c
+++ b/libavformat/mpegtsenc.c
@@ -237,10 +237,9 @@ typedef struct MpegTSWriteStream {
 int payload_flags;
 uint8_t *payload;
 AVFormatContext *amux;
-AVRational user_tb;
 
-int pcr_packet_count;
-int pcr_packet_period;
+int pcr_period;
+int64_t last_pcr;
 
 /* For Opus */
 int opus_queued_samples;
@@ -792,32 +791,9 @@ static void 
enable_pcr_generation_for_stream(AVFormatContext *s, AVStream *pcr_s
 MpegTSWrite *ts = s->priv_data;
 MpegTSWriteStream *ts_st = pcr_st->priv_data;
 
-if (ts->mux_rate > 1) {
-ts_st->pcr_packet_period   = (int64_t)ts->mux_rate * ts->pcr_period /
- (TS_PACKET_SIZE * 8 * 1000);
-} else {
-if (pcr_st->codecpar->codec_type == AVMEDIA_TYPE_AUDIO) {
-int frame_size = av_get_audio_frame_duration2(pcr_st->codecpar, 0);
-if (!frame_size) {
-av_log(s, AV_LOG_WARNING, "frame size not set\n");
-ts_st->pcr_packet_period =
-pcr_st->codecpar->sample_rate / (10 * 512);
-} else {
-ts_st->pcr_packet_period =
-pcr_st->codecpar->sample_rate / (10 * frame_size);
-}
-} else {
-// max delta PCR 0.1s
-// TODO: should be avg_frame_rate
-ts_st->pcr_packet_period =
-ts_st->user_tb.den / (10 * ts_st->user_tb.num);
-}
-if (!ts_st->pcr_packet_period)
-ts_st->pcr_packet_period = 1;
-}
-
+ts_st->pcr_period = av_rescale(ts->pcr_period, PCR_TIME_BASE, 1000);
 // output a PCR as soon as possible
-ts_st->pcr_packet_count = ts_st->pcr_packet_period;
+ts_st->last_pcr   = av_rescale(s->max_delay, PCR_TIME_BASE, AV_TIME_BASE) 
- ts_st->pcr_period;
 }
 
 static void select_pcr_streams(AVFormatContext *s)
@@ -907,7 +883,6 @@ static int mpegts_init(AVFormatContext *s)
 }
 st->priv_data = ts_st;
 
-ts_st->user_tb = st->time_base;
 avpriv_set_pts_info(st, 33, 1, 9);
 
 ts_st->payload = av_mallocz(ts->pes_payload_size);
@@ -1183,7 +1158,6 @@ static void mpegts_write_pes(AVFormatContext *s, AVStream 
*st,
 uint8_t *q;
 int val, is_start, len, header_len, write_pcr, is_dvb_subtitle, 
is_dvb_teletext, flags;
 int afc_len, stuffing_len;
-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;
 
@@ -1194,18 +1168,24 @@ static void mpegts_write_pes(AVFormatContext *s, 
AVStream *st,
 
 is_start = 1;
 while (payload_size > 0) {
+int64_t pcr = -1; /* avoid warning */
+
 retransmit_si_info(s, force_pat, dts);
 force_pat = 0;
 
 write_pcr = 0;
-if (ts_st->pcr_packet_period) {
-if (ts->mux_rate > 1 || is_start) // VBR pcr period is based on 
frames
-ts_st->pcr_packet_count++;
-if (ts_st->pcr_packet_count >=
-ts_st->pcr_packet_period) {
-ts_st->pcr_packet_count = 0;
-write_pcr = 1;
+if (ts_st->pcr_period) {
+if (ts->mux_rate > 1) {
+pcr = get_pcr(ts, s->pb);
+if (pcr - ts_st->last_pcr >= ts_st->pcr_period)
+write_pcr = 1;
+} else if (dts != AV_NOPTS_VALUE) {
+pcr = (dts - delay) * 300;
+if (pcr - ts_st->last_pcr >= ts_st->pcr_period && is_start)
+write_pcr = 1;
 }
+if (write_pcr)
+ts_st->last_pcr = FFMAX(pcr - ts_st->pcr_period, 
ts_st->last_pcr + ts_st->pcr_period);
 }
 
 if (ts->mux_rate > 1 && dts != AV_NOPTS_VALUE &&
@@ -1236,7 +1216,7 @@ static void mpegts_write_pes(AVFormatContext *s, AVStream 
*st,
 }
 if (key && is_start && pts != AV_NOPTS_VALUE) {
 // set Random Access for key frames
-if (ts_st->pcr_packet_period)
+if (ts_st->pcr_period)
 write_pcr = 1;
 set_af_flag(buf, 0x40);
  

Re: [FFmpeg-devel] [PATCH] avformat/mpegtsenc: added support for the write_data_type callback

2019-03-22 Thread Oliver Collyer via ffmpeg-devel
> 
> This patch makes it possible to do stuff like write a custom in-memory TS 
> segmenter, which was what I needed it for.
> 
>> Hi
>> 
>> I needed to be able to use the write_data_type callback when reading data 
>> from the mpegts muxer, to make my application aware of key frames in the 
>> data so I added support. I used the matroska implementation as a reference.
>> 
>> If this is accepted, I will format this as a proper patch after feedback.
>> 
>> Regards
>> 
>> Oliver
>> 
>> diff --git a/libavformat/mpegtsenc.c b/libavformat/mpegtsenc.c
>> index fc0ea225c6..e5d1a64b4c 100644
>> --- a/libavformat/mpegtsenc.c
>> +++ b/libavformat/mpegtsenc.c
>> @@ -1815,6 +1815,12 @@ static int mpegts_write_packet(AVFormatContext *s, 
>> AVPacket *pkt)
>>  mpegts_write_flush(s);
>>  return 1;
>>  } else {
>> +if (s->pb && s->pb->write_data_type) {
>> +AVStream *st = s->streams[pkt->stream_index];
>> +avio_write_marker(s->pb,
>> +av_rescale_q(pkt->dts, st->time_base, AV_TIME_BASE_Q),
>> +(pkt->flags & AV_PKT_FLAG_KEY) && st->codecpar->codec_type 
>> == AVMEDIA_TYPE_VIDEO ? AVIO_DATA_MARKER_SYNC_POINT : 
>> AVIO_DATA_MARKER_BOUNDARY_POINT);
>> +}
>>  return mpegts_write_packet_internal(s, pkt);
>>  }
>> }
>> 
> 
> So I've created a patch for this.
> 
> <0001-mpegtsenc-added-support-for-the-write_data_type-call.patch>

Ping, for this really trivial patch.

___
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] avformat/mpegtsenc: added support for the write_data_type callback

2019-03-15 Thread Oliver Collyer
> 
> This patch makes it possible to do stuff like write a custom in-memory TS 
> segmenter, which was what I needed it for.
> 
>> Hi
>> 
>> I needed to be able to use the write_data_type callback when reading data 
>> from the mpegts muxer, to make my application aware of key frames in the 
>> data so I added support. I used the matroska implementation as a reference.
>> 
>> If this is accepted, I will format this as a proper patch after feedback.
>> 
>> Regards
>> 
>> Oliver
>> 
>> diff --git a/libavformat/mpegtsenc.c b/libavformat/mpegtsenc.c
>> index fc0ea225c6..e5d1a64b4c 100644
>> --- a/libavformat/mpegtsenc.c
>> +++ b/libavformat/mpegtsenc.c
>> @@ -1815,6 +1815,12 @@ static int mpegts_write_packet(AVFormatContext *s, 
>> AVPacket *pkt)
>>   mpegts_write_flush(s);
>>   return 1;
>>   } else {
>> +if (s->pb && s->pb->write_data_type) {
>> +AVStream *st = s->streams[pkt->stream_index];
>> +avio_write_marker(s->pb,
>> +av_rescale_q(pkt->dts, st->time_base, AV_TIME_BASE_Q),
>> +(pkt->flags & AV_PKT_FLAG_KEY) && st->codecpar->codec_type 
>> == AVMEDIA_TYPE_VIDEO ? AVIO_DATA_MARKER_SYNC_POINT : 
>> AVIO_DATA_MARKER_BOUNDARY_POINT);
>> +}
>>   return mpegts_write_packet_internal(s, pkt);
>>   }
>> }
>> 
> 
> So I've created a patch for this.
> 
> <0001-mpegtsenc-added-support-for-the-write_data_type-call.patch>

And how about this one, can this be pushed too?

I'm unsure of the etiquette with a ping message like this, sorry if I offend 
anyone, but it's been over a week and I guess that means it was forgotten?



0001-mpegtsenc-added-support-for-the-write_data_type-call.patch
Description: Binary data


___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] avformat/mpegtsenc: added support for the write_data_type callback

2019-03-08 Thread Oliver Collyer
[Apols for sending this again, but I realised the subject didn't describe the 
change, which was unhelpful)

This patch makes it possible to do stuff like write a custom in-memory TS 
segmenter, which was what I needed it for.

> Hi
> 
> I needed to be able to use the write_data_type callback when reading data 
> from the mpegts muxer, to make my application aware of key frames in the data 
> so I added support. I used the matroska implementation as a reference.
> 
> If this is accepted, I will format this as a proper patch after feedback.
> 
> Regards
> 
> Oliver
> 
> diff --git a/libavformat/mpegtsenc.c b/libavformat/mpegtsenc.c
> index fc0ea225c6..e5d1a64b4c 100644
> --- a/libavformat/mpegtsenc.c
> +++ b/libavformat/mpegtsenc.c
> @@ -1815,6 +1815,12 @@ static int mpegts_write_packet(AVFormatContext *s, 
> AVPacket *pkt)
>mpegts_write_flush(s);
>return 1;
>} else {
> +if (s->pb && s->pb->write_data_type) {
> +AVStream *st = s->streams[pkt->stream_index];
> +avio_write_marker(s->pb,
> +av_rescale_q(pkt->dts, st->time_base, AV_TIME_BASE_Q),
> +(pkt->flags & AV_PKT_FLAG_KEY) && st->codecpar->codec_type 
> == AVMEDIA_TYPE_VIDEO ? AVIO_DATA_MARKER_SYNC_POINT : 
> AVIO_DATA_MARKER_BOUNDARY_POINT);
> +}
>return mpegts_write_packet_internal(s, pkt);
>}
> }
> 

So I've created a patch for this.



0001-mpegtsenc-added-support-for-the-write_data_type-call.patch
Description: Binary data
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] avformat/mpegtsenc:

2019-03-07 Thread Oliver Collyer

> Hi
> 
> I needed to be able to use the write_data_type callback when reading data 
> from the mpegts muxer, to make my application aware of key frames in the data 
> so I added support. I used the matroska implementation as a reference.
> 
> If this is accepted, I will format this as a proper patch after feedback.
> 
> Regards
> 
> Oliver
> 
> diff --git a/libavformat/mpegtsenc.c b/libavformat/mpegtsenc.c
> index fc0ea225c6..e5d1a64b4c 100644
> --- a/libavformat/mpegtsenc.c
> +++ b/libavformat/mpegtsenc.c
> @@ -1815,6 +1815,12 @@ static int mpegts_write_packet(AVFormatContext *s, 
> AVPacket *pkt)
> mpegts_write_flush(s);
> return 1;
> } else {
> +if (s->pb && s->pb->write_data_type) {
> +AVStream *st = s->streams[pkt->stream_index];
> +avio_write_marker(s->pb,
> +av_rescale_q(pkt->dts, st->time_base, AV_TIME_BASE_Q),
> +(pkt->flags & AV_PKT_FLAG_KEY) && st->codecpar->codec_type 
> == AVMEDIA_TYPE_VIDEO ? AVIO_DATA_MARKER_SYNC_POINT : 
> AVIO_DATA_MARKER_BOUNDARY_POINT);
> +}
> return mpegts_write_packet_internal(s, pkt);
> }
> }
> 

So I've created a patch for this.



0001-mpegtsenc-added-support-for-the-write_data_type-call.patch
Description: Binary data
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel


[FFmpeg-devel] [PATCH] avformat/mpegtsenc:

2019-03-06 Thread Oliver Collyer
Hi

I needed to be able to use the write_data_type callback when reading data from 
the mpegts muxer, to make my application aware of key frames in the data so I 
added support. I used the matroska implementation as a reference.

If this is accepted, I will format this as a proper patch after feedback.

Regards

Oliver

diff --git a/libavformat/mpegtsenc.c b/libavformat/mpegtsenc.c
index fc0ea225c6..e5d1a64b4c 100644
--- a/libavformat/mpegtsenc.c
+++ b/libavformat/mpegtsenc.c
@@ -1815,6 +1815,12 @@ static int mpegts_write_packet(AVFormatContext *s, 
AVPacket *pkt)
 mpegts_write_flush(s);
 return 1;
 } else {
+if (s->pb && s->pb->write_data_type) {
+AVStream *st = s->streams[pkt->stream_index];
+avio_write_marker(s->pb,
+av_rescale_q(pkt->dts, st->time_base, AV_TIME_BASE_Q),
+(pkt->flags & AV_PKT_FLAG_KEY) && st->codecpar->codec_type == 
AVMEDIA_TYPE_VIDEO ? AVIO_DATA_MARKER_SYNC_POINT : 
AVIO_DATA_MARKER_BOUNDARY_POINT);
+}
 return mpegts_write_packet_internal(s, pkt);
 }
 }

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] avformat/mpegtsenc: Add option to mark stream begin as discontinuous

2016-11-02 Thread Michael Niedermayer
On Wed, Nov 02, 2016 at 10:31:38PM +0800, Steven Liu wrote:
> 2016-11-02 7:51 GMT+08:00 Michael Niedermayer :
> 
> > This avoids continuity check failures in concatenated streams
> >
> > TODO: docs
> >
> > Signed-off-by: Michael Niedermayer 
> > ---
> >  libavformat/mpegtsenc.c | 26 ++
> >  1 file changed, 26 insertions(+)
> >
> > diff --git a/libavformat/mpegtsenc.c b/libavformat/mpegtsenc.c
> > index 3ad3de7..71a6642 100644
> > --- a/libavformat/mpegtsenc.c
> > +++ b/libavformat/mpegtsenc.c
> > @@ -46,6 +46,7 @@
> >  typedef struct MpegTSSection {
> >  int pid;
> >  int cc;
> > +int discontinuity;
> >  void (*write_packet)(struct MpegTSSection *s, const uint8_t *packet);
> >  void *opaque;
> >  } MpegTSSection;
> > @@ -104,6 +105,7 @@ typedef struct MpegTSWrite {
> >  #define MPEGTS_FLAG_AAC_LATM0x02
> >  #define MPEGTS_FLAG_PAT_PMT_AT_FRAMES   0x04
> >  #define MPEGTS_FLAG_SYSTEM_B0x08
> > +#define MPEGTS_FLAG_DISCONT 0x10
> >  int flags;
> >  int copyts;
> >  int tables_version;
> > @@ -153,6 +155,12 @@ static void mpegts_write_section(MpegTSSection *s,
> > uint8_t *buf, int len)
> >  *q++  = s->pid;
> >  s->cc = s->cc + 1 & 0xf;
> >  *q++  = 0x10 | s->cc;
> > +if (s->discontinuity) {
> > +q[-1] |= 0x20;
> > +*q++ = 1;
> > +*q++ = 0x80;
> > +s->discontinuity = 0;
> > +}
> >  if (first)
> >  *q++ = 0; /* 0 offset */
> >  len1 = TS_PACKET_SIZE - (q - packet);
> > @@ -223,6 +231,7 @@ typedef struct MpegTSWriteStream {
> >  struct MpegTSService *service;
> >  int pid; /* stream associated pid */
> >  int cc;
> > +int discontinuity;
> >  int payload_size;
> >  int first_pts_check; ///< first pts check needed
> >  int prev_payload_key;
> > @@ -782,6 +791,7 @@ static int mpegts_init(AVFormatContext *s)
> >  service->pmt.write_packet = section_write_packet;
> >  service->pmt.opaque   = s;
> >  service->pmt.cc   = 15;
> > +service->pmt.discontinuity= ts->flags & MPEGTS_FLAG_DISCONT;
> >  } else {
> >  for (i = 0; i < s->nb_programs; i++) {
> >  AVProgram *program = s->programs[i];
> > @@ -800,6 +810,7 @@ static int mpegts_init(AVFormatContext *s)
> >  service->pmt.write_packet = section_write_packet;
> >  service->pmt.opaque   = s;
> >  service->pmt.cc   = 15;
> > +service->pmt.discontinuity= ts->flags & MPEGTS_FLAG_DISCONT;
> >  service->program  = program;
> >  }
> >  }
> > @@ -808,11 +819,13 @@ static int mpegts_init(AVFormatContext *s)
> >  /* Initialize at 15 so that it wraps and is equal to 0 for the
> >   * first packet we write. */
> >  ts->pat.cc   = 15;
> > +ts->pat.discontinuity= ts->flags & MPEGTS_FLAG_DISCONT;
> >  ts->pat.write_packet = section_write_packet;
> >  ts->pat.opaque   = s;
> >
> >  ts->sdt.pid  = SDT_PID;
> >  ts->sdt.cc   = 15;
> > +ts->sdt.discontinuity= ts->flags & MPEGTS_FLAG_DISCONT;
> >  ts->sdt.write_packet = section_write_packet;
> >  ts->sdt.opaque   = s;
> >
> > @@ -883,6 +896,7 @@ static int mpegts_init(AVFormatContext *s)
> >  ts_st->payload_dts = AV_NOPTS_VALUE;
> >  ts_st->first_pts_check = 1;
> >  ts_st->cc  = 15;
> > +ts_st->discontinuity   = ts->flags & MPEGTS_FLAG_DISCONT;
> >  /* update PCR pid by using the first video stream */
> >  if (st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO &&
> >  service->pcr_pid == 0x1fff) {
> > @@ -1078,6 +1092,10 @@ static void mpegts_insert_pcr_only(AVFormatContext
> > *s, AVStream *st)
> >  /* Continuity Count field does not increment (see 13818-1 section
> > 2.4.3.3) */
> >  *q++ = TS_PACKET_SIZE - 5; /* Adaptation Field Length */
> >  *q++ = 0x10;   /* Adaptation flags: PCR present */
> > +if (ts_st->discontinuity) {
> > +q[-1] |= 0x80;
> > +ts_st->discontinuity = 0;
> > +}
> >
> >  /* PCR coded into 6 bytes */
> >  q += write_pcr_bits(q, get_pcr(ts, s->pb));
> > @@ -1195,6 +1213,11 @@ static void mpegts_write_pes(AVFormatContext *s,
> > AVStream *st,
> >  *q++  = ts_st->pid;
> >  ts_st->cc = ts_st->cc + 1 & 0xf;
> >  *q++  = 0x10 | ts_st->cc; // payload indicator + CC
> > +if (ts_st->discontinuity) {
> > +set_af_flag(buf, 0x80);
> > +q = get_ts_payload_start(buf);
> > +ts_st->discontinuity = 0;
> > +}
> >  if (key && is_start && pts != AV_NOPTS_VALUE) {
> >  // set Random Access for key frames
> >  if (ts_st->pid == ts_st->service->pcr_pid)
> > @@ -1872,6 +1895,9 @@ static const AVOption options[] = {
> >  { "system_b", "Con

Re: [FFmpeg-devel] [PATCH] avformat/mpegtsenc: Add option to mark stream begin as discontinuous

2016-11-02 Thread Steven Liu
2016-11-02 7:51 GMT+08:00 Michael Niedermayer :

> This avoids continuity check failures in concatenated streams
>
> TODO: docs
>
> Signed-off-by: Michael Niedermayer 
> ---
>  libavformat/mpegtsenc.c | 26 ++
>  1 file changed, 26 insertions(+)
>
> diff --git a/libavformat/mpegtsenc.c b/libavformat/mpegtsenc.c
> index 3ad3de7..71a6642 100644
> --- a/libavformat/mpegtsenc.c
> +++ b/libavformat/mpegtsenc.c
> @@ -46,6 +46,7 @@
>  typedef struct MpegTSSection {
>  int pid;
>  int cc;
> +int discontinuity;
>  void (*write_packet)(struct MpegTSSection *s, const uint8_t *packet);
>  void *opaque;
>  } MpegTSSection;
> @@ -104,6 +105,7 @@ typedef struct MpegTSWrite {
>  #define MPEGTS_FLAG_AAC_LATM0x02
>  #define MPEGTS_FLAG_PAT_PMT_AT_FRAMES   0x04
>  #define MPEGTS_FLAG_SYSTEM_B0x08
> +#define MPEGTS_FLAG_DISCONT 0x10
>  int flags;
>  int copyts;
>  int tables_version;
> @@ -153,6 +155,12 @@ static void mpegts_write_section(MpegTSSection *s,
> uint8_t *buf, int len)
>  *q++  = s->pid;
>  s->cc = s->cc + 1 & 0xf;
>  *q++  = 0x10 | s->cc;
> +if (s->discontinuity) {
> +q[-1] |= 0x20;
> +*q++ = 1;
> +*q++ = 0x80;
> +s->discontinuity = 0;
> +}
>  if (first)
>  *q++ = 0; /* 0 offset */
>  len1 = TS_PACKET_SIZE - (q - packet);
> @@ -223,6 +231,7 @@ typedef struct MpegTSWriteStream {
>  struct MpegTSService *service;
>  int pid; /* stream associated pid */
>  int cc;
> +int discontinuity;
>  int payload_size;
>  int first_pts_check; ///< first pts check needed
>  int prev_payload_key;
> @@ -782,6 +791,7 @@ static int mpegts_init(AVFormatContext *s)
>  service->pmt.write_packet = section_write_packet;
>  service->pmt.opaque   = s;
>  service->pmt.cc   = 15;
> +service->pmt.discontinuity= ts->flags & MPEGTS_FLAG_DISCONT;
>  } else {
>  for (i = 0; i < s->nb_programs; i++) {
>  AVProgram *program = s->programs[i];
> @@ -800,6 +810,7 @@ static int mpegts_init(AVFormatContext *s)
>  service->pmt.write_packet = section_write_packet;
>  service->pmt.opaque   = s;
>  service->pmt.cc   = 15;
> +service->pmt.discontinuity= ts->flags & MPEGTS_FLAG_DISCONT;
>  service->program  = program;
>  }
>  }
> @@ -808,11 +819,13 @@ static int mpegts_init(AVFormatContext *s)
>  /* Initialize at 15 so that it wraps and is equal to 0 for the
>   * first packet we write. */
>  ts->pat.cc   = 15;
> +ts->pat.discontinuity= ts->flags & MPEGTS_FLAG_DISCONT;
>  ts->pat.write_packet = section_write_packet;
>  ts->pat.opaque   = s;
>
>  ts->sdt.pid  = SDT_PID;
>  ts->sdt.cc   = 15;
> +ts->sdt.discontinuity= ts->flags & MPEGTS_FLAG_DISCONT;
>  ts->sdt.write_packet = section_write_packet;
>  ts->sdt.opaque   = s;
>
> @@ -883,6 +896,7 @@ static int mpegts_init(AVFormatContext *s)
>  ts_st->payload_dts = AV_NOPTS_VALUE;
>  ts_st->first_pts_check = 1;
>  ts_st->cc  = 15;
> +ts_st->discontinuity   = ts->flags & MPEGTS_FLAG_DISCONT;
>  /* update PCR pid by using the first video stream */
>  if (st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO &&
>  service->pcr_pid == 0x1fff) {
> @@ -1078,6 +1092,10 @@ static void mpegts_insert_pcr_only(AVFormatContext
> *s, AVStream *st)
>  /* Continuity Count field does not increment (see 13818-1 section
> 2.4.3.3) */
>  *q++ = TS_PACKET_SIZE - 5; /* Adaptation Field Length */
>  *q++ = 0x10;   /* Adaptation flags: PCR present */
> +if (ts_st->discontinuity) {
> +q[-1] |= 0x80;
> +ts_st->discontinuity = 0;
> +}
>
>  /* PCR coded into 6 bytes */
>  q += write_pcr_bits(q, get_pcr(ts, s->pb));
> @@ -1195,6 +1213,11 @@ static void mpegts_write_pes(AVFormatContext *s,
> AVStream *st,
>  *q++  = ts_st->pid;
>  ts_st->cc = ts_st->cc + 1 & 0xf;
>  *q++  = 0x10 | ts_st->cc; // payload indicator + CC
> +if (ts_st->discontinuity) {
> +set_af_flag(buf, 0x80);
> +q = get_ts_payload_start(buf);
> +ts_st->discontinuity = 0;
> +}
>  if (key && is_start && pts != AV_NOPTS_VALUE) {
>  // set Random Access for key frames
>  if (ts_st->pid == ts_st->service->pcr_pid)
> @@ -1872,6 +1895,9 @@ static const AVOption options[] = {
>  { "system_b", "Conform to System B (DVB) instead of System A (ATSC)",
>0, AV_OPT_TYPE_CONST, { .i64 = MPEGTS_FLAG_SYSTEM_B }, 0, INT_MAX,
>AV_OPT_FLAG_ENCODING_PARAM, "mpegts_flags" },
> +{ "initial_discontinuity", "Mark initial packets as discontinuous",
> +  0, AV_OPT_TYPE_CONST, { .i64 = 

[FFmpeg-devel] [PATCH] avformat/mpegtsenc: Add option to mark stream begin as discontinuous

2016-11-01 Thread Michael Niedermayer
This avoids continuity check failures in concatenated streams

TODO: docs

Signed-off-by: Michael Niedermayer 
---
 libavformat/mpegtsenc.c | 26 ++
 1 file changed, 26 insertions(+)

diff --git a/libavformat/mpegtsenc.c b/libavformat/mpegtsenc.c
index 3ad3de7..71a6642 100644
--- a/libavformat/mpegtsenc.c
+++ b/libavformat/mpegtsenc.c
@@ -46,6 +46,7 @@
 typedef struct MpegTSSection {
 int pid;
 int cc;
+int discontinuity;
 void (*write_packet)(struct MpegTSSection *s, const uint8_t *packet);
 void *opaque;
 } MpegTSSection;
@@ -104,6 +105,7 @@ typedef struct MpegTSWrite {
 #define MPEGTS_FLAG_AAC_LATM0x02
 #define MPEGTS_FLAG_PAT_PMT_AT_FRAMES   0x04
 #define MPEGTS_FLAG_SYSTEM_B0x08
+#define MPEGTS_FLAG_DISCONT 0x10
 int flags;
 int copyts;
 int tables_version;
@@ -153,6 +155,12 @@ static void mpegts_write_section(MpegTSSection *s, uint8_t 
*buf, int len)
 *q++  = s->pid;
 s->cc = s->cc + 1 & 0xf;
 *q++  = 0x10 | s->cc;
+if (s->discontinuity) {
+q[-1] |= 0x20;
+*q++ = 1;
+*q++ = 0x80;
+s->discontinuity = 0;
+}
 if (first)
 *q++ = 0; /* 0 offset */
 len1 = TS_PACKET_SIZE - (q - packet);
@@ -223,6 +231,7 @@ typedef struct MpegTSWriteStream {
 struct MpegTSService *service;
 int pid; /* stream associated pid */
 int cc;
+int discontinuity;
 int payload_size;
 int first_pts_check; ///< first pts check needed
 int prev_payload_key;
@@ -782,6 +791,7 @@ static int mpegts_init(AVFormatContext *s)
 service->pmt.write_packet = section_write_packet;
 service->pmt.opaque   = s;
 service->pmt.cc   = 15;
+service->pmt.discontinuity= ts->flags & MPEGTS_FLAG_DISCONT;
 } else {
 for (i = 0; i < s->nb_programs; i++) {
 AVProgram *program = s->programs[i];
@@ -800,6 +810,7 @@ static int mpegts_init(AVFormatContext *s)
 service->pmt.write_packet = section_write_packet;
 service->pmt.opaque   = s;
 service->pmt.cc   = 15;
+service->pmt.discontinuity= ts->flags & MPEGTS_FLAG_DISCONT;
 service->program  = program;
 }
 }
@@ -808,11 +819,13 @@ static int mpegts_init(AVFormatContext *s)
 /* Initialize at 15 so that it wraps and is equal to 0 for the
  * first packet we write. */
 ts->pat.cc   = 15;
+ts->pat.discontinuity= ts->flags & MPEGTS_FLAG_DISCONT;
 ts->pat.write_packet = section_write_packet;
 ts->pat.opaque   = s;
 
 ts->sdt.pid  = SDT_PID;
 ts->sdt.cc   = 15;
+ts->sdt.discontinuity= ts->flags & MPEGTS_FLAG_DISCONT;
 ts->sdt.write_packet = section_write_packet;
 ts->sdt.opaque   = s;
 
@@ -883,6 +896,7 @@ static int mpegts_init(AVFormatContext *s)
 ts_st->payload_dts = AV_NOPTS_VALUE;
 ts_st->first_pts_check = 1;
 ts_st->cc  = 15;
+ts_st->discontinuity   = ts->flags & MPEGTS_FLAG_DISCONT;
 /* update PCR pid by using the first video stream */
 if (st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO &&
 service->pcr_pid == 0x1fff) {
@@ -1078,6 +1092,10 @@ static void mpegts_insert_pcr_only(AVFormatContext *s, 
AVStream *st)
 /* Continuity Count field does not increment (see 13818-1 section 2.4.3.3) 
*/
 *q++ = TS_PACKET_SIZE - 5; /* Adaptation Field Length */
 *q++ = 0x10;   /* Adaptation flags: PCR present */
+if (ts_st->discontinuity) {
+q[-1] |= 0x80;
+ts_st->discontinuity = 0;
+}
 
 /* PCR coded into 6 bytes */
 q += write_pcr_bits(q, get_pcr(ts, s->pb));
@@ -1195,6 +1213,11 @@ static void mpegts_write_pes(AVFormatContext *s, 
AVStream *st,
 *q++  = ts_st->pid;
 ts_st->cc = ts_st->cc + 1 & 0xf;
 *q++  = 0x10 | ts_st->cc; // payload indicator + CC
+if (ts_st->discontinuity) {
+set_af_flag(buf, 0x80);
+q = get_ts_payload_start(buf);
+ts_st->discontinuity = 0;
+}
 if (key && is_start && pts != AV_NOPTS_VALUE) {
 // set Random Access for key frames
 if (ts_st->pid == ts_st->service->pcr_pid)
@@ -1872,6 +1895,9 @@ static const AVOption options[] = {
 { "system_b", "Conform to System B (DVB) instead of System A (ATSC)",
   0, AV_OPT_TYPE_CONST, { .i64 = MPEGTS_FLAG_SYSTEM_B }, 0, INT_MAX,
   AV_OPT_FLAG_ENCODING_PARAM, "mpegts_flags" },
+{ "initial_discontinuity", "Mark initial packets as discontinuous",
+  0, AV_OPT_TYPE_CONST, { .i64 = MPEGTS_FLAG_DISCONT }, 0, INT_MAX,
+  AV_OPT_FLAG_ENCODING_PARAM, "mpegts_flags" },
 // backward compatibility
 { "resend_headers", "Reemit PAT/PMT before writing the next packet",
   offsetof(MpegTSWrite, reemit_pat_pmt), AV_OPT_TYPE_INT,
-- 
2.10.2

__

Re: [FFmpeg-devel] [PATCH] avformat/mpegtsenc: Fix multi program so that it supports adding the same stream to multiple programs.

2016-01-25 Thread Vittorio Gambaletta (VittGam)

Hi,

On 25/01/2016 19:35:58 CET, Michael Niedermayer wrote:

On Sun, Jan 24, 2016 at 03:54:34PM +0100, Vittorio Gambaletta (VittGam) wrote:

Hi,

On 24/01/2016 12:01:38 CET, Michael Niedermayer wrote:
>On Sun, Jan 24, 2016 at 06:06:36AM +0100, Vittorio Gambaletta (VittGam) wrote:
>>Signed-off-by: Vittorio Gambaletta 
>>---
>> libavformat/mpegtsenc.c |   15 +--
>> 1 file changed, 13 insertions(+), 2 deletions(-)
>>
>>diff --git a/libavformat/mpegtsenc.c b/libavformat/mpegtsenc.c
>>index 2c12043..a20e229 100644
>>--- a/libavformat/mpegtsenc.c
>>+++ b/libavformat/mpegtsenc.c
>>@@ -275,8 +275,19 @@ static int mpegts_write_pmt(AVFormatContext *s, 
MpegTSService *service)
>> AVDictionaryEntry *lang = av_dict_get(st->metadata, "language", 
NULL, 0);
>>
>> if (s->nb_programs) {
>>-AVProgram *program = av_find_program_from_stream(s, NULL, i);
>>-if (program->id != service->sid)
>>+int j, k, found = 0;
>>+
>>+for (j = 0; j < s->nb_programs; j++)
>>+if (s->programs[j]->id == service->sid) {
>>+for (k = 0; k < s->programs[j]->nb_stream_indexes; k++)
>>+if (s->programs[j]->stream_index[k] == i) {
>>+found = 1;
>>+break;
>>+}
>>+break;
>>+}
>
>av_find_program_from_stream() should be run in a loop to enumerate
>the programs, see other uses of av_find_program_from_stream()

Wouldn't this solve the problem backwards?


yes, though it would avoid directly accessing the data structs.
no big problem really though, i see the av_find_program_from_stream()
isnt exactly optimal here
so applied

thanks


You're welcome!

Well, if the same logic needs to be reused somewhere else, it could
always be put in a new function, maybe av_check_stream_is_in_program().

Cheers,
Vittorio
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] avformat/mpegtsenc: Fix multi program so that it supports adding the same stream to multiple programs.

2016-01-25 Thread Michael Niedermayer
On Sun, Jan 24, 2016 at 03:54:34PM +0100, Vittorio Gambaletta (VittGam) wrote:
> Hi,
> 
> On 24/01/2016 12:01:38 CET, Michael Niedermayer wrote:
> >On Sun, Jan 24, 2016 at 06:06:36AM +0100, Vittorio Gambaletta (VittGam) 
> >wrote:
> >>Signed-off-by: Vittorio Gambaletta 
> >>---
> >> libavformat/mpegtsenc.c |   15 +--
> >> 1 file changed, 13 insertions(+), 2 deletions(-)
> >>
> >>diff --git a/libavformat/mpegtsenc.c b/libavformat/mpegtsenc.c
> >>index 2c12043..a20e229 100644
> >>--- a/libavformat/mpegtsenc.c
> >>+++ b/libavformat/mpegtsenc.c
> >>@@ -275,8 +275,19 @@ static int mpegts_write_pmt(AVFormatContext *s, 
> >>MpegTSService *service)
> >> AVDictionaryEntry *lang = av_dict_get(st->metadata, "language", 
> >> NULL, 0);
> >>
> >> if (s->nb_programs) {
> >>-AVProgram *program = av_find_program_from_stream(s, NULL, i);
> >>-if (program->id != service->sid)
> >>+int j, k, found = 0;
> >>+
> >>+for (j = 0; j < s->nb_programs; j++)
> >>+if (s->programs[j]->id == service->sid) {
> >>+for (k = 0; k < s->programs[j]->nb_stream_indexes; k++)
> >>+if (s->programs[j]->stream_index[k] == i) {
> >>+found = 1;
> >>+break;
> >>+}
> >>+break;
> >>+}
> >
> >av_find_program_from_stream() should be run in a loop to enumerate
> >the programs, see other uses of av_find_program_from_stream()
> 
> Wouldn't this solve the problem backwards?

yes, though it would avoid directly accessing the data structs.
no big problem really though, i see the av_find_program_from_stream()
isnt exactly optimal here
so applied

thanks

[...]
-- 
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

I have often repented speaking, but never of holding my tongue.
-- Xenocrates


signature.asc
Description: Digital signature
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] avformat/mpegtsenc: Fix multi program so that it supports adding the same stream to multiple programs.

2016-01-24 Thread Vittorio Gambaletta (VittGam)

Hi,

On 24/01/2016 12:01:38 CET, Michael Niedermayer wrote:

On Sun, Jan 24, 2016 at 06:06:36AM +0100, Vittorio Gambaletta (VittGam) wrote:

Signed-off-by: Vittorio Gambaletta 
---
 libavformat/mpegtsenc.c |   15 +--
 1 file changed, 13 insertions(+), 2 deletions(-)

diff --git a/libavformat/mpegtsenc.c b/libavformat/mpegtsenc.c
index 2c12043..a20e229 100644
--- a/libavformat/mpegtsenc.c
+++ b/libavformat/mpegtsenc.c
@@ -275,8 +275,19 @@ static int mpegts_write_pmt(AVFormatContext *s, 
MpegTSService *service)
 AVDictionaryEntry *lang = av_dict_get(st->metadata, "language", NULL, 
0);

 if (s->nb_programs) {
-AVProgram *program = av_find_program_from_stream(s, NULL, i);
-if (program->id != service->sid)
+int j, k, found = 0;
+
+for (j = 0; j < s->nb_programs; j++)
+if (s->programs[j]->id == service->sid) {
+for (k = 0; k < s->programs[j]->nb_stream_indexes; k++)
+if (s->programs[j]->stream_index[k] == i) {
+found = 1;
+break;
+}
+break;
+}


av_find_program_from_stream() should be run in a loop to enumerate
the programs, see other uses of av_find_program_from_stream()


Wouldn't this solve the problem backwards?

We need to search the program that has the same ID as the service
being evaluated, and then we search that program for the stream with
the same ID as the stream being evaluated. My code does that.

av_find_program_from_stream() instead enumerates every stream in every
program (starting from `last`) until it finds a stream with the same ID
as the stream being searched, so every time it returns a different
program ID. In fact it is used to update every program that contain
a certain stream, not the reverse.

Cheers,
Vittorio
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] avformat/mpegtsenc: Fix multi program so that it supports adding the same stream to multiple programs.

2016-01-24 Thread Michael Niedermayer
On Sun, Jan 24, 2016 at 06:06:36AM +0100, Vittorio Gambaletta (VittGam) wrote:
> Signed-off-by: Vittorio Gambaletta 
> ---
>  libavformat/mpegtsenc.c |   15 +--
>  1 file changed, 13 insertions(+), 2 deletions(-)
> 
> diff --git a/libavformat/mpegtsenc.c b/libavformat/mpegtsenc.c
> index 2c12043..a20e229 100644
> --- a/libavformat/mpegtsenc.c
> +++ b/libavformat/mpegtsenc.c
> @@ -275,8 +275,19 @@ static int mpegts_write_pmt(AVFormatContext *s, 
> MpegTSService *service)
>  AVDictionaryEntry *lang = av_dict_get(st->metadata, "language", 
> NULL, 0);
>  
>  if (s->nb_programs) {
> -AVProgram *program = av_find_program_from_stream(s, NULL, i);
> -if (program->id != service->sid)
> +int j, k, found = 0;
> +
> +for (j = 0; j < s->nb_programs; j++)
> +if (s->programs[j]->id == service->sid) {
> +for (k = 0; k < s->programs[j]->nb_stream_indexes; k++)
> +if (s->programs[j]->stream_index[k] == i) {
> +found = 1;
> +break;
> +}
> +break;
> +}

av_find_program_from_stream() should be run in a loop to enumerate
the programs, see other uses of av_find_program_from_stream()

[...]

-- 
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Rewriting code that is poorly written but fully understood is good.
Rewriting code that one doesnt understand is a sign that one is less smart
then the original author, trying to rewrite it will not make it better.


signature.asc
Description: Digital signature
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


[FFmpeg-devel] [PATCH] avformat/mpegtsenc: Fix multi program so that it supports adding the same stream to multiple programs.

2016-01-23 Thread Vittorio Gambaletta (VittGam)
Signed-off-by: Vittorio Gambaletta 
---
 libavformat/mpegtsenc.c |   15 +--
 1 file changed, 13 insertions(+), 2 deletions(-)

diff --git a/libavformat/mpegtsenc.c b/libavformat/mpegtsenc.c
index 2c12043..a20e229 100644
--- a/libavformat/mpegtsenc.c
+++ b/libavformat/mpegtsenc.c
@@ -275,8 +275,19 @@ static int mpegts_write_pmt(AVFormatContext *s, 
MpegTSService *service)
 AVDictionaryEntry *lang = av_dict_get(st->metadata, "language", NULL, 
0);
 
 if (s->nb_programs) {
-AVProgram *program = av_find_program_from_stream(s, NULL, i);
-if (program->id != service->sid)
+int j, k, found = 0;
+
+for (j = 0; j < s->nb_programs; j++)
+if (s->programs[j]->id == service->sid) {
+for (k = 0; k < s->programs[j]->nb_stream_indexes; k++)
+if (s->programs[j]->stream_index[k] == i) {
+found = 1;
+break;
+}
+break;
+}
+
+if (!found)
 continue;
 }
 
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] avformat/mpegtsenc: add flag to embed an AC-3/E-AC-3 ES the DVB way

2015-12-23 Thread Michael Niedermayer
On Sun, Dec 13, 2015 at 11:54:32AM +0100, Stefan Pöschel wrote:
> So far an AC-3 elementary stream is refered to in the PMT according to
> System A (ATSC). An E-AC-3 ES in contrast is embedded the System B (DVB) way.
> To fix this inconsistency, this commit changes the default E-AC-3 behaviour to
> use the ATSC way, too. Furthermore a new flag is added to optionally select 
> the
> DVB way (regarding both codecs and possible further differences in the 
> future).
> ---
>  libavformat/mpegts.h|  1 +
>  libavformat/mpegtsenc.c | 20 ++--
>  2 files changed, 19 insertions(+), 2 deletions(-)

patch applied

please also send one to update the docs

thanks

[...]
-- 
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

The real ebay dictionary, page 2
"100% positive feedback" - "All either got their money back or didnt complain"
"Best seller ever, very honest" - "Seller refunded buyer after failed scam"


signature.asc
Description: Digital signature
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] avformat/mpegtsenc: add flag to embed an AC-3/E-AC-3 ES the DVB way

2015-12-23 Thread Stefan Pöschel
Just wanted to ask if there is any further information needed regarding my 
patch.

> Gesendet: Sonntag, 13. Dezember 2015 um 11:54 Uhr
> Von: "Stefan Pöschel" 
> An: ffmpeg-devel@ffmpeg.org
> Betreff: [FFmpeg-devel] [PATCH] avformat/mpegtsenc: add flag to embed an 
> AC-3/E-AC-3 ES the DVB way
>
> So far an AC-3 elementary stream is refered to in the PMT according to
> System A (ATSC). An E-AC-3 ES in contrast is embedded the System B (DVB) way.
> To fix this inconsistency, this commit changes the default E-AC-3 behaviour to
> use the ATSC way, too. Furthermore a new flag is added to optionally select 
> the
> DVB way (regarding both codecs and possible further differences in the 
> future).
> ---
>  libavformat/mpegts.h|  1 +
>  libavformat/mpegtsenc.c | 20 ++--
>  2 files changed, 19 insertions(+), 2 deletions(-)
> 
> diff --git a/libavformat/mpegts.h b/libavformat/mpegts.h
> index 84f3098..0cdbc76 100644
> --- a/libavformat/mpegts.h
> +++ b/libavformat/mpegts.h
> @@ -60,6 +60,7 @@
>  #define STREAM_TYPE_AUDIO_AC3   0x81
>  #define STREAM_TYPE_AUDIO_DTS   0x82
>  #define STREAM_TYPE_AUDIO_TRUEHD0x83
> +#define STREAM_TYPE_AUDIO_EAC3  0x87
> 
>  typedef struct MpegTSContext MpegTSContext;
> 
> diff --git a/libavformat/mpegtsenc.c b/libavformat/mpegtsenc.c
> index 19032f3..cb11c31 100644
> --- a/libavformat/mpegtsenc.c
> +++ b/libavformat/mpegtsenc.c
> @@ -99,6 +99,7 @@ typedef struct MpegTSWrite {
>  #define MPEGTS_FLAG_REEMIT_PAT_PMT  0x01
>  #define MPEGTS_FLAG_AAC_LATM0x02
>  #define MPEGTS_FLAG_PAT_PMT_AT_FRAMES   0x04
> +#define MPEGTS_FLAG_SYSTEM_B0x08
>  int flags;
>  int copyts;
>  int tables_version;
> @@ -319,7 +320,14 @@ static int mpegts_write_pmt(AVFormatContext *s, 
> MpegTSService *service)
>  stream_type = STREAM_TYPE_AUDIO_AAC_LATM;
>  break;
>  case AV_CODEC_ID_AC3:
> -stream_type = STREAM_TYPE_AUDIO_AC3;
> +stream_type = (ts->flags & MPEGTS_FLAG_SYSTEM_B)
> +  ? STREAM_TYPE_PRIVATE_DATA
> +  : STREAM_TYPE_AUDIO_AC3;
> +break;
> +case AV_CODEC_ID_EAC3:
> +stream_type = (ts->flags & MPEGTS_FLAG_SYSTEM_B)
> +  ? STREAM_TYPE_PRIVATE_DATA
> +  : STREAM_TYPE_AUDIO_EAC3;
>  break;
>  case AV_CODEC_ID_DTS:
>  stream_type = STREAM_TYPE_AUDIO_DTS;
> @@ -343,7 +351,12 @@ static int mpegts_write_pmt(AVFormatContext *s, 
> MpegTSService *service)
>  /* write optional descriptors here */
>  switch (st->codec->codec_type) {
>  case AVMEDIA_TYPE_AUDIO:
> -if (st->codec->codec_id==AV_CODEC_ID_EAC3) {
> +if (st->codec->codec_id==AV_CODEC_ID_AC3 && (ts->flags & 
> MPEGTS_FLAG_SYSTEM_B)) {
> +*q++=0x6a; // AC3 descriptor see A038 DVB SI
> +*q++=1; // 1 byte, all flags sets to 0
> +*q++=0; // omit all fields...
> +}
> +if (st->codec->codec_id==AV_CODEC_ID_EAC3 && (ts->flags & 
> MPEGTS_FLAG_SYSTEM_B)) {
>  *q++=0x7a; // EAC3 descriptor see A038 DVB SI
>  *q++=1; // 1 byte, all flags sets to 0
>  *q++=0; // omit all fields...
> @@ -1790,6 +1803,9 @@ static const AVOption options[] = {
>  { "pat_pmt_at_frames", "Reemit PAT and PMT at each video frame",
>0, AV_OPT_TYPE_CONST, { .i64 = MPEGTS_FLAG_PAT_PMT_AT_FRAMES}, 0, 
> INT_MAX,
>AV_OPT_FLAG_ENCODING_PARAM, "mpegts_flags" },
> +{ "system_b", "Conform to System B (DVB) instead of System A (ATSC)",
> +  0, AV_OPT_TYPE_CONST, { .i64 = MPEGTS_FLAG_SYSTEM_B }, 0, INT_MAX,
> +  AV_OPT_FLAG_ENCODING_PARAM, "mpegts_flags" },
>  // backward compatibility
>  { "resend_headers", "Reemit PAT/PMT before writing the next packet",
>offsetof(MpegTSWrite, reemit_pat_pmt), AV_OPT_TYPE_INT,
> -- 
> 2.6.4
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] avformat/mpegtsenc: add flag to embed an AC-3/E-AC-3 ES the DVB way

2015-12-17 Thread Stefan Pöschel
*bump*

Am 13.12.2015 um 15:23 schrieb Stefan Pöschel:
> Am 13.12.2015 um 14:18 schrieb Moritz Barsnick:
>> On Sun, Dec 13, 2015 at 11:54:32 +0100, Stefan Pöschel wrote:
>>> So far an AC-3 elementary stream is refered to in the PMT according to
>>> System A (ATSC). An E-AC-3 ES in contrast is embedded the System B (DVB) 
>>> way.
>>
>> Interesting, that's apparently the reason why my (DVB-)PVR didn't ever
>> recognize AC-3 in MPEG-TS. See
>> https://ffmpeg.org/pipermail/ffmpeg-user/2015-October/028812.html
>> E-AC-3 in MPEG-TS seems to have worked (I just tried it - successfully
>> - for the first time), I didn't realize that.
>>
>> With your patch, I can now successfully play AC-3 and E-AC-3 with that
>> player, when using the "-mpegts_flags system_b" (and kill this
>> capability when not using it).
> 
> I've had the same problem which was the motivation to take a look into it.
> 
>>> To fix this inconsistency, this commit changes the default E-AC-3 behaviour 
>>> to
>>> use the ATSC way, too. Furthermore a new flag is added to optionally select 
>>> the
>>> DVB way (regarding both codecs and possible further differences in the 
>>> future).
>>
>> I never found the patch mentioned in the thread, and don't know enough
>> about the differences myself.
> 
> There is a bug report of libav regarding this problem, together with a
> patch from 2011 which just changes the AC-3 signalling from ATSC to DVB:
> https://bugzilla.libav.org/show_bug.cgi?id=73
> 
> Yesterday I therefore posted a patch to libav-devel (similar to this one
> for FFmpeg-devel) for switching between ATSC and DVB:
> https://lists.libav.org/pipermail/libav-devel/2015-December/073574.html
> 
> Regards,
>   Stefan
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
> 
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] avformat/mpegtsenc: add flag to embed an AC-3/E-AC-3 ES the DVB way

2015-12-13 Thread Stefan Pöschel
Am 13.12.2015 um 14:18 schrieb Moritz Barsnick:
> On Sun, Dec 13, 2015 at 11:54:32 +0100, Stefan Pöschel wrote:
>> So far an AC-3 elementary stream is refered to in the PMT according to
>> System A (ATSC). An E-AC-3 ES in contrast is embedded the System B (DVB) way.
> 
> Interesting, that's apparently the reason why my (DVB-)PVR didn't ever
> recognize AC-3 in MPEG-TS. See
> https://ffmpeg.org/pipermail/ffmpeg-user/2015-October/028812.html
> E-AC-3 in MPEG-TS seems to have worked (I just tried it - successfully
> - for the first time), I didn't realize that.
> 
> With your patch, I can now successfully play AC-3 and E-AC-3 with that
> player, when using the "-mpegts_flags system_b" (and kill this
> capability when not using it).

I've had the same problem which was the motivation to take a look into it.

>> To fix this inconsistency, this commit changes the default E-AC-3 behaviour 
>> to
>> use the ATSC way, too. Furthermore a new flag is added to optionally select 
>> the
>> DVB way (regarding both codecs and possible further differences in the 
>> future).
> 
> I never found the patch mentioned in the thread, and don't know enough
> about the differences myself.

There is a bug report of libav regarding this problem, together with a
patch from 2011 which just changes the AC-3 signalling from ATSC to DVB:
https://bugzilla.libav.org/show_bug.cgi?id=73

Yesterday I therefore posted a patch to libav-devel (similar to this one
for FFmpeg-devel) for switching between ATSC and DVB:
https://lists.libav.org/pipermail/libav-devel/2015-December/073574.html

Regards,
Stefan
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] avformat/mpegtsenc: add flag to embed an AC-3/E-AC-3 ES the DVB way

2015-12-13 Thread Moritz Barsnick
On Sun, Dec 13, 2015 at 11:54:32 +0100, Stefan Pöschel wrote:
> So far an AC-3 elementary stream is refered to in the PMT according to
> System A (ATSC). An E-AC-3 ES in contrast is embedded the System B (DVB) way.

Interesting, that's apparently the reason why my (DVB-)PVR didn't ever
recognize AC-3 in MPEG-TS. See
https://ffmpeg.org/pipermail/ffmpeg-user/2015-October/028812.html
E-AC-3 in MPEG-TS seems to have worked (I just tried it - successfully
- for the first time), I didn't realize that.

With your patch, I can now successfully play AC-3 and E-AC-3 with that
player, when using the "-mpegts_flags system_b" (and kill this
capability when not using it).

> To fix this inconsistency, this commit changes the default E-AC-3 behaviour to
> use the ATSC way, too. Furthermore a new flag is added to optionally select 
> the
> DVB way (regarding both codecs and possible further differences in the 
> future).

I never found the patch mentioned in the thread, and don't know enough
about the differences myself.

Moritz
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


[FFmpeg-devel] [PATCH] avformat/mpegtsenc: add flag to embed an AC-3/E-AC-3 ES the DVB way

2015-12-13 Thread Stefan Pöschel
So far an AC-3 elementary stream is refered to in the PMT according to
System A (ATSC). An E-AC-3 ES in contrast is embedded the System B (DVB) way.
To fix this inconsistency, this commit changes the default E-AC-3 behaviour to
use the ATSC way, too. Furthermore a new flag is added to optionally select the
DVB way (regarding both codecs and possible further differences in the future).
---
 libavformat/mpegts.h|  1 +
 libavformat/mpegtsenc.c | 20 ++--
 2 files changed, 19 insertions(+), 2 deletions(-)

diff --git a/libavformat/mpegts.h b/libavformat/mpegts.h
index 84f3098..0cdbc76 100644
--- a/libavformat/mpegts.h
+++ b/libavformat/mpegts.h
@@ -60,6 +60,7 @@
 #define STREAM_TYPE_AUDIO_AC3   0x81
 #define STREAM_TYPE_AUDIO_DTS   0x82
 #define STREAM_TYPE_AUDIO_TRUEHD0x83
+#define STREAM_TYPE_AUDIO_EAC3  0x87

 typedef struct MpegTSContext MpegTSContext;

diff --git a/libavformat/mpegtsenc.c b/libavformat/mpegtsenc.c
index 19032f3..cb11c31 100644
--- a/libavformat/mpegtsenc.c
+++ b/libavformat/mpegtsenc.c
@@ -99,6 +99,7 @@ typedef struct MpegTSWrite {
 #define MPEGTS_FLAG_REEMIT_PAT_PMT  0x01
 #define MPEGTS_FLAG_AAC_LATM0x02
 #define MPEGTS_FLAG_PAT_PMT_AT_FRAMES   0x04
+#define MPEGTS_FLAG_SYSTEM_B0x08
 int flags;
 int copyts;
 int tables_version;
@@ -319,7 +320,14 @@ static int mpegts_write_pmt(AVFormatContext *s, 
MpegTSService *service)
 stream_type = STREAM_TYPE_AUDIO_AAC_LATM;
 break;
 case AV_CODEC_ID_AC3:
-stream_type = STREAM_TYPE_AUDIO_AC3;
+stream_type = (ts->flags & MPEGTS_FLAG_SYSTEM_B)
+  ? STREAM_TYPE_PRIVATE_DATA
+  : STREAM_TYPE_AUDIO_AC3;
+break;
+case AV_CODEC_ID_EAC3:
+stream_type = (ts->flags & MPEGTS_FLAG_SYSTEM_B)
+  ? STREAM_TYPE_PRIVATE_DATA
+  : STREAM_TYPE_AUDIO_EAC3;
 break;
 case AV_CODEC_ID_DTS:
 stream_type = STREAM_TYPE_AUDIO_DTS;
@@ -343,7 +351,12 @@ static int mpegts_write_pmt(AVFormatContext *s, 
MpegTSService *service)
 /* write optional descriptors here */
 switch (st->codec->codec_type) {
 case AVMEDIA_TYPE_AUDIO:
-if (st->codec->codec_id==AV_CODEC_ID_EAC3) {
+if (st->codec->codec_id==AV_CODEC_ID_AC3 && (ts->flags & 
MPEGTS_FLAG_SYSTEM_B)) {
+*q++=0x6a; // AC3 descriptor see A038 DVB SI
+*q++=1; // 1 byte, all flags sets to 0
+*q++=0; // omit all fields...
+}
+if (st->codec->codec_id==AV_CODEC_ID_EAC3 && (ts->flags & 
MPEGTS_FLAG_SYSTEM_B)) {
 *q++=0x7a; // EAC3 descriptor see A038 DVB SI
 *q++=1; // 1 byte, all flags sets to 0
 *q++=0; // omit all fields...
@@ -1790,6 +1803,9 @@ static const AVOption options[] = {
 { "pat_pmt_at_frames", "Reemit PAT and PMT at each video frame",
   0, AV_OPT_TYPE_CONST, { .i64 = MPEGTS_FLAG_PAT_PMT_AT_FRAMES}, 0, 
INT_MAX,
   AV_OPT_FLAG_ENCODING_PARAM, "mpegts_flags" },
+{ "system_b", "Conform to System B (DVB) instead of System A (ATSC)",
+  0, AV_OPT_TYPE_CONST, { .i64 = MPEGTS_FLAG_SYSTEM_B }, 0, INT_MAX,
+  AV_OPT_FLAG_ENCODING_PARAM, "mpegts_flags" },
 // backward compatibility
 { "resend_headers", "Reemit PAT/PMT before writing the next packet",
   offsetof(MpegTSWrite, reemit_pat_pmt), AV_OPT_TYPE_INT,
-- 
2.6.4
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] avformat/mpegtsenc: Support a user specified PAT/PMT period

2015-07-18 Thread Michael Niedermayer
On Thu, Jul 16, 2015 at 12:56:55PM +0200, Michael Niedermayer wrote:
> From: Michael Niedermayer 
> 
> Can be used to fix Ticket3714
> 
> TODO, add docs

added docs

applied

[...]
-- 
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

When the tyrant has disposed of foreign enemies by conquest or treaty, and
there is nothing more to fear from them, then he is always stirring up
some war or other, in order that the people may require a leader. -- Plato


signature.asc
Description: Digital signature
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


[FFmpeg-devel] [PATCH] avformat/mpegtsenc: Support a user specified PAT/PMT period

2015-07-16 Thread Michael Niedermayer
From: Michael Niedermayer 

Can be used to fix Ticket3714

TODO, add docs

Signed-off-by: Michael Niedermayer 
---
 libavformat/mpegtsenc.c |   22 +++---
 1 file changed, 19 insertions(+), 3 deletions(-)

diff --git a/libavformat/mpegtsenc.c b/libavformat/mpegtsenc.c
index 7fc717c..914a732 100644
--- a/libavformat/mpegtsenc.c
+++ b/libavformat/mpegtsenc.c
@@ -102,6 +102,8 @@ typedef struct MpegTSWrite {
 int flags;
 int copyts;
 int tables_version;
+float pat_period;
+int64_t last_pat_ts;
 
 int omit_video_pes_length;
 } MpegTSWrite;
@@ -784,6 +786,12 @@ static int mpegts_write_header(AVFormatContext *s)
 service->pcr_packet_period = 1;
 }
 
+ts->last_pat_ts = AV_NOPTS_VALUE;
+// The user specified a period, use only it
+if (ts->pat_period < INT_MAX/2) {
+ts->pat_packet_period = INT_MAX;
+}
+
 // output a PCR as soon as possible
 service->pcr_packet_count = service->pcr_packet_period;
 ts->pat_packet_count  = ts->pat_packet_period - 1;
@@ -834,7 +842,7 @@ fail:
 }
 
 /* send SDT, PAT and PMT tables regulary */
-static void retransmit_si_info(AVFormatContext *s, int force_pat)
+static void retransmit_si_info(AVFormatContext *s, int force_pat, int64_t dts)
 {
 MpegTSWrite *ts = s->priv_data;
 int i;
@@ -843,8 +851,13 @@ static void retransmit_si_info(AVFormatContext *s, int 
force_pat)
 ts->sdt_packet_count = 0;
 mpegts_write_sdt(s);
 }
-if (++ts->pat_packet_count == ts->pat_packet_period || force_pat) {
+if (++ts->pat_packet_count == ts->pat_packet_period ||
+(dts != AV_NOPTS_VALUE && ts->last_pat_ts == AV_NOPTS_VALUE) ||
+(dts != AV_NOPTS_VALUE && dts - ts->last_pat_ts >= 
ts->pat_period*9.0) ||
+force_pat) {
 ts->pat_packet_count = 0;
+if (dts != AV_NOPTS_VALUE)
+ts->last_pat_ts = FFMAX(dts, ts->last_pat_ts);
 mpegts_write_pat(s);
 for (i = 0; i < ts->nb_services; i++)
 mpegts_write_pmt(s, ts->services[i]);
@@ -979,7 +992,7 @@ static void mpegts_write_pes(AVFormatContext *s, AVStream 
*st,
 
 is_start = 1;
 while (payload_size > 0) {
-retransmit_si_info(s, force_pat);
+retransmit_si_info(s, force_pat, dts);
 force_pat = 0;
 
 write_pcr = 0;
@@ -1530,6 +1543,9 @@ static const AVOption options[] = {
 { "pcr_period", "PCR retransmission time",
   offsetof(MpegTSWrite, pcr_period), AV_OPT_TYPE_INT,
   { .i64 = PCR_RETRANS_TIME }, 0, INT_MAX, AV_OPT_FLAG_ENCODING_PARAM },
+{ "pat_period", "PAT/PMT retransmission time limit in seconds",
+  offsetof(MpegTSWrite, pat_period), AV_OPT_TYPE_FLOAT,
+  { .dbl = INT_MAX }, 0, INT_MAX, AV_OPT_FLAG_ENCODING_PARAM },
 { NULL },
 };
 
-- 
1.7.9.5

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] avformat/mpegtsenc: Fix build with msvc

2015-02-03 Thread Michael Niedermayer
On Wed, Feb 04, 2015 at 12:49:39AM +1100, Matt Oliver wrote:
> A recent commit has broken msvc compilation.
> http://fate.ffmpeg.org/report.cgi?time=20150203090035&slot=x86_32-msvc12-windows-native
> 
> Attached is the corresponding fix.

>  mpegtsenc.c |   20 ++--
>  1 file changed, 10 insertions(+), 10 deletions(-)
> 584c40aa7efb3fbdc2d114bdf41b279a229d5c6b  
> avformat-mpegtsenc-Fix-build-with-msvc.patch
> From 06430e9c889461ff92116018580296b815f87a24 Mon Sep 17 00:00:00 2001
> From: Matt Oliver 
> Date: Wed, 4 Feb 2015 00:46:39 +1100
> Subject: [PATCH] avformat/mpegtsenc: Fix build with msvc

applied

thanks

[...]

-- 
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

During times of universal deceit, telling the truth becomes a
revolutionary act. -- George Orwell


signature.asc
Description: Digital signature
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


[FFmpeg-devel] [PATCH] avformat/mpegtsenc: Fix build with msvc

2015-02-03 Thread Matt Oliver
A recent commit has broken msvc compilation.
http://fate.ffmpeg.org/report.cgi?time=20150203090035&slot=x86_32-msvc12-windows-native

Attached is the corresponding fix.


avformat-mpegtsenc-Fix-build-with-msvc.patch
Description: Binary data
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] avformat/mpegtsenc: add an option to disable first PTS check.

2014-10-24 Thread Michael Niedermayer
On Fri, Oct 24, 2014 at 04:47:51PM +0200, Nicolas George wrote:
> Le tridi 3 brumaire, an CCXXIII, Benoit Fouet a écrit :
> > Fixes ticket #1598
> > ---
> >  libavformat/mpegtsenc.c | 6 +-
> >  1 file changed, 5 insertions(+), 1 deletion(-)
> 
> Are the produced files valid? If they are, why do the test at all? If they
> are not, can this be considered actually a fix for the issue?

its allowed to have some timestamps missing in TS under some
circumstances. so it might be possible to generate a valid file
with the first pts missing (i dont know for sure, id have to check the
spec) also iam not sure what our muxer makes out of that case.
Its certainly better to have valid timestamps on the muxer input
on all frames and let the muxer decide which to store in the file
and which to ommit
calculating valid timestamps for h264/hevc input that ommits some is
not entirely trivial though

[...]

-- 
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

During times of universal deceit, telling the truth becomes a
revolutionary act. -- George Orwell


signature.asc
Description: Digital signature
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] avformat/mpegtsenc: add an option to disable first PTS check.

2014-10-24 Thread Benoit Fouet
Hi,

Le 24/10/2014 16:47, Nicolas George a écrit :
> Le tridi 3 brumaire, an CCXXIII, Benoit Fouet a écrit :
>> Fixes ticket #1598
>> ---
>>  libavformat/mpegtsenc.c | 6 +-
>>  1 file changed, 5 insertions(+), 1 deletion(-)
> Are the produced files valid? If they are, why do the test at all? If they
> are not, can this be considered actually a fix for the issue?

This was just a shot in the dark from a real quick look at the issue.
ffplay is able to play the file (with a warning on pts though), but I
don't think the files are valid.
I think I'll spend some more time on all this end of next week,
specifically on the genpts thing, as this would seem a valid way to be
able to remux the raw h264 files.

> I believe the commit message should at least spare a few words to explain.

I believe I could have refrained from sending this patch in the first
place, as my gut feeling is that it does not fix anything in the first
place.
Thanks,

-- 
Ben

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] avformat/mpegtsenc: add an option to disable first PTS check.

2014-10-24 Thread Nicolas George
Le tridi 3 brumaire, an CCXXIII, Benoit Fouet a écrit :
> Fixes ticket #1598
> ---
>  libavformat/mpegtsenc.c | 6 +-
>  1 file changed, 5 insertions(+), 1 deletion(-)

Are the produced files valid? If they are, why do the test at all? If they
are not, can this be considered actually a fix for the issue?

I believe the commit message should at least spare a few words to explain.

Regards,

-- 
  Nicolas George


signature.asc
Description: Digital signature
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


[FFmpeg-devel] [PATCH] avformat/mpegtsenc: add an option to disable first PTS check.

2014-10-24 Thread Benoit Fouet
Fixes ticket #1598
---
 libavformat/mpegtsenc.c | 6 +-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/libavformat/mpegtsenc.c b/libavformat/mpegtsenc.c
index d73b75f..74541d1 100644
--- a/libavformat/mpegtsenc.c
+++ b/libavformat/mpegtsenc.c
@@ -91,6 +91,7 @@ typedef struct MpegTSWrite {
 int tables_version;
 
 int omit_video_pes_length;
+int first_pts_check;
 } MpegTSWrite;
 
 /* a PES packet header is generated every DEFAULT_PES_HEADER_FREQ packets */
@@ -691,7 +692,7 @@ static int mpegts_write_header(AVFormatContext *s)
 pids[i]= ts_st->pid;
 ts_st->payload_pts = AV_NOPTS_VALUE;
 ts_st->payload_dts = AV_NOPTS_VALUE;
-ts_st->first_pts_check = 1;
+ts_st->first_pts_check = ts->first_pts_check;
 ts_st->cc  = 15;
 /* update PCR pid by using the first video stream */
 if (st->codec->codec_type == AVMEDIA_TYPE_VIDEO &&
@@ -1473,6 +1474,9 @@ static const AVOption options[] = {
 { "pcr_period", "PCR retransmission time",
   offsetof(MpegTSWrite, pcr_period), AV_OPT_TYPE_INT,
   { .i64 = PCR_RETRANS_TIME }, 0, INT_MAX, AV_OPT_FLAG_ENCODING_PARAM },
+{ "first_pts_check", "Check the first PTS value to be valid.",
+  offsetof(MpegTSWrite, first_pts_check), AV_OPT_TYPE_INT,
+  { .i64 = 1 }, 0, 1, AV_OPT_FLAG_ENCODING_PARAM },
 { NULL },
 };
 
-- 
2.1.2.532.g19b5d50

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel