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

JULIAN GARDNER joolzg at btinternet.com
Sun Dec 10 13:51:12 EET 2017


There are a few problems with the code.
1. Use calloc not malloc initialising your structures2. You call encode_frame ONCE at the end of your main while loop3. Code as it stands crashes with and invalid index at line 269. Joolz
NOTE: Please start using joolzg at gardnersweden.com as this email account will be closed on 31/12/2017 

    On Thursday, 7 December 2017, 1:41, Leandro Moreira <leandro.ribeiro.moreira at gmail.com> wrote:
 

 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 with the functions:   
   - avformat_alloc_context,
   - avformat_open_input,
   - avformat_find_stream_info,
   - avcodec_find_decoder,
   - avcodec_alloc_context3,
   - avcodec_parameters_to_context,
   - avcodec_open2
Prepared the encoder with the functions:   
   - avformat_alloc_output_context2,
   - avformat_new_stream,
   - avcodec_find_encoder_by_name,
   - avcodec_alloc_context3,
   - avcodec_parameters_from_context,
   - avcodec_find_encoder,
   - avcodec_alloc_context3,
   - avformat_new_stream,
   - avcodec_open2,
   - avcodec_parameters_from_context,
   - avio_open,
   - avformat_write_header   

Read all the packets:
while (av_read_frame(decoder_context->format_context, input_packet) >= 0)

Decode the video packets into frames:   
   - avcodec_send_packet,
   - avcodec_receive_frame   

Encode the frame into the encoder:   
   - avcodec_send_frame,
   - avcodec_receive_packet,
   - av_packet_rescale_ts,
   - av_interleaved_write_frame   

Copy audio stream directly to the encoder:   
   - av_packet_rescale_ts,
   - av_interleaved_write_frame   

Finish with av_write_trailer
Can you see anything suspicious on that? I tried really hard 
_______________________________________________
Libav-user mailing list
Libav-user at ffmpeg.org
http://ffmpeg.org/mailman/listinfo/libav-user


   
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://ffmpeg.org/pipermail/libav-user/attachments/20171210/12b2ceed/attachment.html>


More information about the Libav-user mailing list