[Libav-user] Transcoding with new API avcodec_receive_packet

Leandro Moreira leandro.ribeiro.moreira at gmail.com
Wed Nov 29 15:12:30 EET 2017


Hello there,

I'm trying to code a simple transcoder that replicates (almost the same
behavior) as this command line:

ffmpeg -i input.mp4 -c:v libx264 -x264-params
keyint=60:min-keyint=60:no-scenecut=1 -c:a copy output.mp4

In order to implement this code I used two examples I found:

   - https://ffmpeg.org/doxygen/trunk/transcoding_8c-example.html
   - https://ffmpeg.org/doxygen/trunk/encode_video_8c-example.html

When I try to run my transcoder it doesn't produce the output and also
shows this logging message:

[libx264 @ 0x7fd99e801200] Input picture width (1920) is greater than
stride (0)

Am I missing something?

*The entire code, how to compile it and run it.*

https://github.com/leandromoreira/ffmpeg-libav-tutorial/blob/transcoding/2_transcoding.c
<https://github.com/leandromoreira/ffmpeg-libav-tutorial/blob/transcoding/2_transcoding.ccat>

gcc -g -Wall -o transcoding -lavformat -lavcodec -lswscale -lz
2_transcoding.c \
  && ./transcoding small_bunny_1080p_60fps.mp4 bunny_1s_gop.mp4

*A summary of my code:*

// a simple transcode context
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;

//I use two context
TranscodeContext *decoder = malloc(sizeof(TranscodeContext));
TranscodeContext *encoder = malloc(sizeof(TranscodeContext));

prepare_input(decoder);
prepare_output(decoder, encoder);

// decoding
while (av_read_frame(decoder->format_context, i_packet) >= 0) {
    decode_packet();
    encode_frame();
}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://ffmpeg.org/pipermail/libav-user/attachments/20171129/99b160e0/attachment.html>


More information about the Libav-user mailing list