[Libav-user] Writing Audio headers during encoding

Goo Creations goocreations at gmail.com
Thu Apr 26 12:54:50 CEST 2012


Hi,

This probably might seem as a stupid question to most of you, but I'm new
to ffmpeg and I'm kind of lost.

When encoding a some raw samples and writing it to file (as the
decoding_encoding example shows), how are the codec headers added to the
file?
I don't see any function call which explicitly writes and kind of header
data to file.

I've created some raw samples and tried to encode them to WAV (PCM 16 SE):

*while(sampleSize > 0)
{
        frame->data[0] = (uint8_t*)samples;
        frame->nb_samples = sampleSize / (2 * codecContext->channels);
        av_init_packet(&packet);
        packet.data = NULL;
        packet.size = 0;
        got_packet = 0;
        ret = avcodec_encode_audio2(codecContext, &packet, frame,
&got_packet);
        if (ret < 0) {
                cout<<"Audio encoding failed"<<endl;
        }
        if (got_packet) {
                fwrite(packet.data, 1, packet.size, f);
                av_destruct_packet(&packet);
        }
     //Get more samples
}

*
I've noticed that the actual encoded samples are correctly written to
files, but there is no header.

Christoph
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://ffmpeg.org/pipermail/libav-user/attachments/20120426/95f4424f/attachment.html>


More information about the Libav-user mailing list