[Libav-user] trying to add scte-35 demuxer/decoder

David Henry dhenry at movenetworks.com
Thu Jan 16 19:10:25 CET 2014


I am trying to add a way to detect and parse scte-35 messages in a mpeg udp multi-program transport stream.

/opt/move/ffmpeg/bin/ffmpeg -loglevel debug -i udp://x.x.x.x:x
…
Input #0, mpegts, from 'udp://x.x.x.x:x':
  Program 1
    Stream #0:10[0x80f], 36, 1/90000: Id=2 video: mpeg2video (Main) ([2][0][0][0] / 0x0002), yuv420p, 1280x720 [SAR 1:1 DAR 16:9], 1001/120000, 20000 kb/s, 92.67 fps, 59.94 tbr, 90k tbn, 119.88 tbc
    Stream #0:11[0x80e](eng), 19, 1/90000: Id=86019 audio: ac3 (AC-3 / 0x332D4341), 48000 Hz, 5.1(side), s16, 384 kb/s
    Stream #0:12[0x80d](spa), 18, 1/90000: Id=86019 audio: ac3 (AC-3 / 0x332D4341), 48000 Hz, stereo, s16, 192 kb/s
    Stream #0:13[0x80c], 0, 1/90000: Id=98305 data: scte-35 ([134][0][0][0] / 0x0086)

I added a codec in libavcodec which will eventually parse the packets, but currently does nothing.
I am setting the data_codec_id in my calling application, which I have added to AVFormatContext (see below).
I have looked at the following pages for guidance:
http://wiki.multimedia.cx/index.php?title=FFmpeg_demuxer_howto
http://wiki.multimedia.cx/index.php?title=FFmpeg_codec_HOWTO#libavcodec.2Favcodec.h
But it seems I am not really writing a "demuxer", because I will just be piggybacking on the libavformat/mpegts.c demuxer, right?
My question is this:  What is the next step to be able to capture packets/messages out of stream #0:13 (see above)
And pass those packets to the codec I have defined in libavcodec?  Where does this occur in the code?
Thanks, David

These are the changes I have made in libavformat/ :

diff --git a/libavformat/avformat.h b/libavformat/avformat.h
index f2b4317..6a740d6 100644
--- a/libavformat/avformat.h
+++ b/libavformat/avformat.h
@@ -1018,6 +1018,7 @@ typedef struct AVFormatContext {
      */
     enum CodecID subtitle_codec_id;

+    enum CodecID data_codec_id;

diff --git a/libavformat/mpegts.c b/libavformat/mpegts.c
index 7935048..0c5bbea 100644
--- a/libavformat/mpegts.c
+++ b/libavformat/mpegts.c
@@ -560,6 +560,7 @@ static const StreamType HDMV_types[] = {
 static const StreamType MISC_types[] = {
     { 0x81, AVMEDIA_TYPE_AUDIO,   CODEC_ID_AC3 },
     { 0x8a, AVMEDIA_TYPE_AUDIO,   CODEC_ID_DTS },
+    { 0x86, AVMEDIA_TYPE_DATA, CODEC_ID_SCTE },
     { 0 },
 };

diff --git a/libavformat/utils.c b/libavformat/utils.c
index 4817507..7ad59ac 100644
--- a/libavformat/utils.c
+++ b/libavformat/utils.c
@@ -805,6 +805,9 @@ int av_read_packet(AVFormatContext *s, AVPacket *pkt)
         case AVMEDIA_TYPE_SUBTITLE:
             if(s->subtitle_codec_id)st->codec->codec_id= s->subtitle_codec_id;
             break;
+        case AVMEDIA_TYPE_DATA:
+            if(s->data_codec_id)st->codec->codec_id= s->data_codec_id;
+            break;
         }


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://ffmpeg.org/pipermail/libav-user/attachments/20140116/7ce717d4/attachment.html>


More information about the Libav-user mailing list