From c0c7da749db01b10137d2e6c5595617666d2264f Mon Sep 17 00:00:00 2001 From: Jonathan Thomas Date: Mon, 10 Mar 2025 14:46:00 -0500 Subject: [PATCH 1/2] Set libx265 hvc1 tag (for Apple playback compatibility). Apparently, we can't just set this on the mux_dict, but rather set the tag on the video codec (libx265). --- src/FFmpegWriter.cpp | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/src/FFmpegWriter.cpp b/src/FFmpegWriter.cpp index 3ef7ccab..a17cc442 100644 --- a/src/FFmpegWriter.cpp +++ b/src/FFmpegWriter.cpp @@ -647,11 +647,6 @@ void FFmpegWriter::WriteHeader() { av_dict_set(&oc->metadata, iter->first.c_str(), iter->second.c_str(), 0); } - // For HEVC (H265) to playback on Apple devices: https://github.com/OpenShot/libopenshot/issues/990 - if (info.has_video && video_codec_ctx && video_codec_ctx->codec_id == AV_CODEC_ID_HEVC) { - av_dict_set(&mux_dict, "tag:v", "hvc1", 0); - } - // Set multiplexing parameters (only for MP4/MOV containers) AVDictionary *dict = NULL; if (mux_dict) { @@ -1544,6 +1539,17 @@ void FFmpegWriter::open_video(AVFormatContext *oc, AVStream *st) { } #endif // USE_HW_ACCEL +// Set libx265 hvc1 tag (for Apple playback compatibility). +#if USE_HW_ACCEL + if (!(hw_en_on && hw_en_supported) && video_codec_ctx->codec_id == AV_CODEC_ID_HEVC) { + video_codec_ctx->codec_tag = MKTAG('h', 'v', 'c', '1'); + } +#else + if (video_codec_ctx->codec_id == AV_CODEC_ID_HEVC) { + video_codec_ctx->codec_tag = MKTAG('h', 'v', 'c', '1'); + } +#endif + /* open the codec */ if (avcodec_open2(video_codec_ctx, codec, &opts) < 0) throw InvalidCodec("Could not open video codec", path); From e81e7922b287d85a5c5b0ec90ea7c8b864d9d233 Mon Sep 17 00:00:00 2001 From: Jonathan Thomas Date: Mon, 10 Mar 2025 17:43:31 -0500 Subject: [PATCH 2/2] Adding alpha to JSON properties of wave_color (for the clip class). --- src/Clip.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Clip.cpp b/src/Clip.cpp index ed135743..d8b61b3a 100644 --- a/src/Clip.cpp +++ b/src/Clip.cpp @@ -841,7 +841,7 @@ std::string Clip::PropertiesJSON(int64_t requested_frame) const { root["wave_color"]["red"] = add_property_json("Red", wave_color.red.GetValue(requested_frame), "float", "", &wave_color.red, 0, 255, false, requested_frame); root["wave_color"]["blue"] = add_property_json("Blue", wave_color.blue.GetValue(requested_frame), "float", "", &wave_color.blue, 0, 255, false, requested_frame); root["wave_color"]["green"] = add_property_json("Green", wave_color.green.GetValue(requested_frame), "float", "", &wave_color.green, 0, 255, false, requested_frame); - + root["wave_color"]["alpha"] = add_property_json("Alpha", wave_color.alpha.GetValue(requested_frame), "float", "", &wave_color.alpha, 0, 255, false, requested_frame); // Return formatted string return root.toStyledString();