<div dir="ltr"><div><br></div>Hi all,<div><br></div><div>I have been trying to change the encoding profile for H264 with no luck. There are few questions here and on SO with no helpful answers that I came across. So I looked at FFmpeg code and found that in libavcodec/libx264.c:X264_init(AVCodecContext *avctx), AVCodecContext->priv_data becomes X264Context with,</div><div><br></div><div><div>X264Context *x4 = avctx->priv_data<br></div></div><div><br></div><div>And then AVCodecContext->profile is processed only when AVCodecContext->priv_data["profile"] (which later magically becomes X264Context->profile) is NULL,</div><div><br></div><div><div>    /* Allow specifying the x264 profile through AVCodecContext. */</div><div>    if (!x4->profile)</div><div>        switch (avctx->profile) {</div><div>        case FF_PROFILE_H264_BASELINE:</div><div>            x4->profile = av_strdup("baseline");</div><div>            break;</div><div>        case FF_PROFILE_H264_HIGH:</div><div>            x4->profile = av_strdup("high");</div><div>            break;</div><div>        case FF_PROFILE_H264_HIGH_10:</div><div>            x4->profile = av_strdup("high10");</div><div>            break;</div><div>        case FF_PROFILE_H264_HIGH_422:</div><div>            x4->profile = av_strdup("high422");</div><div>            break;</div><div>        case FF_PROFILE_H264_HIGH_444:</div><div>            x4->profile = av_strdup("high444");</div><div>            break;</div><div>        case FF_PROFILE_H264_MAIN:</div><div>            x4->profile = av_strdup("main");</div><div>            break;</div><div>        default:</div><div>            break;</div><div>        }</div></div><div><br></div><div>I've been fiddling around these following two lines of my code for two days,</div><div><br></div><div><div>    av_opt_set(m_codecContext->priv_data, "profile", "high", 0);</div><div><span style="white-space:pre">    </span>m_codecContext->profile = FF_PROFILE_H264_HIGH;<br></div></div><div><br></div><div>But I'm still getting following line in the logs,</div><div><br></div><div><div>[libx264 @ 0x209ae40] profile Main, level 1.2</div></div><div><br></div><div>But when I do,</div><div><br></div><div>    av_opt_set(m_codecContext->priv_data, "profile", "nosuch", 0);<br></div><div><br></div><div>I get,</div><div><br></div><div><div>    x264 [error]: invalid profile: nosuch</div><div>    [libx264 @ 0x25d0060] Error setting profile nosuch.</div></div><div>    [libx264 @ 0x25d0060] Possible profiles: baseline main high high10 high422 high444<br></div><div><br></div><div>So it's taken into account and "high" is a valid value but it's just not working. My log level is TRACE but there is no "You wanted high but I fallback to Main because..." kind of message.</div><div><br></div><div>How do I set profile? And what are the conditions that libavcodec changes it on its own? Any clues, please?</div><div><br></div><div>Thanks a bunch in advance!<br clear="all"><div><div class="gmail_signature"><br>-- Baris</div></div>
</div></div>