<div dir="ltr"><div>Hi there,</div><div><br></div><div>It turns out that <b>I was sending the frames to the decoder</b> format context <b>instead of the encoder</b> context format. Anyway, I solved this and I'm seeing some different messages, the file was generated but it can't be played on vlc, although I can listen its sound.</div><div><br></div><div>The entire file is on github <a href="https://github.com/leandromoreira/ffmpeg-libav-tutorial/blob/transcoding/2_transcoding.c">https://github.com/leandromoreira/ffmpeg-libav-tutorial/blob/transcoding/2_transcoding.c</a></div><div><br></div><div><b>Questions:</b></div><div><br></div><div><div>1) How can I fix the yellow messages? (which I suppose are the warning level log) or where should I keep my focus to fix? </div><div>  [libx264 @ 0x7faa4c801200] MB rate (489600000) > level limit (2073600) <b>(yellow)</b></div><div><b>  </b>[mp4 @ 0x7faa4c800000] track 1: codec frame size is not set <b>(yellow)</b></div><div><div><div>  [libx264 @ 0x7faa4c801200] forced frame type (5) at 4 was changed to frame type (3)<b>(yellow)</b></div><div>  [libx264 @ 0x7faa4c801200] forced frame type (5) at 9 was changed to frame type (3)<b>(yellow)</b></div><div>  [libx264 @ 0x7faa4c801200] forced frame type (5) at 17 was changed to frame type (3)<b>(yellow)</b></div></div></div><div>2) How can I send x264opts? (I tried AVCodecContext->priv_data and it didn't work)</div></div><div><br></div><div><b>FFmpegLibAV messages</b></div><div><br></div><div><div>[libx264 @ 0x7faa4c801200] using SAR=1/1</div><div>[libx264 @ 0x7faa4c801200] MB rate (489600000) > level limit (2073600) <b>(yellow)</b></div><div>[libx264 @ 0x7faa4c801200] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX</div><div>[libx264 @ 0x7faa4c801200] profile High, level 5.2</div><div>[mp4 @ 0x7faa4c800000] track 1: codec frame size is not set <b>(yellow)</b></div></div><div><br></div><div><div>[libx264 @ 0x7faa4c801200] forced frame type (5) at 4 was changed to frame type (3)<b>(yellow)</b></div><div>[libx264 @ 0x7faa4c801200] forced frame type (5) at 9 was changed to frame type (3)<b>(yellow)</b></div><div>[libx264 @ 0x7faa4c801200] forced frame type (5) at 17 was changed to frame type (3)<b>(yellow)</b></div></div><div><br></div><div><b>VLC message:</b></div><div><br></div><div><div>[000000010100a4b8] core decoder error: Could not convert timestamp 675061246497</div><div>[000000010100a4b8] clock decoder error: Timestamp conversion failed (delay 1000000, buffering 100000, bound 9000000)</div><div>[000000010100a4b8] core decoder error: Could not convert timestamp 675069579830</div><div>[000000010100a4b8] clock decoder error: Timestamp conversion failed (delay 1000000, buffering 100000, bound 9000000)</div><div>[000000010100a4b8] core decoder error: Could not convert timestamp 675077913164</div></div></div><br><div class="gmail_quote"><div dir="ltr">On Sun, Dec 3, 2017 at 10:39 PM Leandro Moreira <<a href="mailto:leandro.ribeiro.moreira@gmail.com">leandro.ribeiro.moreira@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">I'm trying to code a simple transcoder, using the new API, that replicates to the following command line:<div><br></div><div><div style="color:rgb(33,33,33);font-size:13px"><font face="monospace">ffmpeg -i input.mp4 -c:v libx264 -x264-params keyint=60:min-keyint=60:no-scenecut=1 -c:a copy output.mp4</font></div></div><div><br></div><div>I followed the transcoding example on Doxygen documentation but using the new API. </div><div><br></div><div>My attempt to code it didn't work, either I get a single audio stream on an mp4, that works, or a video stream on an mp4 that doesn't work.</div><div><br></div><div>I don't see any error message, the messages I see are these:</div><div><br></div><div><div><font face="monospace">[libx264 @ 0x7fd0ae038000] using SAR=1/1</font></div><div><font face="monospace">[libx264 @ 0x7fd0ae038000] MB rate (489600000) > level limit (2073600)</font></div><div><font face="monospace">[libx264 @ 0x7fd0ae038000] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX</font></div><div><font face="monospace">[libx264 @ 0x7fd0ae038000] profile High, level 5.2</font></div></div><div><br class="m_6932376413342880216inbox-inbox-Apple-interchange-newline">The whole file <a href="https://github.com/leandromoreira/ffmpeg-libav-tutorial/blob/transcoding/2_transcoding.c" target="_blank">https://github.com/leandromoreira/ffmpeg-libav-tutorial/blob/transcoding/2_transcoding.c</a><br></div><div><br></div><div>Anyway, what I did was: <br></div><br><b>I created a transcode context type:</b><br><br>typedef struct TrancodeContext { <br>  char *file_name; <br>  AVFormatContext *format_context; <br>  int audio_stream_index; <br>  int video_stream_index; <br>  AVStream *stream[2]; <br>  AVCodec *codec[2]; <br>  AVCodecContext *codec_context[2];<br>} TranscodeContext;<br><br><b><a href="https://github.com/leandromoreira/ffmpeg-libav-tutorial/blob/transcoding/2_transcoding.c#L120" target="_blank">Prepared the decoder</a> with the functions:</b><div><ol><li>avformat_alloc_context,</li><li>avformat_open_input,</li><li>avformat_find_stream_info,</li><li>avcodec_find_decoder,</li><li>avcodec_alloc_context3,</li><li>avcodec_parameters_to_context,</li><li>avcodec_open2</li></ol></div><div><b><a href="https://github.com/leandromoreira/ffmpeg-libav-tutorial/blob/transcoding/2_transcoding.c#L337" target="_blank">Prepared the encoder</a> with the functions:</b></div><div><ol><li>avformat_alloc_output_context2,</li><li>avformat_new_stream,</li><li>avcodec_find_encoder_by_name,</li><li>avcodec_alloc_context3,</li><li>avcodec_parameters_from_context,</li><li>avcodec_find_encoder,</li><li>avcodec_alloc_context3,</li><li>avformat_new_stream,</li><li>avcodec_open2,</li><li>avcodec_parameters_from_context,</li><li>avio_open,</li><li>avformat_write_header<br></li></ol></div><div><b>Read all the packets:</b></div><div><br><div><div>while (av_read_frame(decoder_context->format_context, input_packet) >= 0)<br></div><div><br></div><div><b><a href="https://github.com/leandromoreira/ffmpeg-libav-tutorial/blob/transcoding/2_transcoding.c#L180" target="_blank">Decode the video packets</a> into frames:</b></div><div><ol><li>avcodec_send_packet,</li><li>avcodec_receive_frame<br></li></ol></div><div><b><a href="https://github.com/leandromoreira/ffmpeg-libav-tutorial/blob/transcoding/2_transcoding.c#L221" target="_blank">Encode the frame</a> into the encoder:</b></div><div><ol><li>avcodec_send_frame,</li><li>avcodec_receive_packet,</li><li>av_packet_rescale_ts,</li><li>av_interleaved_write_frame<br></li></ol></div><div><b><a href="https://github.com/leandromoreira/ffmpeg-libav-tutorial/blob/transcoding/2_transcoding.c#L79" target="_blank">Copy audio stream directly</a> to the encoder:</b></div><div><ol><li>av_packet_rescale_ts,</li><li>av_interleaved_write_frame<br></li></ol></div><div><b>Finish with</b> av_write_trailer</div><div><br></div></div></div><div>Can you see anything suspicious on that? I tried really hard </div></div></blockquote></div>