Hi,<br><br>This probably might seem as a stupid question to most of you, but I'm new to ffmpeg and I'm kind of lost.<br><br>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?<br>
I don't see any function call which explicitly writes and kind of header data to file.<br><br>I've created some raw samples and tried to encode them to WAV (PCM 16 SE):<br><br><div style="margin-left:40px"><i>while(sampleSize > 0)<br>
{<br>        frame->data[0] = (uint8_t*)samples;<br>        frame->nb_samples = sampleSize / (2 * codecContext->channels);<br>        av_init_packet(&packet);<br>        packet.data = NULL;<br>        packet.size = 0;<br>
        got_packet = 0;<br>        ret = avcodec_encode_audio2(codecContext, &packet, frame, &got_packet);<br>        if (ret < 0) {<br>                cout<<"Audio encoding failed"<<endl;<br>
        }<br>        if (got_packet) {<br>                fwrite(packet.data, 1, packet.size, f);<br>                av_destruct_packet(&packet);<br>        }<br>     //Get more samples<br> }<br><br></i></div>I've noticed that the actual encoded samples are correctly written to files, but there is no header.<br>
<br>Christoph<br>