diff options
author | dec05eba <dec05eba@protonmail.com> | 2024-06-03 10:11:49 +0200 |
---|---|---|
committer | dec05eba <dec05eba@protonmail.com> | 2024-06-03 10:11:49 +0200 |
commit | ac2add6f04a7b569cb679aa9caa504845441fdc6 (patch) | |
tree | c18b7acf95ae7a703665b6b868936042e58aec87 /src | |
parent | bccf6e2dfe2121cff96d2dd2e329704e33668a5f (diff) |
Force non av1 video codec for hls and aac, force aac for flv
Diffstat (limited to 'src')
-rw-r--r-- | src/main.cpp | 33 |
1 files changed, 28 insertions, 5 deletions
diff --git a/src/main.cpp b/src/main.cpp index 06ce49e..445625d 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -2128,7 +2128,7 @@ int main(int argc, char **argv) { file_extension = file_extension.substr(0, comma_index); } - const bool force_no_audio_offset = file_extension == "ts" || file_extension == "flv"; + const bool force_no_audio_offset = is_livestream || (file_extension != "mp4" && file_extension == "mkv" && file_extension != "webm"); if(egl.gpu_info.vendor != GSR_GPU_VENDOR_NVIDIA && file_extension == "mkv" && strcmp(video_codec_to_use, "h264") == 0) { video_codec_to_use = "hevc"; @@ -2215,10 +2215,33 @@ int main(int argc, char **argv) { // TODO: Allow hevc, vp9 and av1 in (enhanced) flv (supported since ffmpeg 6.1) const bool is_flv = strcmp(file_extension.c_str(), "flv") == 0; - if(video_codec != VideoCodec::H264 && is_flv) { - video_codec_to_use = "h264"; - video_codec = VideoCodec::H264; - fprintf(stderr, "Warning: hevc/av1 is not compatible with flv, falling back to h264 instead.\n"); + if(is_flv) { + if(video_codec != VideoCodec::H264) { + video_codec_to_use = "h264"; + video_codec = VideoCodec::H264; + fprintf(stderr, "Warning: hevc/av1 is not compatible with flv, falling back to h264 instead.\n"); + } + + if(audio_codec != AudioCodec::AAC) { + audio_codec_to_use = "aac"; + audio_codec = AudioCodec::AAC; + fprintf(stderr, "Warning: flv only supports aac, falling back to aac instead.\n"); + } + } + + const bool is_hls = strcmp(file_extension.c_str(), "m3u8") == 0; + if(is_hls) { + if(video_codec == VideoCodec::AV1 || video_codec == VideoCodec::AV1_HDR) { + video_codec_to_use = "hevc"; + video_codec = VideoCodec::HEVC; + fprintf(stderr, "Warning: av1 is not compatible with hls (m3u8), falling back to hevc instead.\n"); + } + + if(audio_codec != AudioCodec::AAC) { + audio_codec_to_use = "aac"; + audio_codec = AudioCodec::AAC; + fprintf(stderr, "Warning: hls (m3u8) only supports aac, falling back to aac instead.\n"); + } } const AVCodec *video_codec_f = nullptr; |