<div dir="ltr"><div>You are calling: avcodec_parameters_to_context( av_encode_codec_ctx, parameters ) but I think that is not in the example. Maybe only needed for decoding ?<br><br><br></div><br></div><div class="gmail_extra"><br clear="all"><div><div class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><div><div dir="ltr"><br><a href="http://lives-video.com" target="_blank">http://lives-video.com</a><br><a href="https://www.openhub.net/accounts/salsaman" target="_blank">https://www.openhub.net/accounts/salsaman</a><br></div></div></div></div></div>
<br><div class="gmail_quote">On Tue, Aug 23, 2016 at 9:30 AM, Charles <span dir="ltr"><<a href="mailto:linux2@orion15.org" target="_blank">linux2@orion15.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Just posted the current version<br>
<a href="https://gist.github.com/LinuxwitChdoCtOr/74c1721dd7688cf1d16509ea2a52d231" rel="noreferrer" target="_blank">https://gist.github.com/Linuxw<wbr>itChdoCtOr/74c1721dd7688cf1d16<wbr>509ea2a52d231</a><br>
Thanks<br>
cco<div class="HOEnZb"><div class="h5"><br>
<br>
On 08/23/2016 07:22 AM, Charles wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Thank you for looking.<br>
<br>
Yes, I pretty much started there, and pretty much have it open all the time.<br>
>From what I can tell my code is doing the same thing:<br>
<br>
   av_encode_codec_ctx = avcodec_alloc_context3( av_encode_codec );<br>
   if ( !av_encode_codec_ctx ) { PRINT_AV_ERROR( "ERROR:avcodec_alloc_context3:<wbr>" ); return -1; }<br>
   av_encode_codec_ctx->bit_<wbr>rate    = 5e6;<br>
   av_encode_codec_ctx->width       = 1024;   /// \note multiple of 2<br>
   av_encode_codec_ctx->height      = 768;   /// \note multiple of 2<br>
   av_encode_codec_ctx->time_<wbr>base   = (AVRational) { 1, 60 }; //* 2;<br>
   av_encode_codec_ctx->gop_<wbr>size    = 15;      // Intra frames per x P frames<br>
   av_encode_codec_ctx->pix_fmt     = AV_PIX_FMT_YUV420P; // (MUST) DO NOT CHANGE nvenc required<br>
<br>
That code does not setup the output with<br>
   avio_open( &av_out_fmt_ctx->pb, f.c_str(), AVIO_FLAG_WRITE )<br>
   avformat_write_header( av_out_fmt_ctx, NULL )<br>
<br>
The header is where I see my error, either the muxer is unhappy or the encoder is unhappy<br>
<br>
Output #0, mp4, to 'enc.mp4':<br>
    Stream #0:0: Unknown: none (h264_nvenc) ([33][0][0][0] / 0x0021)<br>
av_dump_format enc.mp4<br>
[mp4 @ 0x786d60] Using AVStream.codec to pass codec parameters to muxers is deprecated, use AVStream.codecpar instead.<br>
[mp4 @ 0x786d60] dimensions not set<br>
ERROR:avformat_write_header::<br>
<br>
Thanks<br>
cco<br>
<br>
On 08/23/2016 07:01 AM, salsaman wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Charles,<br>
perhaps the example here can help ?<br>
<br>
 <a href="https://ffmpeg.org/doxygen/3.1/decoding__encoding_8c_source.html#l00347" rel="noreferrer" target="_blank">https://ffmpeg.org/doxygen/3.<wbr>1/decoding__encoding_8c_source<wbr>.html#l00347</a><br>
<br>
<br>
<br>
<br>
<br>
<a href="http://lives-video.com" rel="noreferrer" target="_blank">http://lives-video.com</a><br>
<a href="https://www.openhub.net/accounts/salsaman" rel="noreferrer" target="_blank">https://www.openhub.net/accoun<wbr>ts/salsaman</a><br>
<br>
On Tue, Aug 23, 2016 at 8:39 AM, Charles <<a href="mailto:linux2@orion15.org" target="_blank">linux2@orion15.org</a> <mailto:<a href="mailto:linux2@orion15.org" target="_blank">linux2@orion15.org</a>>> wrote:<br>
<br>
    On 08/23/2016 03:08 AM, Nicolas George wrote:<br>
<br>
        Le sextidi 6 fructidor, an CCXXIV, Charles a écrit :<br>
<br>
            6 - avcodec_parameters_to_context( av_encode_codec_ctx, av_out_fmt_ctx->streams[ 0 ]->codecpar )<br>
<br>
<br>
        You are copying the parameters from a newly created blank stream to an<br>
        initialized encoder. That feels wrong.<br>
<br>
        Regards,<br>
<br>
<br>
    Thanks for the look, I did some rearranging and I am to the point where the muxer is happy or the encoder is happy but cant get both at<br>
    the same time:<br>
