X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=nageru%2Fvideo_encoder.cpp;h=31c6b4d8e24834d960205a3790e8dcc02169d88f;hb=23a236b4b2c551376b90c31d9a6cf72025da368c;hp=c75c4e3f365f851a0aa056fdebb3bacd7701bf9a;hpb=f0db8fcc58dd66a7dfd019f99add721d8161b75a;p=nageru diff --git a/nageru/video_encoder.cpp b/nageru/video_encoder.cpp index c75c4e3..31c6b4d 100644 --- a/nageru/video_encoder.cpp +++ b/nageru/video_encoder.cpp @@ -12,6 +12,9 @@ extern "C" { } #include "audio_encoder.h" +#ifdef HAVE_AV1 +#include "av1_encoder.h" +#endif #include "defs.h" #include "shared/ffmpeg_raii.h" #include "flags.h" @@ -61,8 +64,14 @@ VideoEncoder::VideoEncoder(ResourcePool *resource_pool, QSurface *surface, const if (global_flags.x264_video_to_http || global_flags.x264_video_to_disk) { x264_encoder.reset(new X264Encoder(oformat, /*use_separate_disk_params=*/false)); } - X264Encoder *http_encoder = x264_encoder.get(); - X264Encoder *disk_encoder = x264_encoder.get(); + VideoCodecInterface *http_encoder = x264_encoder.get(); + VideoCodecInterface *disk_encoder = x264_encoder.get(); +#ifdef HAVE_AV1 + if (global_flags.av1_video_to_http) { + av1_encoder.reset(new AV1Encoder(oformat)); + http_encoder = av1_encoder.get(); + } +#endif if (global_flags.x264_separate_disk_encode) { x264_disk_encoder.reset(new X264Encoder(oformat, /*use_separate_disk_params=*/true)); disk_encoder = x264_disk_encoder.get(); @@ -77,6 +86,11 @@ VideoEncoder::VideoEncoder(ResourcePool *resource_pool, QSurface *surface, const if (global_flags.x264_video_to_http) { x264_encoder->add_mux(stream_mux.get()); } +#ifdef HAVE_AV1 + if (global_flags.av1_video_to_http) { + av1_encoder->add_mux(stream_mux.get()); + } +#endif } VideoEncoder::~VideoEncoder() @@ -201,6 +215,8 @@ void VideoEncoder::open_output_stream() Mux::Codec video_codec; if (global_flags.uncompressed_video_to_http) { video_codec = Mux::CODEC_NV12; + } else if (global_flags.av1_video_to_http) { + video_codec = Mux::CODEC_AV1; } else { video_codec = Mux::CODEC_H264; } @@ -208,8 +224,12 @@ void VideoEncoder::open_output_stream() avctx->flags = AVFMT_FLAG_CUSTOM_IO; string video_extradata; - if (global_flags.x264_video_to_http || global_flags.x264_video_to_disk) { + if (global_flags.x264_video_to_http) { video_extradata = x264_encoder->get_global_headers(); +#ifdef HAVE_AV1 + } else if (global_flags.av1_video_to_http) { + video_extradata = av1_encoder->get_global_headers(); +#endif } stream_mux.reset(new Mux(avctx, width, height, video_codec, video_extradata, stream_audio_encoder->get_codec_parameters().get(),