Encoding a Data Stream Alongside Video in FFMPEG

2019-07-02 11:53发布

I'm wanting to encode some proprietary data (it's a serialised unsigned 64-bit integer per frame) into a video container (mp4) as a data stream, but I have been unable to find any instructions/tutorials of anyone doing this.

The only thing I've been able to find is this, which describes potentially how to create a data stream (the user had no success apparently https://lists.libav.org/pipermail/ffmpeg-user/2006-November/005070.html)

This is my current code for creating a stream:

    ff_data_stream = avformat_new_stream(ff_output_context, NULL);

    ff_data_stream->codec->codec_type = AVMEDIA_TYPE_DATA;
    ff_data_stream->codec->codec_id = AV_CODEC_ID_NONE;
    ff_data_stream->codec->flags |= CODEC_FLAG_GLOBAL_HEADER;

But then when I'm calling avformat_write_header it errors with the following output to console:

[mp4 @ 0x7fff68000900] track 1: could not find tag, codec not currently supported in container

So my questions are as follows:

  • Is it possible to create a data stream with an mp4 container? If not, are there any containers that do?
    • This might not be the right way to do this, but I have not yet come across any method of doing so.
  • If so, how can I configure the stream correctly? (Whether it's for this container or another)
  • Would one then use an AVPacket when writing to file? And write it into the file by using av_interleaved_write_frame?

Thanks

标签: c ffmpeg
0条回答
登录 后发表回答