diff options
author | Simon Ser <contact@emersion.fr> | 2021-03-22 11:42:57 +0100 |
---|---|---|
committer | Kenny Levinsen <kl@kl.wtf> | 2021-03-22 17:15:06 +0100 |
commit | 6230f7be4f92b83df7ea8e6487410b3b81dd4b1d (patch) | |
tree | f3386b55997e1c48476b3ac2cdf1dc97b811e879 | |
parent | e8ad05913fb9fbefd2aa4b89cebfca03ab2bd1eb (diff) |
examples/dmabuf-capture: stop using av_init_packet
It's deprecated in ffmpeg >= 4.4.
Closes: https://github.com/swaywm/wlroots/issues/2798
-rw-r--r-- | examples/dmabuf-capture.c | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/examples/dmabuf-capture.c b/examples/dmabuf-capture.c index 60cdb657..4d05b78b 100644 --- a/examples/dmabuf-capture.c +++ b/examples/dmabuf-capture.c @@ -490,26 +490,27 @@ static void *vid_encode_thread(void *arg) { } while (1) { - AVPacket pkt; - av_init_packet(&pkt); - - int ret = avcodec_receive_packet(ctx->avctx, &pkt); + AVPacket *pkt = av_packet_alloc(); + int ret = avcodec_receive_packet(ctx->avctx, pkt); if (ret == AVERROR(EAGAIN)) { + av_packet_free(&pkt); break; } else if (ret == AVERROR_EOF) { av_log(ctx, AV_LOG_INFO, "Encoder flushed!\n"); + av_packet_free(&pkt); goto end; } else if (ret) { av_log(ctx, AV_LOG_ERROR, "Error encoding: %s!\n", av_err2str(ret)); + av_packet_free(&pkt); err = ret; goto end; } - pkt.stream_index = 0; - err = av_interleaved_write_frame(ctx->avf, &pkt); + pkt->stream_index = 0; + err = av_interleaved_write_frame(ctx->avf, pkt); - av_packet_unref(&pkt); + av_packet_free(&pkt); if (err) { av_log(ctx, AV_LOG_ERROR, "Writing packet fail: %s!\n", |