<div dir="ltr"><div><div class="gmail_signature"><div dir="ltr"><div>Hi <span style="color:rgb(0,0,0);white-space:pre-wrap">everyone.</span><br></div></div></div></div><div class="gmail_quote"><div dir="ltr"><div><br></div><div>I have a question about the FFmpeg library, and more precisely about the <b>audio management</b> in case of no symmetry between video and audio frames.</div><div><br></div><div>First I will explain my situation.</div><div>I work on an open source project, which is a C++ wrapper of FFmpeg, called avTranscoder (<a href="https://github.com/avTranscoder/avTranscoder" target="_blank">https://github.com/avTranscoder/avTranscoder</a>). The goal is to provide a high level API to rewrap / transcode media easily. </div><div>Currently we have an issue about one of our common case: get a MOV file, transcode video and audio at the same time, and create our output media (MXF).</div><div><br></div><div>Indeed, we decode, convert, and encode sequentially video and audio frames. <i>ffprobe</i> tells us about our input file:</div><div><i>Stream #0:0(eng): Video: dnxhd (AVdn / 0x6E645641), yuv422p, 1920x1080, 121241 kb/s, 25 fps, 25 tbr, 25k tbn, 25k tbc<br></i></div><div><i>Stream #0:1(eng): Audio: pcm_s24le (in24 / 0x34326E69), 48000 Hz, 2 channels, s32, 2304 kb/s</i><br></div><div><br></div><div>After few calculations, we expect:</div><div><b style="font-weight:normal"><p dir="ltr" style="margin-top:0pt;margin-bottom:0pt;display:inline!important"><span style="line-height:1;font-family:Arial;color:rgb(0,0,0);background-color:transparent;vertical-align:baseline;white-space:pre-wrap">Video <span style="color:rgb(34,34,34);font-family:arial;line-height:normal;white-space:normal">packet</span> = 1 video frame</span></p></b></div><div><b style="font-weight:normal"><span style="font-family:Arial;color:rgb(0,0,0);background-color:transparent;vertical-align:baseline;white-space:pre-wrap">Audio <span style="color:rgb(34,34,34);font-family:arial;white-space:normal">packet</span> = </span><span style="font-family:Arial;vertical-align:baseline;white-space:pre-wrap;background-color:rgb(255,255,255)"><font color="#000000">1920 audio samples (sample_rate / fps)</font></span></b><br></div><div><br></div><div>Unfortunately, we have more audio packets than video packets (there is in fact <b>1024 audio samples</b> per packet, as I can see with <i>ffprobe -show_packets</i>), and our output is "frame wrapped" (implying same video packets as audio packets). This requires to manage buffer(s) to encode audio packets correctly.</div><div><br></div><div>So my question is: how does ffmpeg buffer video and audio data in such a case ?</div><div style>After looking at the ffmpeg.c file, we believe the solution starts here: <a href="https://github.com/FFmpeg/FFmpeg/blob/master/ffmpeg.c#L713">https://github.com/FFmpeg/FFmpeg/blob/master/ffmpeg.c#L713</a> Isn't it ?</div><div style><br></div><div>Clément</div></div></div></div>