From 37de70000ec5bd76ceaa436cd05d57f201e29b33 Mon Sep 17 00:00:00 2001 From: garret Date: Wed, 15 Dec 2021 19:45:50 +0000 Subject: [PATCH] use -ss and -to "properly" this way just seeks to the bit you need and _then_ extracts it, instead of decoding everything and chucking away the bits we didn't ask for. massive performance increase, should've rtfm'd earlier --- macros/audio-clipper.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/macros/audio-clipper.lua b/macros/audio-clipper.lua index 8576688..fbab298 100644 --- a/macros/audio-clipper.lua +++ b/macros/audio-clipper.lua @@ -60,10 +60,10 @@ end function extract_audio(in_path, start_time, end_time, out_path, name, extension, copy) if copy == true then - os.execute('ffmpeg -i "'..in_path..'" -codec copy -vn -ss '..start_time..'ms -to '..end_time..'ms "'..out_path..name..'.'..extension..'" -y') + os.execute('ffmpeg -ss '..start_time..'ms -to '..end_time..'ms -i "'..in_path..'" -codec copy -vn "'..out_path..name..'.'..extension..'" -y') -- takes the video as input, copies the streams, but doesn't include video. sets it to start at the start of the selection, and end at the end of it. outputs to our chosen out path with our chosen name and extension. overwrites anything with the same name. elseif copy == false then - os.execute('ffmpeg -i "'..in_path..'" -vn -ss '..start_time..'ms -to '..end_time..'ms "'..out_path..name..'.'..extension..'" -y') + os.execute('ffmpeg -ss '..start_time..'ms -to '..end_time..'ms -i "'..in_path..'" -vn "'..out_path..name..'.'..extension..'" -y') -- same as above, but doesn't copy the stream (transcodes to flac) end end