-
-
Save davehorner/c38b235e995268b7631ae1864e66fdea to your computer and use it in GitHub Desktop.
Revisions
-
Zehkul renamed this gist
Jul 2, 2015 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. -
Zehkul renamed this gist
Jul 2, 2015 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. -
Zehkul revised this gist
Jun 15, 2015 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -2,7 +2,7 @@ This script for mpv intends to offer the fastest and simplest way to convert parts of a video—while you’re watching it and not really more work intensive than making a screenshot. A short demonstration: https://d.maxfile.ro/omdwzyhkoa.webm ##Installation: -
Zehkul revised this gist
Jun 12, 2015 . 1 changed file with 3 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -293,7 +293,9 @@ function encode(enc) else encode_options = encode_options .. options.libvpx_vp9_options --libvpx-vp9 produces slightly bigger files if bitrate then bitrate = bitrate * 0.93 end end -
Zehkul revised this gist
Jun 12, 2015 . 1 changed file with 11 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -12,6 +12,7 @@ local options = { libvpx_threads = 4, -- libvpx only crop_individually = true, libvpx_options = "--ovcopts-add=cpu-used=0,auto-alt-ref=1,lag-in-frames=25,quality=good", libvpx_vp9_options = "", legacy_yad = false, -- if you don’t want to upgrade to at least yad 0.18 libvpx_fps = "--oautofps", -- --ofps=24000/1001 for example audio_bitrate = 112, -- mpv default, in kbps @@ -286,8 +287,16 @@ function encode(enc) end local encode_options = ' ' .. ovc_c if ovc == "libvpx" or ovc == "libvpx-vp9" then encode_options = encode_options .. ' ' .. options.libvpx_fps .. ' --ovcopts-add=threads=' .. options.libvpx_threads .. ' ' if ovc == "libvpx" then encode_options = encode_options .. options.libvpx_options else encode_options = encode_options .. options.libvpx_vp9_options --libvpx-vp9 produces slightly bigger files bitrate = bitrate * 0.93 end end if twopass then encode_options = encode_options .. ' --ovcopts-add=b=' .. bitrate -
Zehkul revised this gist
Jun 12, 2015 . 1 changed file with 14 additions and 10 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -285,7 +285,7 @@ function encode(enc) ovc_c = ' ' end local encode_options = ' ' .. ovc_c if ovc == "libvpx" or ovc == "libvpx-vp9" then encode_options = encode_options .. ' ' .. options.libvpx_fps .. ' ' .. options.libvpx_options .. ' --ovcopts-add=threads=' .. options.libvpx_threads end @@ -295,7 +295,7 @@ function encode(enc) if not (ovc == "gif") then encode_options = encode_options .. ' --ovcopts-add=crf=' .. tostring(crf) end if ovc == "libvpx" or ovc == "libvpx-vp9" then encode_options = encode_options .. ' --ovcopts-add=b=10000000' end end @@ -454,24 +454,26 @@ function call_gui () end if yad_table[7] == "vp8/webm" then format_dropdown_content = "'^vp8/webm!vp9/webm!h264/mkv!h264/mp4!h265/mkv!gif!stream copy/mkv'" elseif yad_table[7] == "vp9/webm" then format_dropdown_content = "'vp8/webm!^vp9/webm!h264/mkv!h264/mp4!h265/mkv!gif!stream copy/mkv'" elseif yad_table[7] == "h264/mkv" then format_dropdown_content = "'vp8/webm!vp9/webm!^h264/mkv!h264/mp4!h265/mkv!gif!stream copy/mkv'" elseif yad_table[7] == "h264/mp4" then format_dropdown_content = "'vp8/webm!vp9/webm!h264/mkv!^h264/mp4!h265/mkv!gif!stream copy/mkv'" elseif yad_table[7] == "h265/mkv" then format_dropdown_content = "'vp8/webm!vp9/webm!h264/mkv!h264/mp4!^h265/mkv!gif!stream copy/mkv'" elseif yad_table[7] == "gif" then format_dropdown_content = "'vp8/webm!vp9/webm!h264/mkv!h264/mp4!h265/mkv!^gif!stream copy/mkv'" elseif yad_table[7] == "stream copy/mkv" then format_dropdown_content = "'vp8/webm!vp9/webm!h264/mkv!h264/mp4!h265/mkv!gif!^stream copy/mkv'" else format_dropdown_content = "'^vp8/webm!vp9/webm!h264/mkv!h264/mp4!h265/mkv!gif!stream copy/mkv'" end else mode_dropdown_content = "'Target file size (KiB)!Target file size (MiB)!CRF'" format_dropdown_content = "'vp8/webm!vp9/webm!h264/mkv!h264/mp4!h265/mkv!gif!stream copy/mkv'" yad_offset_10 = -2 end @@ -624,6 +626,8 @@ function call_gui () ovc = "libx265" elseif yad_table[7]:find("vp8") then ovc = "libvpx" elseif yad_table[7]:find("vp9") then ovc = "libvpx-vp9" elseif yad_table[7]:find("gif") then ovc = "gif" extension = ".gif" -
Zehkul revised this gist
Apr 18, 2015 . 2 changed files with 22 additions and 3 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -31,6 +31,10 @@ You can bind it to another hotkey in your input.conf with ``<key> script_message convert_script`` and set some options in ``mpv/lua-settings/convert_script.conf`` or with ``--script-opts`` (mpv 0.7 and earlier: ``--lua-opts``) audio_bitrate Default: 112 In kbps. The script tries to compensate for audio when going for a file size limit (2pass). You’ll only need to change this if you modify mpv’s audio encoding options, for example with oacopts-add=qscale=0 in the [encoding] section of your mpv.conf (in which case this option would need 64). bitrate_multiplier Default: 0.975 To make sure the file won’t go over the target file size, set it to 1 if you don’t care. This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -14,6 +14,7 @@ local options = { libvpx_options = "--ovcopts-add=cpu-used=0,auto-alt-ref=1,lag-in-frames=25,quality=good", legacy_yad = false, -- if you don’t want to upgrade to at least yad 0.18 libvpx_fps = "--oautofps", -- --ofps=24000/1001 for example audio_bitrate = 112, -- mpv default, in kbps } read_options(options, "convert_script") @@ -191,6 +192,7 @@ function preparations() local filename_ext = mp.get_property_osd("media-title") filename_ext = string.gsub(filename_ext, "'", "'\\''") local filename = string.gsub(filename_ext, "%....$","") metadata_title = filename if string.len(filename) > 230 then @@ -224,6 +226,13 @@ function encode(enc) aspect_first = rect_width / rect_height width_first = rect_width height_first = rect_height if not no_scale then if scale_width then width_first = scale else height_first = scale end end end rect_width, rect_height = nil end @@ -332,10 +341,12 @@ function encode(enc) end local delay = framestep * 4 if ovc == "gif" then full_command = full_command .. ' --vf-add=lavfi=graph=\\"framestep=' .. framestep .. '\\" && convert ' .. tmpfolder .. '/*.png -set delay ' .. delay .. ' -loop 0 -fuzz ' .. fuzz .. '% ' .. dither .. ' -layers optimize ' .. full_output_path .. ' && rm -rf ' .. tmpfolder .. ' && notify-send "Gif done") & disown' else full_command = full_command .. ' && notify-send "Encoding done"; mkvpropedit ' .. full_output_path .. ' -s title="' .. metadata_title .. '") & disown' end @@ -625,7 +636,11 @@ function call_gui () factor = 1048576 end if twopass then local total_bitrate = yad_table[6] * factor if audio == "" then total_bitrate = total_bitrate - ( options.audio_bitrate * 1000 * segments_length / 8 ) end bitrate = math.floor(total_bitrate*8/segments_length*options.bitrate_multiplier) else crf = yad_table[6] end -
Zehkul revised this gist
Apr 1, 2015 . 1 changed file with 0 additions and 6 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -254,7 +254,6 @@ function encode(enc) end local sub_auto = mp.get_property("options/sub-auto") local sub_delay = mp.get_property("sub-delay") local hr_seek_demuxer_offset = mp.get_property_native("options/hr-seek-demuxer-offset") preparations() @@ -270,11 +269,6 @@ function encode(enc) .. ' --sub-delay=' .. sub_delay .. ' --sub-auto=' .. sub_auto .. aid .. ' --vf-add=' .. vf .. ' --hr-seek-demuxer-offset=' .. hr_seek_demuxer_offset .. ' --af=' .. af .. ' ' .. audio_file if not (ovc == "gif") then ovc_c = ' --ovc=' .. ovc -
Zehkul revised this gist
Jan 23, 2015 . 1 changed file with 2 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -339,9 +339,9 @@ function encode(enc) local delay = framestep * 4 if ovc == "gif" then full_command = full_command .. ' --vf-add=lavfi=graph=\\"framestep=' .. framestep .. '\\" && convert ' .. tmpfolder .. '/*.png -set delay ' .. delay .. ' -loop 0 -fuzz ' .. fuzz .. '% ' .. dither .. ' -layers optimize ' .. full_output_path .. ' && rm -rf ' .. tmpfolder .. ' && notify-send "Gif done") & disown' else full_command = full_command .. ' && notify-send "Encoding done") & disown' end -
Zehkul revised this gist
Jan 23, 2015 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -341,7 +341,7 @@ function encode(enc) full_command = full_command .. ' --vf-add=lavfi=graph=\\"framestep=' .. framestep .. '\\" && convert ' .. tmpfolder .. '/*.png -set delay ' .. delay .. ' -loop 0 -fuzz ' .. fuzz .. '% ' .. dither .. ' -layers optimize ' .. full_output_path .. ' && rm -rf ' .. tmpfolder .. ' && notify-send "Gif done") &; disown' else full_command = full_command .. ' && notify-send "Encoding done") &; disown' end -
Zehkul revised this gist
Jan 23, 2015 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -339,7 +339,7 @@ function encode(enc) local delay = framestep * 4 if ovc == "gif" then full_command = full_command .. ' --vf-add=lavfi=graph=\\"framestep=' .. framestep .. '\\" && convert ' .. tmpfolder .. '/*.png -set delay ' .. delay .. ' -loop 0 -fuzz ' .. fuzz .. '% ' .. dither .. ' -layers optimize ' .. full_output_path .. ' && rm -rf ' .. tmpfolder .. ' && notify-send "Gif done") &; disown' else full_command = full_command .. ' && notify-send "Encoding done") &' end -
Zehkul revised this gist
Jan 23, 2015 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -290,7 +290,7 @@ function encode(enc) encode_options = encode_options .. ' --ovcopts-add=b=' .. bitrate else if not (ovc == "gif") then encode_options = encode_options .. ' --ovcopts-add=crf=' .. tostring(crf) end if ovc == "libvpx" then encode_options = encode_options .. ' --ovcopts-add=b=10000000' -
Zehkul revised this gist
Jan 21, 2015 . 1 changed file with 5 additions and 5 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -217,8 +217,8 @@ function encode(enc) end else -- odd numbers for video resolution are a bad idea rect_width = round(rect_width) - (math.fmod(round(rect_width), 2)) rect_height = round(rect_height) - (math.fmod(round(rect_height), 2)) crop = rect_width .. ":" .. rect_height .. ":" .. round(rect_x1) .. ":" .. round(rect_y1) if not aspect_first then aspect_first = rect_width / rect_height @@ -363,10 +363,10 @@ function encode(enc) if scale_width then local scale_2 = round(scale / aspect_first) scale = scale .. ":" .. (scale_2 - (math.fmod(scale_2, 2))) else local scale_2 = round(scale * aspect_first) scale = (scale_2 - math.fmod(scale_2, 2)) .. ":" .. scale end if no_scale and not width_first then scale = dwidth .. ":" .. dheight @@ -567,7 +567,7 @@ function call_gui () yad_ret = -2 end scale = tonumber(yad_table[1]) - (math.fmod(tonumber(yad_table[1]), 2 )) scale_sav = scale if (yad_table[2] == "FALSE") and (tonumber(yad_table[1]) > 0) then scale_width = false -
Zehkul revised this gist
Jan 18, 2015 . 1 changed file with 2 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -490,7 +490,7 @@ function call_gui () end local yad_command = [[LC_NUMERIC=C yad --title="Convert Script" --center --form --fixed --always-print-result \ --name "convert script" --class "Convert Script" --field="Resize to height:NUM" "]] .. scale_sav --yad_table 1 .. [[" --field="Resize to width instead:CHK" ]] .. resize_to_width_instead .. " " --yad_table 2 if options.legacy_yad then @@ -525,7 +525,7 @@ function call_gui () yad_command = yad_command .. [[ --button="Crop:1" --button="gtk-cancel:2" --button="gtk-ok:0"; ret=$? && echo $ret]] if gif_dialog then yad_command = [[echo $(LC_NUMERIC=C yad --title="Gif settings" --name "convert script" --class "Convert Script" \ --center --form --always-print-result --separator="…" \ --field="Fuzz Factor:NUM" '1!0..100!0.5!1' \ --field="Framestep:NUM" '3!1..3!1' \ -
Zehkul revised this gist
Jan 18, 2015 . 2 changed files with 46 additions and 29 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -61,7 +61,7 @@ and set some options in ``mpv/lua-settings/convert_script.conf`` or with ``--scr legacy_yad Default: no If you don’t want to upgrade your yad. Features like appending segments won’t be available. libvpx_fps Default: --oautofps This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -427,38 +427,51 @@ function call_gui () local mode_dropdown_content local resize_to_width_instead local include_audio local yad_offset_10 = 0 if not scale_sav then scale_sav = 540 end if not yad_table[5] then yad_table[5] = "" end if not options.legacy_yad then if yad_table[5]:find("(MiB)") then mode_dropdown_content = "'Target file size (KiB)!^Target file size (MiB)!CRF'" elseif yad_table[5]:find("(KiB)") then mode_dropdown_content = "'^Target file size (KiB)!Target file size (MiB)!CRF'" elseif yad_table[5]:find("CRF") then mode_dropdown_content = "'Target file size (KiB)!Target file size (MiB)!^CRF'" else mode_dropdown_content = "'^Target file size (KiB)!Target file size (MiB)!CRF'" end if yad_table[7] == "vp8/webm" then format_dropdown_content = "'^vp8/webm!h264/mkv!h264/mp4!h265/mkv!gif!stream copy/mkv'" elseif yad_table[7] == "h264/mkv" then format_dropdown_content = "'vp8/webm!^h264/mkv!h264/mp4!h265/mkv!gif!stream copy/mkv'" elseif yad_table[7] == "h264/mp4" then format_dropdown_content = "'vp8/webm!h264/mkv!^h264/mp4!h265/mkv!gif!stream copy/mkv'" elseif yad_table[7] == "h265/mkv" then format_dropdown_content = "'vp8/webm!h264/mkv!h264/mp4!^h265/mkv!gif!stream copy/mkv'" elseif yad_table[7] == "gif" then format_dropdown_content = "'vp8/webm!h264/mkv!h264/mp4!h265/mkv!^gif!stream copy/mkv'" elseif yad_table[7] == "stream copy/mkv" then format_dropdown_content = "'vp8/webm!h264/mkv!h264/mp4!h265/mkv!gif!^stream copy/mkv'" else format_dropdown_content = "'^vp8/webm!h264/mkv!h264/mp4!h265/mkv!gif!stream copy/mkv'" end else mode_dropdown_content = "'Target file size (KiB)!Target file size (MiB)!CRF'" format_dropdown_content = "'vp8/webm!h264/mkv!h264/mp4!h265/mkv!gif!stream copy/mkv'" yad_offset_10 = -2 end if (yad_table[2] == "TRUE") then resize_to_width_instead = '"true"' @@ -501,11 +514,15 @@ function call_gui () .. '--field="Mode::CB" ' .. mode_dropdown_content --yad_table 5 .. ' --field="Value::NUM" ' .. yad_table[6] --yad_table 6 .. ' --field="Output format::CB" ' .. format_dropdown_content --yad_table 7 if not options.legacy_yad then yad_command = yad_command .. [[ --field="Advanced:FBTN" 'bash -c "echo \"advanced\" && kill -s SIGUSR1 \"$YAD_PID\""' ]] end end if not options.legacy_yad then yad_command = yad_command .. [[--field="Append another segment:FBTN" 'bash -c "echo \"append\" && kill -s SIGUSR1 \"$YAD_PID\""' ]] end yad_command = yad_command .. [[ --button="Crop:1" --button="gtk-cancel:2" --button="gtk-ok:0"; ret=$? && echo $ret]] if gif_dialog then yad_command = [[echo $(LANG=en_US.utf8 yad --title="Gif settings" --name "convert script" --class "Convert Script" \ @@ -533,7 +550,7 @@ function call_gui () if not gif_dialog then yad_ret = tonumber(yad_table[10+yad_offset_10]) if yad_table[1]:find("append") then yad_table[1] = string.gsub(yad_table[1], "append\n", "") yad_ret = -1 -
Zehkul revised this gist
Jan 18, 2015 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -7,7 +7,7 @@ http://s1.webmshare.com/dX3BL.webm ##Installation: You need: - yad (at least 0.26) ([AUR](https://aur.archlinux.org/packages/yad/)) - mpv (at least 0.4) - notify-send (optional, to send a notification when the encode is done) (to be found in libnotify on Arch) - mkvmerge (optional, for stream copy) -
Zehkul revised this gist
Jan 18, 2015 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -185,7 +185,7 @@ function preparations() end if options.use_same_dir then options.output_directory = "'" .. utils.split_path(video) .. "'" end local filename_ext = mp.get_property_osd("media-title") -
Zehkul revised this gist
Jan 18, 2015 . 1 changed file with 2 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -554,10 +554,12 @@ function call_gui () scale_sav = scale if (yad_table[2] == "FALSE") and (tonumber(yad_table[1]) > 0) then scale_width = false no_scale = false elseif yad_table[1] == "0.000000" then no_scale = true else scale_width = true no_scale = false end if yad_table[3] == "TRUE" then no_scale = true -
Zehkul revised this gist
Jan 18, 2015 . 2 changed files with 7 additions and 7 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -56,8 +56,8 @@ and set some options in ``mpv/lua-settings/convert_script.conf`` or with ``--scr Whether you want only the last crop argument to count—no—or you want to crop all segments individually—yes. In that case the final video will inherit the aspect ratio of the first segment. libvpx_options Default: --ovcopts-add=cpu-used=0,auto-alt-ref=1,lag-in-frames=25,quality=good Higher quality at the expense of processing time. legacy_yad Default: no This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -11,7 +11,7 @@ local options = { use_same_dir = false, -- puts the output files where the original video was libvpx_threads = 4, -- libvpx only crop_individually = true, libvpx_options = "--ovcopts-add=cpu-used=0,auto-alt-ref=1,lag-in-frames=25,quality=good", legacy_yad = false, -- if you don’t want to upgrade to at least yad 0.18 libvpx_fps = "--oautofps", -- --ofps=24000/1001 for example } @@ -282,11 +282,8 @@ function encode(enc) ovc_c = ' ' end local encode_options = ' ' .. ovc_c if ovc == "libvpx" then encode_options = encode_options .. ' ' .. options.libvpx_fps .. ' ' .. options.libvpx_options .. ' --ovcopts-add=threads=' .. options.libvpx_threads end if twopass then @@ -530,6 +527,9 @@ function call_gui () yad_table = {} local function helper(line) table.insert(yad_table, line) return "" end helper((yad:gsub("(.-)|", helper))) for i, e in pairs(yad_table) do msg.debug(i .. " → " .. e) end if not gif_dialog then -
Zehkul revised this gist
Jan 17, 2015 . 1 changed file with 2 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -484,10 +484,10 @@ function call_gui () --name "convert script" --class "Convert Script" --field="Resize to height:NUM" "]] .. scale_sav --yad_table 1 .. [[" --field="Resize to width instead:CHK" ]] .. resize_to_width_instead .. " " --yad_table 2 if options.legacy_yad then yad_command = yad_command .. [[--field="Don't resize at all:CHK" "false" ]] else yad_command = yad_command .. [[--field="Don't resize at all:BTN" "@bash -c 'if ]] .. '[[ "a%1" == "a0.000000" ]]' .. [[; then printf '\''1:1\n2:false'\''; else printf '\''1:0.000000\n1:@disabled@\n2:@disabled@'\''; fi'" ]] end yad_command = yad_command .. '--field="Include audio:CHK" ' .. include_audio .. ' ' --yad_table 4 -
Zehkul revised this gist
Jan 17, 2015 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -511,7 +511,7 @@ function call_gui () .. [[--button="Crop:1" --button="gtk-cancel:2" --button="gtk-ok:0"; ret=$? && echo $ret]] if gif_dialog then yad_command = [[echo $(LANG=en_US.utf8 yad --title="Gif settings" --name "convert script" --class "Convert Script" \ --center --form --always-print-result --separator="…" \ --field="Fuzz Factor:NUM" '1!0..100!0.5!1' \ --field="Framestep:NUM" '3!1..3!1' \ -
Zehkul revised this gist
Jan 17, 2015 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -480,7 +480,7 @@ function call_gui () end local yad_command = [[LANG=en_US.utf8 yad --title="Convert Script" --center --form --fixed --always-print-result \ --name "convert script" --class "Convert Script" --field="Resize to height:NUM" "]] .. scale_sav --yad_table 1 .. [[" --field="Resize to width instead:CHK" ]] .. resize_to_width_instead .. " " --yad_table 2 if options.legacy_yad then -
Zehkul revised this gist
Jan 16, 2015 . 1 changed file with 5 additions and 5 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -217,8 +217,8 @@ function encode(enc) end else -- odd numbers for video resolution are a bad idea rect_width = round(rect_width) - (math.mod(round(rect_width), 2)) rect_height = round(rect_height) - (math.mod(round(rect_height), 2)) crop = rect_width .. ":" .. rect_height .. ":" .. round(rect_x1) .. ":" .. round(rect_y1) if not aspect_first then aspect_first = rect_width / rect_height @@ -366,10 +366,10 @@ function encode(enc) if scale_width then local scale_2 = round(scale / aspect_first) scale = scale .. ":" .. (scale_2 - (math.mod(scale_2, 2))) else local scale_2 = round(scale * aspect_first) scale = (scale_2 - math.mod(scale_2, 2)) .. ":" .. scale end if no_scale and not width_first then scale = dwidth .. ":" .. dheight @@ -550,7 +550,7 @@ function call_gui () yad_ret = -2 end scale = tonumber(yad_table[1]) - (math.mod(tonumber(yad_table[1]), 2 )) scale_sav = scale if (yad_table[2] == "FALSE") and (tonumber(yad_table[1]) > 0) then scale_width = false -
Zehkul revised this gist
Jan 16, 2015 . 2 changed files with 10 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -41,7 +41,11 @@ and set some options in ``mpv/lua-settings/convert_script.conf`` or with ``--scr use_pwd_instead Default: no Use your working directory as the output directory. Overrides output_directory. use_same_dir Default: no Use the directory of the original video file. Overrides output_directory. libvpx_threads Default: 4 This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,12 +1,14 @@ local assdraw = require 'mp.assdraw' local msg = require 'mp.msg' local opt = require 'mp.options' local utils = require 'mp.utils' -- default options, convert_script.conf is read local options = { 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 output_directory = "$HOME", use_pwd_instead = false, -- overrides output_directory use_same_dir = false, -- puts the output files where the original video was libvpx_threads = 4, -- libvpx only crop_individually = true, libvpx_options = "cpu-used=0,auto-alt-ref=1,lag-in-frames=25,quality=good", @@ -182,6 +184,9 @@ function preparations() options.output_directory = "'" .. pwd .. "'" end if options.use_same_dir then options.output_directory = utils.split_path(video) end local filename_ext = mp.get_property_osd("media-title") filename_ext = string.gsub(filename_ext, "'", "'\\''") -
Zehkul revised this gist
Jan 16, 2015 . 1 changed file with 4 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -277,8 +277,11 @@ function encode(enc) ovc_c = ' ' end local encode_options = ' ' .. ovc_c if not (options.libvpx_options == "") then options.libvpx_options = ' --ovcopts-add=' .. options.libvpx_options end if ovc == "libvpx" then encode_options = encode_options .. ' ' .. options.libvpx_fps .. options.libvpx_options .. ' --ovcopts-add=threads=' .. options.libvpx_threads end if twopass then -
Zehkul revised this gist
Jan 16, 2015 . 2 changed files with 514 additions and 89 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,66 @@ #README: This script for mpv intends to offer the fastest and simplest way to convert parts of a video—while you’re watching it and not really more work intensive than making a screenshot. A short demonstration: http://s1.webmshare.com/dX3BL.webm ##Installation: You need: - yad (at least 0.18) ([AUR](https://aur.archlinux.org/packages/yad/)) - mpv (at least 0.4) - notify-send (optional, to send a notification when the encode is done) (to be found in libnotify on Arch) - mkvmerge (optional, for stream copy) - imagemagick (optional, for gifs) - linux Install it by putting the script into ~/.config/mpv/scripts/ or ~/.mpv/scripts/ (mpv 0.8+) and ~/.config/mpv/lua/ ~/.mpv/lua/ respectively (mpv 0.4 through 0.7) ##Usage: ``alt + w`` activates the script. First activation marks one end of the clip, the second one the other, order does not matter. Cropping doesn’t really work well with the OSC. ##Configuration: Configuration works in the same way as [configuring the OSC does](http://mpv.io/manual/master/#configuration). You can bind it to another hotkey in your input.conf with ``<key> script_message convert_script`` and set some options in ``mpv/lua-settings/convert_script.conf`` or with ``--script-opts`` (mpv 0.7 and earlier: ``--lua-opts``) bitrate_multiplier Default: 0.975 To make sure the file won’t go over the target file size, set it to 1 if you don’t care. output_directory Default: $HOME Where the script saves your converted files. use_pwd_instead Default: no Use your working directory as the output directory. Overrides output_directory. libvpx_threads Default: 4 Number of threads to use for encoding, libvpx only because it apparently doesn’t have auto detection. crop_individually Default: yes Whether you want only the last crop argument to count—no—or you want to crop all segments individually—yes. In that case the final video will inherit the aspect ratio of the first segment. libvpx_options Default: cpu-used=0,auto-alt-ref=1,lag-in-frames=25,quality=good Higher quality at the expense of processing time. This is directly handed over to "--ovcopts-add=", so make sure it’s correct. legacy_yad Default: no If you don’t want to upgrade to yad 0.18. Slightly less fancy. libvpx_fps Default: --oautofps FPS settings (or any other settings really) for libvpx encoding. Set it to --ofps=24000/1001 for example. Warning: Some of these options aren’t very robust and setting them to bogus values will break the script. This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,25 +1,22 @@ local assdraw = require 'mp.assdraw' local msg = require 'mp.msg' local opt = require 'mp.options' -- default options, convert_script.conf is read local options = { 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 output_directory = "$HOME", use_pwd_instead = false, -- overrides output_directory libvpx_threads = 4, -- libvpx only crop_individually = true, libvpx_options = "cpu-used=0,auto-alt-ref=1,lag-in-frames=25,quality=good", legacy_yad = false, -- if you don’t want to upgrade to at least yad 0.18 libvpx_fps = "--oautofps", -- --ofps=24000/1001 for example } read_options(options, "convert_script") options.output_directory = '"' .. options.output_directory .. '"' yad_table = {} ------------------------------------- -- Rectangle selection and drawing -- @@ -126,7 +123,7 @@ function convert_script_hotkey_call () if timepos1 then timepos2 = mp.get_property_native(playback_time) timepos2_humanreadable = mp.get_property_osd(playback_time) if tonumber(timepos1) > tonumber(timepos2) then @@ -151,15 +148,15 @@ function convert_script_hotkey_call () mp.osd_message("Both frames are the same, ignoring the second one") timepos2 = nil return end timepos1 = nil call_gui() else timepos1 = mp.get_property_native(playback_time) timepos1_humanreadable = mp.get_property_osd(playback_time) msg.info("Start frame set") mp.osd_message("Start frame set") @@ -173,24 +170,64 @@ end -- Encode -- ------------ function preparations() video = mp.get_property("path") video = string.gsub(video, "'", "'\\''") if options.use_pwd_instead then local pwd = os.getenv("PWD") pwd = string.gsub(pwd, "'", "'\\''") options.output_directory = "'" .. pwd .. "'" end local filename_ext = mp.get_property_osd("media-title") filename_ext = string.gsub(filename_ext, "'", "'\\''") local filename = string.gsub(filename_ext, "%....$","") if string.len(filename) > 230 then filename = mp.get_property("options/title") if filename == 'mpv - ${media-title}' or string.len(filename) > 230 then filename = 'output' end end filename = filename .. " " .. start_humanreadable .. "-" .. end_humanreadable .. extension filename = string.gsub(filename, ":", ".") full_output_path = options.output_directory .. "/'" .. filename .. "'" end function encode(enc) set_mouse_area = nil if rect_width == nil or rect_width == 0 then crop = "" if not aspect_first then aspect_first = mp.get_property_native("video-params/aspect") end else -- odd numbers for video resolution are a bad idea rect_width = round(rect_width) - (round(rect_width) % 2) rect_height = round(rect_height) - (round(rect_height) % 2) crop = rect_width .. ":" .. rect_height .. ":" .. round(rect_x1) .. ":" .. round(rect_y1) if not aspect_first then aspect_first = rect_width / rect_height width_first = rect_width height_first = rect_height end rect_width, rect_height = nil end local sid = mp.get_property("sid") local sub_visibility = mp.get_property("sub-visibility") local aid = "" aid = " --aid=" .. mp.get_property("aid") local af = mp.get_property("af") local vf = mp.get_property("vf") if string.len(vf) > 0 then vf = vf .. "," @@ -200,60 +237,176 @@ function encode () for index, param in pairs(sub_file_table) do sub_file = sub_file .. " --sub-file='" .. string.gsub(tostring(param), "'", "'\\''") .. "'" end local audio_file_table = mp.get_property_native("options/audio-file") local audio_file = "" for index, param in pairs(audio_file_table) do audio_file = audio_file .. " --audio-file='" .. string.gsub(tostring(param), "'", "'\\''") .. "'" end if mp.get_property_native("mute") then audio_file = "" aid = "" audio = "--no-audio" end local sub_auto = mp.get_property("options/sub-auto") local sub_delay = mp.get_property("sub-delay") local colormatrix_input_range = mp.get_property_native("colormatrix-input-range") local hr_seek_demuxer_offset = mp.get_property_native("options/hr-seek-demuxer-offset") preparations() if options.crop_individually then vf = vf .. 'sub,crop=' .. crop .. ',scale=SCALE…VAR' else vf = vf .. 'sub,crop=CROP…VAR,scale=SCALE…VAR' end local mpv_options = "'" .. video .. "' --start=+" .. start .. ' --length=' .. length .. ' ' .. sub_file .. ' --sid=' .. sid .. ' --sub-visibility=' .. sub_visibility .. ' --sub-delay=' .. sub_delay .. ' --sub-auto=' .. sub_auto .. aid .. ' --vf-add=' .. vf .. ' --hr-seek-demuxer-offset=' .. hr_seek_demuxer_offset .. ' --af=' .. af .. ' ' .. audio_file if (ovc == "libvpx") and (colormatrix_input_range == "full") then mpv_options = mpv_options .. ' --vf-add=lavfi=graph=[pp=autolevels]' else mpv_options = mpv_options .. ' --colormatrix-input-range=' .. colormatrix_input_range end if not (ovc == "gif") then ovc_c = ' --ovc=' .. ovc else ovc_c = ' ' end local encode_options = ' ' .. ovc_c if ovc == "libvpx" then encode_options = encode_options .. ' ' .. options.libvpx_fps .. ' --ovcopts-add=' .. options.libvpx_options .. ' --ovcopts-add=threads=' .. options.libvpx_threads end if twopass then encode_options = encode_options .. ' --ovcopts-add=b=' .. bitrate else if not (ovc == "gif") then encode_options = encode_options .. ' --ovcopts-add=crf=' .. crf end if ovc == "libvpx" then encode_options = encode_options .. ' --ovcopts-add=b=10000000' end end if advanced then encode_options = ' ' .. advanced_output .. advanced_encode end if not segments then segments = "" segment_count = 0 end segment_count = segment_count + 1 segments = segments .. " --\\{ " .. mpv_options .. " --\\}" local full_command = '( mpv' .. segments if twopass then encode_options = encode_options .. ' --ovcopts-add=flags=+pass' full_command = full_command .. ' --no-audio ' .. encode_options .. '1' end if ovc == "gif" then local handle = io.popen("mktemp -d") tmpfolder = handle:read("*a") handle:close() tmpfolder = string.gsub(tmpfolder, '\n', '') encode_options = encode_options .. ' --no-keep-open --vo=image:format=png:outdir=' .. tmpfolder else full_command = full_command .. ' --o=' .. full_output_path end if twopass then full_command = full_command .. ' && mpv' .. segments .. ' ' .. audio .. ' ' .. encode_options .. '2' .. ' --o=' .. full_output_path .. ' && rm ' .. full_output_path .. '-vo-lavc-pass1.log' else full_command = full_command .. ' ' .. audio .. ' ' .. encode_options end if not framestep then framestep = 1 dither = "+dither" fuzz = "1%" end local delay = framestep * 4 if ovc == "gif" then full_command = full_command .. ' --vf-add=lavfi=graph=\\"framestep=' .. framestep .. '\\" && convert ' .. tmpfolder .. '/*.png -set delay ' .. delay .. ' -loop 0 -fuzz ' .. fuzz .. '% ' .. dither .. ' -layers optimize ' .. full_output_path .. ' && rm -rf ' .. tmpfolder .. ' && notify-send "Gif done") &' else full_command = full_command .. ' && notify-send "Encoding done") &' end if enc then -- mpv parses --{ --} last and --no-audio gets overwritten by --aid, so remove them if audio == "--no-audio" then full_command = string.gsub(full_command, "--aid=%d* ", " ") end local dwidth, dheight = mp.get_property_native("dwidth"), mp.get_property_native("dheight") if width_first then if scale_width then scale = width_first else scale = height_first end end if scale_width then local scale_2 = round(scale / aspect_first) scale = scale .. ":" .. (scale_2 - (scale_2 % 2)) else local scale_2 = round(scale * aspect_first) scale = (scale_2 - (scale_2 % 2)) .. ":" .. scale end if no_scale and not width_first then scale = dwidth .. ":" .. dheight end full_command = string.gsub(full_command, "CROP…VAR", crop) full_command = string.gsub(full_command, "SCALE…VAR", scale) msg.info(full_command) os.execute(full_command) clear() end end function encode_copy(enc) preparations() if not mkvmerge_parts then mkvmerge_parts = "--split parts:" sep = "" end mkvmerge_parts = mkvmerge_parts .. sep .. math.floor(start) .. "s-" .. math.ceil(start + length) .. "s" sep = ",+" if enc then local command = "mkvmerge '" .. video .. "' " .. mkvmerge_parts .. " -o " .. full_output_path msg.info(command) os.execute(command) clear() end end function clear() mkvmerge_parts = nil aspect_first = nil height_first = nil width_first = nil sep = nil segments = nil segments_length = 0 end --------- -- GUI -- @@ -263,56 +416,262 @@ function call_gui () mp.disable_key_bindings("draw_rectangle") mp.resume_all() extension = "" local factor = 1024 local format_dropdown_content local mode_dropdown_content local resize_to_width_instead local include_audio if not scale_sav then scale_sav = 540 end if not yad_table[5] then yad_table[5] = "" end if yad_table[5]:find("(MiB)") then mode_dropdown_content = "'Target file size (KiB)!^Target file size (MiB)!CRF'" elseif yad_table[5]:find("(KiB)") then mode_dropdown_content = "'^Target file size (KiB)!Target file size (MiB)!CRF'" elseif yad_table[5]:find("CRF") then mode_dropdown_content = "'Target file size (KiB)!Target file size (MiB)!^CRF'" else mode_dropdown_content = "'^Target file size (KiB)!Target file size (MiB)!CRF'" end if yad_table[7] == "vp8/webm" then format_dropdown_content = "'^vp8/webm!h264/mkv!h264/mp4!h265/mkv!gif!stream copy/mkv'" elseif yad_table[7] == "h264/mkv" then format_dropdown_content = "'vp8/webm!^h264/mkv!h264/mp4!h265/mkv!gif!stream copy/mkv'" elseif yad_table[7] == "h264/mp4" then format_dropdown_content = "'vp8/webm!h264/mkv!^h264/mp4!h265/mkv!gif!stream copy/mkv'" elseif yad_table[7] == "h265/mkv" then format_dropdown_content = "'vp8/webm!h264/mkv!h264/mp4!^h265/mkv!gif!stream copy/mkv'" elseif yad_table[7] == "gif" then format_dropdown_content = "'vp8/webm!h264/mkv!h264/mp4!h265/mkv!^gif!stream copy/mkv'" elseif yad_table[7] == "stream copy/mkv" then format_dropdown_content = "'vp8/webm!h264/mkv!h264/mp4!h265/mkv!gif!^stream copy/mkv'" else format_dropdown_content = "'^vp8/webm!h264/mkv!h264/mp4!h265/mkv!gif!stream copy/mkv'" end if (yad_table[2] == "TRUE") then resize_to_width_instead = '"true"' else resize_to_width_instead = '"false"' end if (yad_table[4] == "TRUE") then include_audio = '"true"' else include_audio = '"false"' end if (not yad_table[6]) then yad_table[6] = '"3072"' end local yad_command = [[yad --title="Convert Script" --center --form --fixed --always-print-result \ --name "convert script" --class "Convert Script" --field="Resize to height:NUM" "]] .. scale_sav --yad_table 1 .. [[" --field="Resize to width instead:CHK" ]] .. resize_to_width_instead .. " " --yad_table 2 if options.legacy_yad then yad_command = yad_command .. [[--field="Don’t resize at all:CHK" "false" ]] else yad_command = yad_command .. [[--field="Don’t resize at all:BTN" "@bash -c 'if ]] .. '[[ "a%1" == "a0.000000" ]]' .. [[; then printf '\''1:1\n2:false'\''; else printf '\''1:0.000000\n1:@disabled@\n2:@disabled@'\''; fi'" ]] end yad_command = yad_command .. '--field="Include audio:CHK" ' .. include_audio .. ' ' --yad_table 4 if yad_ret then yad_command = yad_command .. [[--field="2pass:CHK" "false" ]] --yad_table 5 .. [[--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 .. [[--field="Output format::CBE" ' --ovc=libx264! --oautofps --of=webm --ovc=libvpx' ]] .. [[--field="Simple:FBTN" 'bash -c "echo \"simple\" && kill -s SIGUSR1 \"$YAD_PID\""' ]] advanced = true else yad_command = yad_command .. '--field="Mode::CB" ' .. mode_dropdown_content --yad_table 5 .. ' --field="Value::NUM" ' .. yad_table[6] --yad_table 6 .. ' --field="Output format::CB" ' .. format_dropdown_content --yad_table 7 .. [[ --field="Advanced:FBTN" 'bash -c "echo \"advanced\" && kill -s SIGUSR1 \"$YAD_PID\""' ]] end yad_command = yad_command .. [[--field="Append another segment:FBTN" 'bash -c "echo \"append\" && kill -s SIGUSR1 \"$YAD_PID\""' ]] .. [[--button="Crop:1" --button="gtk-cancel:2" --button="gtk-ok:0"; ret=$? && echo $ret]] if gif_dialog then yad_command = [[echo $(yad --title="Gif settings" --name "convert script" --class "Convert Script" \ --center --form --always-print-result --separator="…" \ --field="Fuzz Factor:NUM" '1!0..100!0.5!1' \ --field="Framestep:NUM" '3!1..3!1' \ --field="Dither:CB" 'None!E-Dither!Ordered Dither' \ --button="Ok:0")]] end local handle = io.popen(yad_command) local yad = handle:read("*a") handle:close() if yad == "127\n" then msg.error("Error: Cannot find yad!") mp.osd_message("Error: Cannot find yad!") return end yad_table = {} local function helper(line) table.insert(yad_table, line) return "" end helper((yad:gsub("(.-)|", helper))) if not gif_dialog then yad_ret = tonumber(yad_table[10]) if yad_table[1]:find("append") then yad_table[1] = string.gsub(yad_table[1], "append\n", "") yad_ret = -1 end if yad_table[1]:find("advanced") then yad_table[1] = string.gsub(yad_table[1], "advanced\n", "") yad_ret = -2 if yad_table[7]:find("gif") then gif_dialog = true end end if yad_table[1]:find("simple") then yad_table[1] = string.gsub(yad_table[1], "simple\n", "") yad_ret = -2 end scale = tonumber(yad_table[1]) - (tonumber(yad_table[1]) % 2) scale_sav = scale if (yad_table[2] == "FALSE") and (tonumber(yad_table[1]) > 0) then scale_width = false elseif yad_table[1] == "0.000000" then no_scale = true else scale_width = true end if yad_table[3] == "TRUE" then no_scale = true end if yad_table[4] == "FALSE" then audio = "--no-audio" else audio = "" end if not segments_length then segments_length = 0 end segments_length = segments_length + length if (yad_table[5] == "TRUE") or yad_table[5]:find("Target") then twopass = true else twopass = false end if advanced then advanced_encode = yad_table[6] advanced_output = yad_table[7] yad_table[6] = '"3072"' else if yad_table[7]:find("webm") then extension = ".webm" elseif yad_table[7]:find("mkv") then extension = ".mkv" elseif yad_table[7]:find("mp4") then extension = ".mp4" end if yad_table[7]:find("h264") then ovc = "libx264" elseif yad_table[7]:find("h265") then ovc = "libx265" elseif yad_table[7]:find("vp8") then ovc = "libvpx" elseif yad_table[7]:find("gif") then ovc = "gif" extension = ".gif" twopass = false elseif yad_table[7]:find("stream copy") then ovc = "stream copy" end if yad_table[5]:find("(MiB)") then factor = 1048576 end if twopass then bitrate = math.floor(yad_table[6]*factor*8/segments_length*options.bitrate_multiplier) else crf = yad_table[6] end end if yad_ret == 1 then mp.enable_key_bindings("draw_rectangle") yad_ret = nil return end else gif_dialog = nil helper((yad:gsub("(.-)…", helper))) fuzz = yad_table[2] framestep = yad_table[3] if yad_table[4] == "None" then dither = "+dither" elseif yad_table[4] == "Ordered Dither" then dither = "-ordered-dither o8x8,20" else dither = "" end yad_table[7] = "gif" end mp.set_osd_ass(width, height, "") if yad_ret == 0 then if ovc == "stream copy" then encode_copy(true) else encode(true) end elseif yad_ret == -1 then if ovc == "stream copy" then encode(false) encode_copy(false) else encode(false) encode_copy(false) end end if yad_ret == -2 then if advanced then advanced = false yad_ret = false end call_gui() end if yad_ret == 2 then clear() end yad_ret = nil advanced = nil end function round(n) return math.floor((math.floor(n*2) + 1)/2) end -
Zehkul revised this gist
Dec 7, 2014 . 1 changed file with 6 additions and 3 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,6 +1,6 @@ -- README: -- convert script for mpv, just throw it into ~/.mpv/lua/ -- needs: yad (at least 0.18), libnotify (optional) and at least mpv 0.4 -- bind it to another hotkey with -- <key> script_message convert_script -- in your input.conf (standard: alt+w) @@ -187,7 +187,10 @@ function encode () video = string.gsub(video, "'", "'\\''") local sid = mp.get_property("sid") local sub_visibility = mp.get_property("sub-visibility") local aid = "" if not audio == "--no-audio" then aid = " --aid=" .. mp.get_property("aid") end local vf = mp.get_property("vf") if string.len(vf) > 0 then vf = vf .. "," @@ -227,7 +230,7 @@ function encode () local mpv_options = "mpv '" .. video .. "' --start=+" .. start .. ' --length=' .. length .. ' ' .. sub_file .. ' --sid=' .. sid .. ' --sub-visibility=' .. sub_visibility .. ' --sub-delay=' .. sub_delay .. ' --sub-auto=' .. sub_auto .. aid .. ' --colormatrix-input-range=' .. colormatrix_input_range .. ' --vf=' .. vf .. 'sub,crop=' .. crop .. ',scale=' .. scale .. ' --hr-seek-demuxer-offset=' .. hr_seek_demuxer_offset -
Zehkul revised this gist
Dec 7, 2014 . 1 changed file with 2 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -187,6 +187,7 @@ function encode () video = string.gsub(video, "'", "'\\''") local sid = mp.get_property("sid") local sub_visibility = mp.get_property("sub-visibility") local aid = mp.get_property("aid") local vf = mp.get_property("vf") if string.len(vf) > 0 then vf = vf .. "," @@ -226,7 +227,7 @@ function encode () local mpv_options = "mpv '" .. video .. "' --start=+" .. start .. ' --length=' .. length .. ' ' .. sub_file .. ' --sid=' .. sid .. ' --sub-visibility=' .. sub_visibility .. ' --sub-delay=' .. sub_delay .. ' --sub-auto=' .. sub_auto .. ' --aid=' .. aid .. ' --colormatrix-input-range=' .. colormatrix_input_range .. ' --vf=' .. vf .. 'sub,crop=' .. crop .. ',scale=' .. scale .. ' --hr-seek-demuxer-offset=' .. hr_seek_demuxer_offset -
Zehkul revised this gist
Sep 20, 2014 . 1 changed file with 6 additions and 6 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -21,12 +21,6 @@ local options = { read_options(options, "convert_script") ------------------------------------- -- Rectangle selection and drawing -- ------------------------------------- @@ -118,6 +112,12 @@ end ----------------- function convert_script_hotkey_call () if mp.get_property("playback-time") then playback_time = "playback-time" else playback_time = "time-pos" end set_mouse_area = true width = mp.get_property("dwidth") -
Zehkul revised this gist
Sep 20, 2014 . 1 changed file with 14 additions and 7 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -21,6 +21,12 @@ local options = { read_options(options, "convert_script") if mp.get_property("playback-time") then playback_time = "playback-time" else playback_time = "time-pos" end ------------------------------------- -- Rectangle selection and drawing -- ------------------------------------- @@ -116,13 +122,12 @@ function convert_script_hotkey_call () set_mouse_area = true width = mp.get_property("dwidth") height = mp.get_property("dheight") mp.set_osd_ass(width, height, "") if timepos1 then timepos2 = mp.get_property(playback_time) timepos2_humanreadable = mp.get_property_osd(playback_time) if tonumber(timepos1) > tonumber(timepos2) then @@ -154,8 +159,8 @@ function convert_script_hotkey_call () else timepos1 = mp.get_property(playback_time) timepos1_humanreadable = mp.get_property_osd(playback_time) msg.info("Start frame set") mp.osd_message("Start frame set") @@ -193,7 +198,8 @@ function encode () end local sub_auto = mp.get_property("options/sub-auto") local sub_delay = mp.get_property("sub-delay") local colormatrix_input_range = mp.get_property_native("colormatrix-input-range") local hr_seek_demuxer_offset = mp.get_property_native("options/hr-seek-demuxer-offset") if options.use_pwd_instead then @@ -218,11 +224,12 @@ function encode () filename = filename .. " " .. start_humanreadable .. "-" .. end_humanreadable .. ".webm" local mpv_options = "mpv '" .. video .. "' --start=+" .. start .. ' --length=' .. length .. ' ' .. sub_file .. ' --sid=' .. sid .. ' --sub-visibility=' .. sub_visibility .. ' --sub-delay=' .. sub_delay .. ' --sub-auto=' .. sub_auto .. ' --colormatrix-input-range=' .. colormatrix_input_range .. ' --vf=' .. vf .. 'sub,crop=' .. crop .. ',scale=' .. scale .. ' --hr-seek-demuxer-offset=' .. hr_seek_demuxer_offset local encode_options = ' --oautofps --of=webm --ovc=libvpx' .. ' --ovcopts=b=' .. bitrate .. ',cpu-used=0,auto-alt-ref=1,lag-in-frames=25,quality=good,threads=' .. options.threads
NewerOlder