I have been having fun doing remixes like this
https://www.youtube.com/watch?v=eTN0...=DanielLumertz
One problem is that is difficult maintaining big projects with HD 40min files chopped all around the place. Reaper starts to become laggy, so is best work just with the audio, the problem is that sometimes you wanna see the video too.
With this script, if you can alternate the item extensions, changing the source of it. You can select a bunch of media items and say ok now I want the .mkv then see with video, then execute again and put .mp3 and goes making more music.
The files you are alternating must be in the same folder, with the same name (just the extension different like
C:\Users\WillieWonka\Downloads\Episode01.mkv
C:\Users\WillieWonka\Downloads\Episode01.mp3
C:\Users\WillieWonka\Downloads\Episode01.mp4
Code:
function GetPath( take )
local source = reaper.GetMediaItemTake_Source( take )
local filenamebuf = reaper.GetMediaSourceFileName( source, '' )
return filenamebuf
end
local retval, ext_new = reaper.GetUserInputs("Extension Changer", 1, 'New Extension', '')
if retval == true then
reaper.Undo_BeginBlock()
local num_items = reaper.CountSelectedMediaItems(0)
for i = 1, num_items do
local item_loop = reaper.GetSelectedMediaItem(0, i-1)
local take_loop = reaper.GetMediaItemTake(item_loop, 0)
local bol = reaper.TakeIsMIDI( take_loop )
if bol == false then
local path_loop = GetPath( take_loop )
local file = path_loop:match("(.+)%..+$")
local ext_old = path_loop:match("^.+(%..+)$")
local new_path = file.."."..ext_new
reaper.BR_SetTakeSourceFromFile2( take_loop, new_path, false, false )
end
end
reaper.UpdateArrange()
reaper.Undo_EndBlock('Change Extension', -1)
end
And here is a second, it is just to glue items without having the -glued on the file path. I create this because I use glue to change my video files .mkv .mp4 to mp3 or .wav, but it would add -glued at the name and I would have to rename the files to use the script to alternate the extension
Code:
function print(val)
reaper.ShowConsoleMsg("\n"..tostring(val))
end
function SaveSelectedItems()
local list = {}
local num = reaper.CountSelectedMediaItems(0)
if num ~= 0 then
for i= 0, num-1 do
list[i+1] = reaper.GetSelectedMediaItem( 0, i )
end
end
reaper.Main_OnCommand(40289, 0)--Item: Unselect all items
return list
end
function LoadSelectedItems(list)
reaper.Main_OnCommand(40289, 0)--Item: Unselect all items
if #list ~= 0 then
for i = 1, #list do
reaper.SetMediaItemSelected( list[i], true )
end
end
end
function GetPath( take )
local source = reaper.GetMediaItemTake_Source( take )
local filenamebuf = reaper.GetMediaSourceFileName( source, '' )
return filenamebuf
end
function RemoveGluedFromName(old_path)
local file = old_path:match("(.+)%..+$")
local ext = old_path:match("^.+(%..+)$")
local new_name = file:match("(.+)%-glued%-%d+$")
if new_name == nil then
new_name = file:match("(.+)%-glued")
end
local new_name = new_name..ext
return new_name
end
reaper.Undo_BeginBlock()
local saved_items_list = SaveSelectedItems()
local new_items_list = {}
for i = 1, #saved_items_list do
local item_loop = saved_items_list[i]
local take_loop = reaper.GetMediaItemTake(item_loop, 0)
local retval, name_before = reaper.GetSetMediaItemTakeInfo_String(take_loop, 'P_NAME', '', false)
local bol = reaper.TakeIsMIDI( take_loop )
if bol == false then -- Is audio then it will be glued
reaper.SetMediaItemSelected(item_loop, true)
reaper.Main_OnCommand(41588, 0) --Item: Glue items
local new_item_loop = reaper.GetSelectedMediaItem(0, 0)
local new_take_loop = reaper.GetMediaItemTake(new_item_loop, 0)
local path_loop = GetPath( new_take_loop )
local new_path = RemoveGluedFromName(path_loop)
os.execute(string.format("copy \"%s\" \"%s\"", path_loop, new_path)) -- Copy Paste the file with new name
reaper.BR_SetTakeSourceFromFile2( new_take_loop, new_path, false, false ) -- Change the source
os.remove(path_loop) -- Delte -glued file
local retval, stringNeedBig = reaper.GetSetMediaItemTakeInfo_String(new_take_loop, 'P_NAME', name_before, true) -- rename the take
new_items_list[i] = new_item_loop -- Add to the select list
reaper.Main_OnCommand(40289, 0)--Item: Unselect all items
end
end
LoadSelectedItems(new_items_list)
reaper.Main_OnCommand(40047, 0)--40047
reaper.UpdateArrange()
reaper.Undo_EndBlock('Glue Without Renaming -glued', -1)