背景
当前FFmpeg支持flv+h264的编解码和转码,但是并不支持flv+h265
如果需要在FFmpeg中支持flv+h265,只需要简单的修改代码
源码修改
flv.h
diff --git a/libavformat/flv.h b/libavformat/flv.h
index 3571b90..91f0065 100644
--- a/libavformat/flv.h
+++ b/libavformat/flv.h
@@ -110,6 +110,7 @@ enum {
FLV_CODECID_H264 = 7,
FLV_CODECID_REALH263= 8,
FLV_CODECID_MPEG4 = 9,
+ FLV_CODECID_HEVC = 12,
};
enum {
flvenc.c
diff --git a/libavformat/flvenc.c b/libavformat/flvenc.c
index 1cfcdc6..9eed7c5 100644
--- a/libavformat/flvenc.c
+++ b/libavformat/flvenc.c
@@ -27,6 +27,7 @@
#include "avio_internal.h"
#include "avio.h"
#include "avc.h"
+#include "hevc.h"
#include "avformat.h"
#include "flv.h"
#include "internal.h"
@@ -46,6 +47,7 @@ static const AVCodecTag flv_video_codec_ids[] = {
{ AV_CODEC_ID_VP6, FLV_CODECID_VP6 },
{ AV_CODEC_ID_VP6A, FLV_CODECID_VP6A },
{ AV_CODEC_ID_H264, FLV_CODECID_H264 },
+ { AV_CODEC_ID_HEVC, FLV_CODECID_HEVC },
{ AV_CODEC_ID_NONE, 0 }
};
@@ -479,9 +481,9 @@ static int unsupported_codec(AVFormatContext *s,
{
const AVCodecDescriptor *desc = avcodec_descriptor_get(codec_id);
av_log(s, AV_LOG_ERROR,
- "%s codec %s not compatible with flv\n",
+ "here %s codec %s not compatible with flv %d\n",
type,
- desc ? desc->name : "unknown");
+ desc ? desc->name : "unknown", codec_id);
return AVERROR(ENOSYS);
}
@@ -490,7 +492,7 @@ static void flv_write_codec_header(AVFormatContext* s, AVCodecParameters* par, i