[FFmpeg-devel] [PATCH] libavformat/mpegtsenc: allow to set service_type in sdt
dhead666
myfoolishgames at gmail.com
Sun Feb 1 18:12:17 CET 2015
---
patch updated with documentation.
also added what seems to me the most useful service types from en-300-468 ( http://www.etsi.org/deliver/etsi_en/300400_300499/300468/01.11.01_60/en_300468v011101p.pdf ).
I can drop them and leave only digital_tv and digital_radio but if we follow the standard these are only for mpeg2 sdtv and mpeg1 audio layer2,
though it seems like at least some broadcasters doesn't follow the standard and for example in tvheadend only 0x02x is recognized as radio (see tvheadend/src/input/mpegts/dvb_psi.c).
doc/muxers.texi | 24 ++++++++++++++++++++++++
libavformat/mpegtsenc.c | 37 ++++++++++++++++++++++++++++++++++++-
2 files changed, 60 insertions(+), 1 deletion(-)
diff --git a/doc/muxers.texi b/doc/muxers.texi
index 7ca6409..9fed9f2 100644
--- a/doc/muxers.texi
+++ b/doc/muxers.texi
@@ -690,6 +690,9 @@ Set the transport_stream_id (default 0x0001). This identifies a
transponder in DVB.
@item -mpegts_service_id @var{number}
Set the service_id (default 0x0001) also known as program in DVB.
+ at item -mpegts_service_type @var{number}
+Set the program service_type (default @var{digital_tv}), see below
+a list of pre defined values.
@item -mpegts_pmt_start_pid @var{number}
Set the first PID for PMT (default 0x1000, max 0x1f00).
@item -mpegts_start_pid @var{number}
@@ -724,6 +727,27 @@ ffmpeg -i source2.ts -codec copy -f mpegts -tables_version 1 udp://1.1.1.1:1111
@end example
@end table
+Option mpegts_service_type accepts the following values:
+
+ at table @option
+ at item hex_value
+Any hexdecimal value between 0x01 to 0xff as defined in ETSI 300 468.
+ at item digital_tv
+Digital TV service.
+ at item digital_radio
+Digital Radio service.
+ at item teletext
+Teletext service.
+ at item advanced_codec_digital_radio
+Advanced Codec Digital Radio service.
+ at item mpeg2_digital_hdtv
+MPEG2 Digital HDTV service.
+ at item advanced_codec_digital_sdtv
+Advanced Codec Digital SDTV service.
+ at item advanced_codec_digital_hdtv
+Advanced Codec Digital HDTV service.
+ at end table
+
Option mpegts_flags may take a set of such flags:
@table @option
diff --git a/libavformat/mpegtsenc.c b/libavformat/mpegtsenc.c
index 8d0da0b..46ff522 100644
--- a/libavformat/mpegtsenc.c
+++ b/libavformat/mpegtsenc.c
@@ -76,6 +76,17 @@ typedef struct MpegTSWrite {
int transport_stream_id;
int original_network_id;
int service_id;
+ int service_type;
+// service_type values as defined in ETSI 300 468
+ enum {
+ MPEGTS_SERVICE_TYPE_DIGITAL_TV = 0x01,
+ MPEGTS_SERVICE_TYPE_DIGITAL_RADIO = 0x02,
+ MPEGTS_SERVICE_TYPE_TELETEXT = 0x03,
+ MPEGTS_SERVICE_TYPE_ADVANCED_CODEC_DIGITAL_RADIO = 0x0A,
+ MPEGTS_SERVICE_TYPE_MPEG2_DIGITAL_HDTV = 0x11,
+ MPEGTS_SERVICE_TYPE_ADVANCED_CODEC_DIGITAL_SDTV = 0x16,
+ MPEGTS_SERVICE_TYPE_ADVANCED_CODEC_DIGITAL_HDTV = 0x19
+ };
int pmt_start_pid;
int start_pid;
@@ -521,7 +532,7 @@ static void mpegts_write_sdt(AVFormatContext *s)
*q++ = 0x48;
desc_len_ptr = q;
q++;
- *q++ = 0x01; /* digital television service */
+ *q++ = ts->service_type;
putstr8(&q, service->provider_name);
putstr8(&q, service->name);
desc_len_ptr[0] = q - desc_len_ptr - 1;
@@ -1434,6 +1445,30 @@ static const AVOption options[] = {
{ "mpegts_service_id", "Set service_id field.",
offsetof(MpegTSWrite, service_id), AV_OPT_TYPE_INT,
{ .i64 = 0x0001 }, 0x0001, 0xffff, AV_OPT_FLAG_ENCODING_PARAM },
+ { "mpegts_service_type", "Set service_type field.",
+ offsetof(MpegTSWrite, service_type), AV_OPT_TYPE_INT,
+ { .i64 = 0x01 }, 0x01, 0xff, AV_OPT_FLAG_ENCODING_PARAM, "mpegts_service_type" },
+ { "digital_tv", "Digital Television.",
+ 0, AV_OPT_TYPE_CONST, { .i64 = MPEGTS_SERVICE_TYPE_DIGITAL_TV }, 0x01, 0xff,
+ AV_OPT_FLAG_ENCODING_PARAM, "mpegts_service_type" },
+ { "digital_radio", "Digital Radio.",
+ 0, AV_OPT_TYPE_CONST, { .i64 = MPEGTS_SERVICE_TYPE_DIGITAL_RADIO }, 0x01, 0xff,
+ AV_OPT_FLAG_ENCODING_PARAM, "mpegts_service_type" },
+ { "teletext", "Teletext.",
+ 0, AV_OPT_TYPE_CONST, { .i64 = MPEGTS_SERVICE_TYPE_TELETEXT }, 0x01, 0xff,
+ AV_OPT_FLAG_ENCODING_PARAM, "mpegts_service_type" },
+ { "advanced_codec_digital_radio", "Advanced Codec Digital Radio.",
+ 0, AV_OPT_TYPE_CONST, { .i64 = MPEGTS_SERVICE_TYPE_ADVANCED_CODEC_DIGITAL_RADIO }, 0x01, 0xff,
+ AV_OPT_FLAG_ENCODING_PARAM, "mpegts_service_type" },
+ { "mpeg2_digital_hdtv", "MPEG2 Digital HDTV.",
+ 0, AV_OPT_TYPE_CONST, { .i64 = MPEGTS_SERVICE_TYPE_MPEG2_DIGITAL_HDTV }, 0x01, 0xff,
+ AV_OPT_FLAG_ENCODING_PARAM, "mpegts_service_type" },
+ { "advanced_codec_digital_sdtv", "Advanced Codec Digital SDTV.",
+ 0, AV_OPT_TYPE_CONST, { .i64 = MPEGTS_SERVICE_TYPE_ADVANCED_CODEC_DIGITAL_SDTV }, 0x01, 0xff,
+ AV_OPT_FLAG_ENCODING_PARAM, "mpegts_service_type" },
+ { "advanced_codec_digital_hdtv", "Advanced Codec Digital HDTV.",
+ 0, AV_OPT_TYPE_CONST, { .i64 = MPEGTS_SERVICE_TYPE_ADVANCED_CODEC_DIGITAL_HDTV }, 0x01, 0xff,
+ AV_OPT_FLAG_ENCODING_PARAM, "mpegts_service_type" },
{ "mpegts_pmt_start_pid", "Set the first pid of the PMT.",
offsetof(MpegTSWrite, pmt_start_pid), AV_OPT_TYPE_INT,
{ .i64 = 0x1000 }, 0x0010, 0x1f00, AV_OPT_FLAG_ENCODING_PARAM },
--
2.2.2
More information about the ffmpeg-devel
mailing list