[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
Mon Dec 4 02:39:23 EET 2017
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/20171204/d628a14c/attachment.html>
More information about the Libav-user
mailing list