--- a/moc/decoder_plugins/ffmpeg/ffmpeg.c	2019-02-27 09:26:51.000000000 +0900
+++ b/moc/decoder_plugins/ffmpeg/ffmpeg.c	2023-09-01 23:01:03.812904000 +0900
@@ -32,6 +32,7 @@
 #include <stdint.h>
 #include <errno.h>
 
+#include <libavcodec/avcodec.h>
 #include <libavformat/avformat.h>
 #include <libavutil/mathematics.h>
 #if HAVE_LIBAVUTIL_CHANNEL_LAYOUT_H
@@ -761,8 +762,10 @@ static void *ffmpeg_open_internal (struc
 	}
 
 	set_downmixing (data);
+#if defined(FF_API_FLAG_TRUNCATED) && FF_API_FLAG_TRUNCATED
 	if (data->codec->capabilities & AV_CODEC_CAP_TRUNCATED)
 		data->enc->flags |= AV_CODEC_FLAG_TRUNCATED;
+#endif
 
 	if (avcodec_open2 (data->enc, data->codec, NULL) < 0)
 	{
@@ -1021,8 +1024,7 @@ static AVPacket *get_packet (struct ffmp
 }
 
 #ifndef HAVE_AVCODEC_RECEIVE_FRAME
-/* Decode samples from packet data using avcodec_decode_audio4(). */
-# define decode_audio avcodec_decode_audio4
+# error Too old FFmpeg version.
 #endif
 
 #ifdef HAVE_AVCODEC_RECEIVE_FRAME
@@ -1171,7 +1173,7 @@ static bool seek_in_stream (struct ffmpe
 static bool seek_in_stream (struct ffmpeg_data *data, int sec)
 #endif
 {
-	int rc, flags = AVSEEK_FLAG_ANY;
+	int rc;
 	int64_t seek_ts;
 
 #if SEEK_IN_DECODER
@@ -1197,10 +1199,8 @@ static bool seek_in_stream (struct ffmpe
 		seek_ts += data->stream->start_time;
 	}
 
-	if (data->stream->cur_dts > seek_ts)
-		flags |= AVSEEK_FLAG_BACKWARD;
-
-	rc = av_seek_frame (data->ic, data->stream->index, seek_ts, flags);
+	rc = av_seek_frame (data->ic, data->stream->index, seek_ts,
+						AVSEEK_FLAG_BACKWARD);
 	if (rc < 0) {
 		log_errno ("Seek error", rc);
 		return false;
