[Libav-user] Getting a Frame question

Charles linux2 at orion15.org
Sun Sep 4 05:11:15 EEST 2016


On 09/03/2016 08:34 PM, Gonzalo GarramuƱo wrote:
>
>
> El 03/09/2016 a las 17:55, M J escribiĆ³:
>> Hi
>>
>> while(av_read_frame(input_ctx, pkts) == 0)
>> {
>>          //decoding
>>          int ret1 = avcodec_send_packet(input_codecCtx, pkts);
>>          int ret2 = avcodec_receive_frame(input_codecCtx, rawFrame);
>>
>>          //encoding
>>          avcodec_send_frame(output_codecCtx, rawFrame);
>>          avcodec_receive_packet(output_codecCtx, pktr);
>>
>>          int ret = av_interleaved_write_frame(output_ctx, pktr);
>> }
>> *************************************************
> Hi, MJ.
>
> AFAIK, the new API does not work yet.  Use the deprecated functions for the time being.
>
It appears to work I have been decoding and encoding using the send / receive, video only.

You probably need to deal with multiple conditional returns from both decode and encode.
i.e avcodec_send_packet can produce multiple frames, you need to receive output in a loop not just the input file.
See https://ffmpeg.org/doxygen/3.1/group__lavc__encdec.html

Another possible issue may be with the setup and connecting everything.
I had issue until the usage was correct for codecpar.

Decode:
avformat_alloc_context / avformat_open_input / avformat_find_stream_info / avcodec_find_decoder / avcodec_alloc_context3
Then
avcodec_parameters_to_context
avcodec_open2

Encode:
avcodec_find_encoder / avformat_alloc_output_context2 / avcodec_alloc_context3 / avformat_new_stream / av_codec_get_tag2
Then
// I had to manually set the output stream codec_tag / time_base / av_stream_set_r_frame_rate
avcodec_parameters_from_context
avcodec_open2

The parameters TO/FROM context connects most of it together.

Thanks
cco


More information about the Libav-user mailing list