MP4 -> ADTS Headers

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

MP4 -> ADTS Headers

FFmpeg-users mailing list
Hi,

I’m writing a C++ program to validate the integrity of a Fragmented MP4 file containing AAC audio.
This program would parse the FMP4 file, read each audio packet, attachment ADTS headers, and then try to decode the AAC using libfdk_aac.

I am using libavformat, and I am able to parse the MP4 atoms correctly, however I’m having issues figuring out the best way to attach the ADTS headers.

The best sample I was able to find was:

https://patchwork.ffmpeg.org/patch/3184/ <https://patchwork.ffmpeg.org/patch/3184/>

Is there a better example for me to use?

Ronak
_______________________________________________
ffmpeg-user mailing list
[hidden email]
https://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".
Reply | Threaded
Open this post in threaded view
|

Re: MP4 -> ADTS Headers

samuel.widmer
Sehr geehrte Damen und Herren

Besten Dank für Ihr Mail. Ich bin vom 3. Oktober bis 9. Oktober 2019 abwesend.

Die Mails werden in dieser Zeit nur sporadisch beantwortet.

In dringenden Fällen nehmen Sie bitte mit [hidden email] Kontakt auf.


Herzlichen Dank für Ihr Verständnis und eine gute Zeit

Samuel Widmer



_______________________________________________
ffmpeg-user mailing list
[hidden email]
https://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".
Reply | Threaded
Open this post in threaded view
|

Re: MP4 -> ADTS Headers

FFmpeg-users mailing list
In reply to this post by FFmpeg-users mailing list

> On Oct 3, 2019, at 12:48 AM, Ronak via ffmpeg-user <[hidden email]> wrote:
>
> Hi,
>
> I’m writing a C++ program to validate the integrity of a Fragmented MP4 file containing AAC audio.
> This program would parse the FMP4 file, read each audio packet, attachment ADTS headers, and then try to decode the AAC using libfdk_aac.
>
> I am using libavformat, and I am able to parse the MP4 atoms correctly, however I’m having issues figuring out the best way to attach the ADTS headers.
>
> The best sample I was able to find was:
>
> https://patchwork.ffmpeg.org/patch/3184/ <https://patchwork.ffmpeg.org/patch/3184/>
>
> Is there a better example for me to use?
>


Hi,

So I managed to figure out how to do this, and I’m up to the part of figuring out what I need to write in the extradata field of the AVCodecParameters here:

// create another context used to append ADTS headers to the parsed segments, if we need them
bool isBufferWritable = true;
avformat_alloc_output_context2(&this->adtsMuxerContext, NULL, "adts", NULL);
this->adtsMuxerWriterContext = avio_alloc_context(this->adtsPacketBuffer, this->adtsPacketBufferSize, isBufferWritable, this, NULL, AudioAssetReader::writeADTSPacket, NULL);
this->adtsMuxerContext->pb = this->adtsMuxerWriterContext;

// initialize an ADTS stream
AVCodecID aacCodec = AVCodecID::AV_CODEC_ID_AAC;
AVCodec *codec = avcodec_find_encoder(aacCodec);
AVStream *stream = avformat_new_stream(this->adtsMuxerContext, codec);
stream->id = this->adtsMuxerContext->nb_streams - 1;
stream->time_base.den = input.getSampleRateHz();
stream->time_base.num = 1;

// configure the stream with the details of the AAC packets
AVCodecParameters *codecParameters = stream->codecpar;
codecParameters->codec_id = aacCodec;
codecParameters->bit_rate = input.getBitrateBps();
codecParameters->profile = this->getAACProfileForCodec(input.getCodec());
codecParameters->sample_rate = input.getSampleRateHz();
codecParameters->channels = input.getChannelCount();
codecParameters->codec_type = AVMEDIA_TYPE_AUDIO;
codecParameters->channel_layout = av_get_default_channel_layout(input.getChannelCount());
codecParameters->extradata = new uint8_t[AV_INPUT_BUFFER_PADDING_SIZE + 2];
codecParameters->extradata_size = 2;
memset(codecParameters->extradata, 2, AV_INPUT_BUFFER_PADDING_SIZE + 2);

But this is still not working with errors about: [adts @ 0x7f87c4803a00] MPEG-4 AOT 0 is not allowed in ADTS


Reading the code in FFmpeg, it looks like I need to send in a full fledged ADTS header into extradata is that correct?

> Ronak
> _______________________________________________
> ffmpeg-user mailing list
> [hidden email]
> https://ffmpeg.org/mailman/listinfo/ffmpeg-user
>
> To unsubscribe, visit link above, or email
> [hidden email] with subject "unsubscribe".

_______________________________________________
ffmpeg-user mailing list
[hidden email]
https://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".
Reply | Threaded
Open this post in threaded view
|

Re: MP4 -> ADTS Headers

Carl Eugen Hoyos-2
In reply to this post by FFmpeg-users mailing list
Am Do., 3. Okt. 2019 um 06:49 Uhr schrieb Ronak via ffmpeg-user
<[hidden email]>:
> I’m writing a C++ program to validate the integrity of a Fragmented MP4 file containing AAC audio.

Note that when using the library, the libav-user mailing list is more suitable:
https://ffmpeg.org/contact.html#MailingLists

Carl Eugen
_______________________________________________
ffmpeg-user mailing list
[hidden email]
https://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".
Reply | Threaded
Open this post in threaded view
|

Re: MP4 -> ADTS Headers

FFmpeg-users mailing list


> On Oct 3, 2019, at 5:27 PM, Carl Eugen Hoyos <[hidden email]> wrote:
>
> Am Do., 3. Okt. 2019 um 06:49 Uhr schrieb Ronak via ffmpeg-user
> <[hidden email]>:
>> I’m writing a C++ program to validate the integrity of a Fragmented MP4 file containing AAC audio.
>
> Note that when using the library, the libav-user mailing list is more suitable:
> https://ffmpeg.org/contact.html#MailingLists

Ok I also emailed there. Do you have any ideas what to do here? From what I read in your code; the extra data seems like should have a fully formed adts header supplied.

If that’s true then why does the muxer even exist? I’m wondering if I’m missing some options on the input format context.

>
> Carl Eugen
> _______________________________________________
> ffmpeg-user mailing list
> [hidden email]
> https://ffmpeg.org/mailman/listinfo/ffmpeg-user
>
> To unsubscribe, visit link above, or email
> [hidden email] with subject "unsubscribe".

_______________________________________________
ffmpeg-user mailing list
[hidden email]
https://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".
Reply | Threaded
Open this post in threaded view
|

Re: MP4 -> ADTS Headers

samuel.widmer
In reply to this post by FFmpeg-users mailing list
Sehr geehrte Damen und Herren

Besten Dank für Ihr Mail. Ich bin vom 3. Oktober bis 9. Oktober 2019 abwesend.

Die Mails werden in dieser Zeit nur sporadisch beantwortet.

In dringenden Fällen nehmen Sie bitte mit [hidden email] Kontakt auf.


Herzlichen Dank für Ihr Verständnis und eine gute Zeit

Samuel Widmer



_______________________________________________
ffmpeg-user mailing list
[hidden email]
https://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".