send additional packets to decoder as required

This commit is contained in:
byte[] 2020-05-18 23:05:27 -04:00
parent db8de06306
commit 9a614820f0

View file

@ -73,7 +73,20 @@ int main(int argc, char *argv[])
AVRational cur_time = { pkt.pts, vstream->time_base.den };
AVRational next_time = { pkt.pts + pkt.duration, vstream->time_base.den };
if (avcodec_send_packet(vctx, &pkt) != 0 || avcodec_receive_frame(vctx, frame) != 0) {
if (avcodec_send_packet(vctx, &pkt) != 0) {
// Decoder returned an error
printf("Couldn't read file\n");
return -1;
}
int ret = avcodec_receive_frame(vctx, frame);
if (ret == AVERROR(EAGAIN)) {
// Need more data, can't receive frame yet
continue;
}
if (ret != 0) {
// Decoder returned an error
printf("Couldn't read file\n");
return -1;