[Libav-user] Private streams in MPEG-TS

Wolfgang Lorenz wl-chmw at gmx.de
Tue Sep 30 11:06:44 CEST 2014


Hello list readers,

I'm trying to interleave some continuous private data into an MPEG-TS
container alongside to some audio data. As far as I know, MPEG-TS
supports private streams, but I can not get it, to work cleanly.

I've attached a little working example to show, what I've got so far
and what problems I've encountered.

The example file works like this:
* Muxing:
  * Open a format context for the MPEG-TS container.
  * Add a stream with codec-type AVMEDIA_TYPE_DATA.
  * Open file, write header.
  * Fill packets with 1024 bytes of random data (either only digits '0'
    to '9', or char (0 - 255), and write them to the container.
  * Write trailer, close file, free format context.
* Demuxing:
  * Open format context and file.
  * Find and write out stream info.
  * Read packets and write out some info.
  * Free format context.

Results, when running the example:
* With digit-only data ('0' - '9'):
  * Stream's codec-type is AVMEDIA_TYPE_UNKNOWN
  * Packet sizes are correct 1024 bytes, as generated while muxing.
* Using full bytes:
  * Stream's codec-type is AVMEDIA_TYPE_AUDIO
  * I guess FFMPEG tries to decode the not-audio data using either mp3
    (FFMPEG 2.2.3) or aac (FFMPEG 2.4.1).
  * Packet sizes are not preserved. :-(

I can work around these problems, by ignoring all warning and error
messages, as well as the codec-types. I can just use a dedicated stream
ID identify the data stream. I can put the size of each packet at the
beginning of each packet, to demangle the package data. But I'd rather
have a cleaner solution, where the codec-type is set correctly and
FFMPEG does not try to decode my data.

So... What have I done wrong? What is the correct way to achieve this?

Thanks,
  Wolfgang
-------------- next part --------------
A non-text attachment was scrubbed...
Name: private_stream.c
Type: text/x-c++src
Size: 3670 bytes
Desc: not available
URL: <https://ffmpeg.org/pipermail/libav-user/attachments/20140930/76f64c7a/attachment.bin>


More information about the Libav-user mailing list