From f2a7463ff32f510d2f981f5b0e165c4bf0a31322 Mon Sep 17 00:00:00 2001 From: Kieran Date: Wed, 10 Apr 2024 22:22:17 -0700 Subject: [PATCH] [Enhancement] Improve support for 4k videos with Plex (#181) * Added WIP 4k MP4 fix [skip ci] * Added tests for new remux options --- .../downloading/download_option_builder.ex | 14 ++++++++------ .../downloading/download_option_builder_test.exs | 3 +++ 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/lib/pinchflat/downloading/download_option_builder.ex b/lib/pinchflat/downloading/download_option_builder.ex index 180c4bc..69fd061 100644 --- a/lib/pinchflat/downloading/download_option_builder.ex +++ b/lib/pinchflat/downloading/download_option_builder.ex @@ -106,16 +106,18 @@ defmodule Pinchflat.Downloading.DownloadOptionBuilder do end defp quality_options(media_profile) do - video_codec_options = "+codec:avc:m4a" + video_codec_option = fn res -> + [format_sort: "res:#{res},+codec:avc:m4a", remux_video: "mp4"] + end case media_profile.preferred_resolution do # Also be aware that :audio disabled all embedding options for subtitles :audio -> [:extract_audio, format: "bestaudio[ext=m4a]"] - :"360p" -> [format_sort: "res:360,#{video_codec_options}"] - :"480p" -> [format_sort: "res:480,#{video_codec_options}"] - :"720p" -> [format_sort: "res:720,#{video_codec_options}"] - :"1080p" -> [format_sort: "res:1080,#{video_codec_options}"] - :"2160p" -> [format_sort: "res:2160,#{video_codec_options}"] + :"360p" -> video_codec_option.("360") + :"480p" -> video_codec_option.("480") + :"720p" -> video_codec_option.("720") + :"1080p" -> video_codec_option.("1080") + :"2160p" -> video_codec_option.("2160") end end diff --git a/test/pinchflat/downloading/download_option_builder_test.exs b/test/pinchflat/downloading/download_option_builder_test.exs index 5314f89..d5c4dab 100644 --- a/test/pinchflat/downloading/download_option_builder_test.exs +++ b/test/pinchflat/downloading/download_option_builder_test.exs @@ -240,6 +240,7 @@ defmodule Pinchflat.Downloading.DownloadOptionBuilderTest do assert {:ok, res} = DownloadOptionBuilder.build(media_item) assert {:format_sort, "res:#{resolution},+codec:avc:m4a"} in res + assert {:remux_video, "mp4"} in res end) end @@ -250,6 +251,8 @@ defmodule Pinchflat.Downloading.DownloadOptionBuilderTest do assert :extract_audio in res assert {:format, "bestaudio[ext=m4a]"} in res + + refute {:remux_video, "mp4"} in res end end