git.iko.soy/typeable/nixpkgs
on master help sign in
Merge pull request #120246 from Profpatsch/mpvScripts-convert-fix-patch

mpvScripts: update convert script patch to work with current mpv

commit0f080fb7f4a37b289de97981e99b5e1d1a374103 authorJörg Thalheim <Mic92@users.noreply.github.com> dateFri 23 Apr 2021, 05:47 (6 years ago) parent2ce1d7a72cc405
2 files changed+70−35
pkgs/applications/video/mpv/scripts/convert.nix+12−12 pkgs/applications/video/mpv/scripts/convert.patch+58−23
pkgs/applications/video/mpv/scripts/convert.nix+12−12
@@ -12,15 +12,17 @@ stdenvNoCC.mkDerivation {
1212
1313 patches = [ ./convert.patch ];
1414
15− postPatch =
16− let
17− t = k: v: '' 'local ${k} = "${v}"' '';
18− subs = var: orig: repl: "--replace " + t var orig + t var repl;
19− in ''
20− substituteInPlace convert_script.lua \
21− ${subs "NOTIFY_CMD" "notify-send" "${libnotify}/bin/notify-send"} \
22− ${subs "YAD_CMD" "yad" "${yad}/bin/yad"} \
23− ${subs "MKVMERGE_CMD" "mkvmerge" "${mkvtoolnix-cli}/bin/mkvmerge"}
15+ postPatch = ''
16+ substituteInPlace convert_script.lua \
17+ --replace 'mkvpropedit_exe = "mkvpropedit"' \
18+ 'mkvpropedit_exe = "${mkvtoolnix-cli}/bin/mkvpropedit"' \
19+ --replace 'mkvmerge_exe = "mkvmerge"' \
20+ 'mkvmerge_exe = "${mkvtoolnix-cli}/bin/mkvmerge"' \
21+ --replace 'yad_exe = "yad"' \
22+ 'yad_exe = "${yad}/bin/yad"' \
23+ --replace 'notify_send_exe = "notify-send"' \
24+ 'notify_send_exe = "${libnotify}/bin/notify-send"' \
25+
2426 '';
2527
2628 dontBuild = true;
@@ -38,9 +40,7 @@ stdenvNoCC.mkDerivation {
3840 When this script is loaded into mpv, you can hit Alt+W to mark the beginning
3941 and Alt+W again to mark the end of the clip. Then a settings window opens.
4042 '';
43+ # author was asked to add a license https://gist.github.com/Zehkul/25ea7ae77b30af959be0#gistcomment-3715700
4144 license = licenses.unfree;
42− # script crashes mpv. See https://github.com/NixOS/nixpkgs/issues/113202
43− broken = true;
4445 };
4546}
46−
pkgs/applications/video/mpv/scripts/convert.patch+58−23
@@ -1,17 +1,45 @@
1−--- convert/convert_script.lua 2016-03-18 19:30:49.675401969 +0100
2−+++ convert_script.lua 2016-03-19 01:18:00.801897043 +0100
3−@@ -3,6 +3,10 @@
1+diff --git "a/Convert Script \342\200\223 README.md" "b/Convert Script \342\200\223 README.md"
2+index 8e062c1..6e0d798 100644
3+--- "a/Convert Script \342\200\223 README.md"
4++++ "b/Convert Script \342\200\223 README.md"
5+@@ -68,7 +68,7 @@ and set some options in ``mpv/lua-settings/convert_script.conf`` or with ``--scr
6+ If you don’t want to upgrade your yad. Features like appending segments won’t be available.
7+
8+ libvpx_fps
9+- Default: --oautofps
10++ Default: ""
11+ FPS settings (or any other settings really) for libvpx encoding. Set it to --ofps=24000/1001 for example.
12+
13+-Warning: Some of these options aren’t very robust and setting them to bogus values will break the script.
14+\ No newline at end of file
15++Warning: Some of these options aren’t very robust and setting them to bogus values will break the script.
16+diff --git a/convert_script.lua b/convert_script.lua
17+index 17d3100..90f88ec 100644
18+--- a/convert_script.lua
19++++ b/convert_script.lua
20+@@ -3,6 +3,12 @@ local msg = require 'mp.msg'
421 local opt = require 'mp.options'
522 local utils = require 'mp.utils'
623
7−+local NOTIFY_CMD = "notify-send"
8−+local YAD_CMD = "yad"
9−+local MKVMERGE_CMD = "mkvmerge"
24++-- executables
25++local mkvpropedit_exe = "mkvpropedit"
26++local mkvmerge_exe = "mkvmerge"
27++local yad_exe = "yad"
28++local notify_send_exe = "notify-send"
1029+
1130 -- default options, convert_script.conf is read
1231 local options = {
1332 bitrate_multiplier = 0.975, -- to make sure the file won’t go over the target file size, set it to 1 if you don’t care
14−@@ -247,12 +247,12 @@
33+@@ -14,7 +20,7 @@ local options = {
34+ libvpx_options = "--ovcopts-add=cpu-used=0,auto-alt-ref=1,lag-in-frames=25,quality=good",
35+ libvpx_vp9_options = "",
36+ legacy_yad = false, -- if you don’t want to upgrade to at least yad 0.18
37+- libvpx_fps = "--oautofps", -- --ofps=24000/1001 for example
38++ libvpx_fps = "", -- --ofps=24000/1001 for example
39+ audio_bitrate = 112, -- mpv default, in kbps
40+ }
41+
42+@@ -247,12 +253,12 @@ function encode(enc)
1543 if string.len(vf) > 0 then
1644 vf = vf .. ","
1745 end
@@ -26,42 +54,49 @@
2654 local audio_file = ""
2755 for index, param in pairs(audio_file_table) do
2856 audio_file = audio_file .. " --audio-file='" .. string.gsub(tostring(param), "'", "'\\''") .. "'"
29−@@ -354,9 +358,9 @@
57+@@ -354,9 +360,9 @@ function encode(enc)
3058 if ovc == "gif" then
3159 full_command = full_command .. ' --vf-add=lavfi=graph=\\"framestep=' .. framestep .. '\\" && convert '
3260 .. tmpfolder .. '/*.png -set delay ' .. delay .. ' -loop 0 -fuzz ' .. fuzz .. '% ' .. dither .. ' -layers optimize '
3361- .. full_output_path .. ' && rm -rf ' .. tmpfolder .. ' && notify-send "Gif done") & disown'
34−+ .. full_output_path .. ' && rm -rf ' .. tmpfolder .. ' && ' .. NOTIFY_CMD .. ' "Gif done") & disown'
62++ .. full_output_path .. ' && rm -rf ' .. tmpfolder .. ' && ' .. notify_send_exe .. ' "Gif done") & disown'
3563 else
3664- full_command = full_command .. ' && notify-send "Encoding done"; mkvpropedit '
37−+ full_command = full_command .. ' && ' .. NOTIFY_CMD .. ' "Encoding done"; mkvpropedit '
65++ full_command = full_command .. ' && ' .. notify_send_exe .. ' "Encoding done"; ' .. mkvpropedit_exe .. ' '
3866 .. full_output_path .. ' -s title="' .. metadata_title .. '") & disown'
3967 end
4068
41−@@ -409,7 +413,7 @@
69+@@ -409,7 +415,7 @@ function encode_copy(enc)
4270 sep = ",+"
4371
4472 if enc then
4573- local command = "mkvmerge '" .. video .. "' " .. mkvmerge_parts .. " -o " .. full_output_path
46−+ local command = MKVMERGE_CMD .. " '" .. video .. "' " .. mkvmerge_parts .. " -o " .. full_output_path
74++ local command = mkvmerge_exe .. " '" .. video .. "' " .. mkvmerge_parts .. " -o " .. full_output_path
4775 msg.info(command)
4876 os.execute(command)
4977 clear()
50−@@ -508,7 +512,7 @@
78+@@ -508,7 +514,7 @@ function call_gui ()
5179 end
5280
5381
5482- local yad_command = [[LC_NUMERIC=C yad --title="Convert Script" --center --form --fixed --always-print-result \
55−+ local yad_command = [[LC_NUMERIC=C ]] .. YAD_CMD .. [[ --title="Convert Script" --center --form --fixed --always-print-result \
83++ local yad_command = [[LC_NUMERIC=C ]] .. yad_exe .. [[ --title="Convert Script" --center --form --fixed --always-print-result \
5684 --name "convert script" --class "Convert Script" --field="Resize to height:NUM" "]] .. scale_sav --yad_table 1
5785 .. [[" --field="Resize to width instead:CHK" ]] .. resize_to_width_instead .. " " --yad_table 2
5886 if options.legacy_yad then
59−@@ -543,7 +547,7 @@
60− yad_command = yad_command .. [[ --button="Crop:1" --button="gtk-cancel:2" --button="gtk-ok:0"; ret=$? && echo $ret]]
61−
62− if gif_dialog then
63−- yad_command = [[echo $(LC_NUMERIC=C yad --title="Gif settings" --name "convert script" --class "Convert Script" \
64−+ yad_command = [[echo $(LC_NUMERIC=C ]] .. YAD_CMD .. [[ --title="Gif settings" --name "convert script" --class "Convert Script" \
65− --center --form --always-print-result --separator="…" \
66− --field="Fuzz Factor:NUM" '1!0..100!0.5!1' \
67− --field="Framestep:NUM" '3!1..3!1' \
87+@@ -524,7 +530,7 @@ function call_gui ()
88+ yad_command = yad_command
89+ .. [[--field="2pass:CHK" "false" ]] --yad_table 5
90+ .. [[--field="Encode options::CBE" '! --ovcopts=b=2000,cpu-used=0,auto-alt-ref=1,lag-in-frames=25,quality=good,threads=4' ]] --yad_table 6
91+- .. [[--field="Output format::CBE" ' --ovc=libx264! --oautofps --of=webm --ovc=libvpx' ]]
92++ .. [[--field="Output format::CBE" ' --ovc=libx264! --of=webm --ovc=libvpx' ]]
93+ .. [[--field="Simple:FBTN" 'bash -c "echo \"simple\" && kill -s SIGUSR1 \"$YAD_PID\""' ]]
94+ advanced = true
95+ else
96+@@ -734,4 +740,4 @@ mp.set_key_bindings({
97+
98+ mp.add_key_binding("alt+w", "convert_script", convert_script_hotkey_call)
99+
100+-mp.register_event("tick", tick)
101+\ No newline at end of file
102++mp.register_event("tick", tick)