diff options
author | Seungha Yang <seungha@centricular.com> | 2020-10-06 03:47:42 +0900 |
---|---|---|
committer | Seungha Yang <seungha@centricular.com> | 2020-10-06 19:21:36 +0900 |
commit | 89bb244ab9fe57645c8da2ac7b267a0469048e4e (patch) | |
tree | b84136be1f683fd0d5b774133ff0a37ca5ca849e /ext/libav/gstavutils.h | |
parent | e30cef412942f945fe13e5d819fdddcf6915fd53 (diff) | |
download | gst-libav-89bb244ab9fe57645c8da2ac7b267a0469048e4e.tar.gz |
avaudenc/avvidenc: Reopen encoding session if it's required
Since the commit https://git.ffmpeg.org/gitweb/ffmpeg.git/commit/22b25b3ea5c,
ffmpeg will not clear draning flag for encoder by avcodec_flush_buffers() API
by default. Allowed case is only if encoder has AV_CODEC_CAP_ENCODER_FLUSH
capability flag. If it's not supported, we should re-open encoding
session, otherwise ffmpeg encoder will keep returning AVERROR_EOF
Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-libav/-/merge_requests/99>
Diffstat (limited to 'ext/libav/gstavutils.h')
-rw-r--r-- | ext/libav/gstavutils.h | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/ext/libav/gstavutils.h b/ext/libav/gstavutils.h index d18b979..7b41b66 100644 --- a/ext/libav/gstavutils.h +++ b/ext/libav/gstavutils.h @@ -29,6 +29,26 @@ #include <gst/gst.h> +/* Introduced since ffmpeg version 4.3 + * + * Note: Not all ffmpeg encoders seem to be reusable after flushing/draining. + * So if ffmpeg encoder doesn't support it, we should reopen encoding session. + * + * Before ffmpeg 4.3, avcodec_flush_buffers() was implemented in + * libavcodec/decodec.c but it was moved to libavcodec/utils.c and it would be + * accepted if encoder supports AV_CODEC_CAP_ENCODER_FLUSH flag. + * That implies that avcodec_flush_buffers() wasn't intended to be working + * properly for encoders. + */ +#ifndef AV_CODEC_CAP_ENCODER_FLUSH +/* + * This encoder can be flushed using avcodec_flush_buffers(). If this flag is + * not set, the encoder must be closed and reopened to ensure that no frames + * remain pending. + */ +#define AV_CODEC_CAP_ENCODER_FLUSH (1 << 21) +#endif + /* *Get the size of an picture */ @@ -79,7 +99,7 @@ gst_ffmpeg_time_gst_to_ff (guint64 time, AVRational base) return out; } -void +void gst_ffmpeg_init_pix_fmt_info(void); int |