Skip to content

Commit 2c71ae4

Browse files
committed
FFmpegWriter: Fixes for building with libav
- libav defines AV_CODEC_ID_HEVC but not AV_CODEC_ID_H265 - AVCodecContext->framerate was actually added in FFmpeg 2.2 which corresponds to libavcodec 56.26
1 parent 99565bb commit 2c71ae4

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

src/FFmpegWriter.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -423,7 +423,7 @@ void FFmpegWriter::SetOption(StreamType stream, std::string name, std::string va
423423
av_opt_set(c->priv_data, "preset", "veryslow", 0);
424424
}
425425
break;
426-
case AV_CODEC_ID_H265 :
426+
case AV_CODEC_ID_HEVC :
427427
av_opt_set_int(c->priv_data, "qp", std::min(std::stoi(value), 51), 0); // 0-51
428428
if (std::stoi(value) == 0) {
429429
av_opt_set(c->priv_data, "preset", "veryslow", 0);
@@ -482,7 +482,7 @@ void FFmpegWriter::SetOption(StreamType stream, std::string name, std::string va
482482
av_opt_set(c->priv_data, "preset", "veryslow", 0);
483483
}
484484
break;
485-
case AV_CODEC_ID_H265 :
485+
case AV_CODEC_ID_HEVC :
486486
av_opt_set_int(c->priv_data, "crf", std::min(std::stoi(value), 51), 0); // 0-51
487487
if (std::stoi(value) == 0) {
488488
av_opt_set(c->priv_data, "preset", "veryslow", 0);
@@ -1162,7 +1162,7 @@ AVStream *FFmpegWriter::add_video_stream() {
11621162
case AV_CODEC_ID_AV1 :
11631163
#endif
11641164
case AV_CODEC_ID_VP9 :
1165-
case AV_CODEC_ID_H265 :
1165+
case AV_CODEC_ID_HEVC :
11661166
#endif
11671167
case AV_CODEC_ID_VP8 :
11681168
case AV_CODEC_ID_H264 :
@@ -1200,7 +1200,8 @@ AVStream *FFmpegWriter::add_video_stream() {
12001200
identically 1. */
12011201
c->time_base.num = info.video_timebase.num;
12021202
c->time_base.den = info.video_timebase.den;
1203-
#if LIBAVFORMAT_VERSION_MAJOR >= 56
1203+
// AVCodecContext->framerate was added in FFmpeg 2.2
1204+
#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(56, 26, 0)
12041205
c->framerate = av_inv_q(c->time_base);
12051206
#endif
12061207
st->avg_frame_rate = av_inv_q(c->time_base);

0 commit comments

Comments
 (0)