Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You must set some additional settings for <code>AVCodecContext</code> before you call <code>avcodec_open2</code>.</p> <p>I usually set these required settings (variables beginning with 'k' mean predefined constatns):</p> <pre><code>avCtx-&gt;strict_std_compliance = FF_COMPLIANCE_EXPERIMENTAL; avCtx-&gt;codec_type = AVMEDIA_TYPE_AUDIO; avCtx-&gt;channels = kChannelsCount; // for example, 2 avCtx-&gt;sample_fmt = kSampleFmt; // AV_SAMPLE_FMT_S16 avCtx-&gt;sample_rate = kSampleRate; // 44100 avCtx-&gt;channel_layout = kSampleLayout; // 3 const AVRational timeBase = {1, avCtx-&gt;sample_rate}; avCtx-&gt;time_base = timeBase; </code></pre> <p><strong>UPD</strong></p> <p>I'm sorry, I wrote the parameters that must be set for audio <em>encoding</em>. For audio decoding usually sufficient to set <code>avCtx-&gt;channels</code>, <code>ctx-&gt;sample_rate</code> or set <code>avCtx-&gt;extrdata</code> and <code>avCtx-&gt;extradata_size</code>.</p> <p>To find the cause of the error, try to see the ffmpeg output. If on the device is difficult to do, you can redirect the ffmpeg output and perform logging by own callback. Example:</p> <pre><code> // initialize: ::av_log_set_callback(&amp;my_ffmpeg_log); // callback void my_ffmpeg_log(void *ptr, int level, const char *fmt, va_list vl) { /// Here you can set a more detailed level if (level &lt; AV_LOG_VERBOSE) { static char message[8192]; const char *module = NULL; if (ptr) { AVClass *avc = *(AVClass**) ptr; if (avc-&gt;item_name) module = avc-&gt;item_name(ptr); } vsnprintf(message, sizeof message, fmt, vl); // you can set own function here, for example LOGI, as you have in your example std::cout &lt;&lt; "ffmpeg message : " &lt;&lt; module &lt;&lt; " " &lt;&lt; level &lt;&lt; " " &lt;&lt; message; } } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload