[Libav-user] libavformat: How to convert AAC audio packets to ADTS format

Henry, David David.Henry at echostar.com
Mon Jan 16 20:53:00 EET 2017


> I am trying to write a C program that demuxes audio from an MP4 file and write demuxed AVPacket data to a file. But the resulting dump is missing ADTS headers. Any pointers on what is the best way to add ADTS headers.

> I see that ffmpeg has 'adtsenc.c' file that seems to implement an ADTS muxer:

AVOutputFormat ff_adts_muxer = {
    .name              = "adts",
    .long_name         = NULL_IF_CONFIG_SMALL("ADTS AAC (Advanced Audio Coding)"),
    .mime_type         = "audio/aac",
    .extensions        = "aac,adts",
    .priv_data_size    = sizeof(ADTSContext),
    .audio_codec       = AV_CODEC_ID_AAC,
    .video_codec       = AV_CODEC_ID_NONE,
    .write_header      = adts_write_header,
    .write_packet      = adts_write_packet,
    .write_trailer     = adts_write_trailer,
    .priv_class        = &adts_muxer_class,
    .flags             = AVFMT_NOTIMESTAMPS,
};

> Can I use this muxer for my purpose? If yes, any links on how to use it?

> Thanks in advance,

> Malik

Malik – Yes, use the adtsenc encoder to add ADTS headers to AAC encoded audio.  (if that’s the output media)
See https://ffmpeg.org/doxygen/2.6/transcode_aac_8c-example.html
For the output format, you can do avformat_alloc_output_context2(&m_format_context, NULL, "adts", NULL)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://ffmpeg.org/pipermail/libav-user/attachments/20170116/76337db2/attachment.html>


More information about the Libav-user mailing list