[Libav-user] My attempt to transcode is writing only a single stream of a two streams output format

Leandro Moreira leandro.ribeiro.moreira at gmail.com
Thu Dec 7 02:35:11 EET 2017


Hi there,

It turns out that *I was sending the frames to the decoder* format
context *instead
of the encoder* 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.

The entire file is on github
https://github.com/leandromoreira/ffmpeg-libav-tutorial/blob/transcoding/2_transcoding.c

*Questions:*

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?
  [libx264 @ 0x7faa4c801200] MB rate (489600000) > level limit (2073600)
*(yellow)*
  [mp4 @ 0x7faa4c800000] track 1: codec frame size is not set *(yellow)*
  [libx264 @ 0x7faa4c801200] forced frame type (5) at 4 was changed to
frame type (3)*(yellow)*
  [libx264 @ 0x7faa4c801200] forced frame type (5) at 9 was changed to
frame type (3)*(yellow)*
  [libx264 @ 0x7faa4c801200] forced frame type (5) at 17 was changed to
frame type (3)*(yellow)*
2) How can I send x264opts? (I tried AVCodecContext->priv_data and it
didn't work)

*FFmpegLibAV messages*

[libx264 @ 0x7faa4c801200] using SAR=1/1
[libx264 @ 0x7faa4c801200] MB rate (489600000) > level limit (2073600)
*(yellow)*
[libx264 @ 0x7faa4c801200] using cpu capabilities: MMX2 SSE2Fast SSSE3
SSE4.2 AVX
[libx264 @ 0x7faa4c801200] profile High, level 5.2
[mp4 @ 0x7faa4c800000] track 1: codec frame size is not set *(yellow)*

[libx264 @ 0x7faa4c801200] forced frame type (5) at 4 was changed to frame
type (3)*(yellow)*
[libx264 @ 0x7faa4c801200] forced frame type (5) at 9 was changed to frame
type (3)*(yellow)*
[libx264 @ 0x7faa4c801200] forced frame type (5) at 17 was changed to frame
type (3)*(yellow)*

*VLC message:*

[000000010100a4b8] core decoder error: Could not convert timestamp
675061246497
[000000010100a4b8] clock decoder error: Timestamp conversion failed (delay
1000000, buffering 100000, bound 9000000)
[000000010100a4b8] core decoder error: Could not convert timestamp
675069579830
[000000010100a4b8] clock decoder error: Timestamp conversion failed (delay
1000000, buffering 100000, bound 9000000)
[000000010100a4b8] core decoder error: Could not convert timestamp
675077913164

On Sun, Dec 3, 2017 at 10:39 PM Leandro Moreira <
leandro.ribeiro.moreira at gmail.com> wrote:

> I'm trying to code a simple transcoder, using the new API, that replicates
> to the following command line:
>
> ffmpeg -i input.mp4 -c:v libx264 -x264-params
> keyint=60:min-keyint=60:no-scenecut=1 -c:a copy output.mp4
>
> I followed the transcoding example on Doxygen documentation but using the
> new API.
>
> 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.
>
> I don't see any error message, the messages I see are these:
>
> [libx264 @ 0x7fd0ae038000] using SAR=1/1
> [libx264 @ 0x7fd0ae038000] MB rate (489600000) > level limit (2073600)
> [libx264 @ 0x7fd0ae038000] using cpu capabilities: MMX2 SSE2Fast SSSE3
> SSE4.2 AVX
> [libx264 @ 0x7fd0ae038000] profile High, level 5.2
>
> The whole file
> https://github.com/leandromoreira/ffmpeg-libav-tutorial/blob/transcoding/2_transcoding.c
>
> Anyway, what I did was:
>
> *I created a transcode context type:*
>
> typedef struct TrancodeContext {
>   char *file_name;
>   AVFormatContext *format_context;
>   int audio_stream_index;
>   int video_stream_index;
>   AVStream *stream[2];
>   AVCodec *codec[2];
>   AVCodecContext *codec_context[2];
> } TranscodeContext;
>
> *Prepared the decoder
> <https://github.com/leandromoreira/ffmpeg-libav-tutorial/blob/transcoding/2_transcoding.c#L120>
> with the functions:*
>
>    1. avformat_alloc_context,
>    2. avformat_open_input,
>    3. avformat_find_stream_info,
>    4. avcodec_find_decoder,
>    5. avcodec_alloc_context3,
>    6. avcodec_parameters_to_context,
>    7. avcodec_open2
>
> *Prepared the encoder
> <https://github.com/leandromoreira/ffmpeg-libav-tutorial/blob/transcoding/2_transcoding.c#L337>
> with the functions:*
>
>    1. avformat_alloc_output_context2,
>    2. avformat_new_stream,
>    3. avcodec_find_encoder_by_name,
>    4. avcodec_alloc_context3,
>    5. avcodec_parameters_from_context,
>    6. avcodec_find_encoder,
>    7. avcodec_alloc_context3,
>    8. avformat_new_stream,
>    9. avcodec_open2,
>    10. avcodec_parameters_from_context,
>    11. avio_open,
>    12. avformat_write_header
>
> *Read all the packets:*
>
> while (av_read_frame(decoder_context->format_context, input_packet) >= 0)
>
> *Decode the video packets
> <https://github.com/leandromoreira/ffmpeg-libav-tutorial/blob/transcoding/2_transcoding.c#L180>
> into frames:*
>
>    1. avcodec_send_packet,
>    2. avcodec_receive_frame
>
> *Encode the frame
> <https://github.com/leandromoreira/ffmpeg-libav-tutorial/blob/transcoding/2_transcoding.c#L221>
> into the encoder:*
>
>    1. avcodec_send_frame,
>    2. avcodec_receive_packet,
>    3. av_packet_rescale_ts,
>    4. av_interleaved_write_frame
>
> *Copy audio stream directly
> <https://github.com/leandromoreira/ffmpeg-libav-tutorial/blob/transcoding/2_transcoding.c#L79>
> to the encoder:*
>
>    1. av_packet_rescale_ts,
>    2. av_interleaved_write_frame
>
> *Finish with* av_write_trailer
>
> Can you see anything suspicious on that? I tried really hard
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://ffmpeg.org/pipermail/libav-user/attachments/20171207/57c9496e/attachment.html>


More information about the Libav-user mailing list