<br>
    Currently Op order:<br>
    1) av_encode_codec = avcodec_find_encoder( AV_CODEC_ID_H264 )<br>
    2) avformat_alloc_output_context2<wbr>( &av_out_fmt_ctx, NULL, NULL, f.c_str() )<br>
    3) video_st = avformat_new_stream( av_out_fmt_ctx, av_encode_codec )<br>
       video_st->id = 0;<br>
       video_st->time_base.den   = 60; // * 2;<br>
       video_st->time_base.num   = 1;<br>
       // This solved the time_base error<br>
    4) parameters = video_st->codecpar;<br>
       parameters->codec_tag = tag;<br>
       parameters->format    = AV_PIX_FMT_YUV420P;<br>
       parameters->bit_rate  = 5e6;<br>
       parameters->width     = 1024;<br>
       parameters->height    = 768;<br>
       parameters->bit_rate  = 5e6;<br>
       av_dict_set( &av_dict_opts, "b", "2.5M", 0);<br>
       av_dict_set( &av_dict_opts, "preset", "losslesshp", 0 );<br>
       av_dict_set( &av_dict_opts, "profile", "high", 0 );<br>
       av_dict_set( &av_dict_opts, "rc", "vbr_minqp", 0 );<br>
       av_dict_set( &av_dict_opts, "gpu", "1", 0 );<br>
    5) av_encode_codec_ctx = avcodec_alloc_context3( av_encode_codec )<br>
       av_encode_codec_ctx->bit_<wbr>rate    = 5e6;<br>
       av_encode_codec_ctx->width       = 1024;   /// \note multiple of 2<br>
       av_encode_codec_ctx->height      = 768;   /// \note multiple of 2<br>
       av_encode_codec_ctx->time_<wbr>base   = (AVRational) { 1, 60 }; //* 2;<br>
       av_encode_codec_ctx->gop_<wbr>size    = 15;      // Intra frames per x P frames<br>
       av_encode_codec_ctx->pix_fmt     = AV_PIX_FMT_YUV420P; // MUST DO NOT CHANGE nvenc required<br>
       // This appears to make h264_nvenc happy<br>
    6) avcodec_parameters_to_context( av_encode_codec_ctx, parameters )<br>
    7) avcodec_open2( av_encode_codec_ctx, av_encode_codec, &av_dict_opts )<br>
<br>
    [mp4 @ 0xc2ed60] Using AVStream.codec to pass codec parameters to muxers is deprecated, use AVStream.codecpar instead.<br>
    [mp4 @ 0xc2ed60] dimensions not set<br>
<br>
    AVStream does not have dimensions, and the error makes me think its in the ctx but I am setting those dims.<br>
<br>
    Clearly I am not setting something, just haven't found it.<br>
<br>
<br>
    Thanks<br>
    cco<br>
<br>
<br>
<br>
    ______________________________<wbr>_________________<br>
    Libav-user mailing list<br>
    <a href="mailto:Libav-user@ffmpeg.org" target="_blank">Libav-user@ffmpeg.org</a> <mailto:<a href="mailto:Libav-user@ffmpeg.org" target="_blank">Libav-user@ffmpeg.org</a>><br>
    <a href="http://ffmpeg.org/mailman/listinfo/libav-user" rel="noreferrer" target="_blank">http://ffmpeg.org/mailman/list<wbr>info/libav-user</a> <<a href="http://ffmpeg.org/mailman/listinfo/libav-user" rel="noreferrer" target="_blank">http://ffmpeg.org/mailman/lis<wbr>tinfo/libav-user</a>><br>
<br>
<br>
<br>
<br>
______________________________<wbr>_________________<br>
Libav-user mailing list<br>
<a href="mailto:Libav-user@ffmpeg.org" target="_blank">Libav-user@ffmpeg.org</a><br>
<a href="http://ffmpeg.org/mailman/listinfo/libav-user" rel="noreferrer" target="_blank">http://ffmpeg.org/mailman/list<wbr>info/libav-user</a><br>
<br>
</blockquote>
<br>
______________________________<wbr>_________________<br>
Libav-user mailing list<br>
<a href="mailto:Libav-user@ffmpeg.org" target="_blank">Libav-user@ffmpeg.org</a><br>
<a href="http://ffmpeg.org/mailman/listinfo/libav-user" rel="noreferrer" target="_blank">http://ffmpeg.org/mailman/list<wbr>info/libav-user</a><br>
</blockquote>
<br>
______________________________<wbr>_________________<br>
Libav-user mailing list<br>
<a href="mailto:Libav-user@ffmpeg.org" target="_blank">Libav-user@ffmpeg.org</a><br>
<a href="http://ffmpeg.org/mailman/listinfo/libav-user" rel="noreferrer" target="_blank">http://ffmpeg.org/mailman/list<wbr>info/libav-user</a><br>
</div></div></blockquote></div><br></div>