From 041e7c6f7f16e89af70d575f327768a5361c83d8 Mon Sep 17 00:00:00 2001 From: amagalma Date: Mon, 11 Nov 2024 15:21:39 +0200 Subject: [PATCH] Release Explode video items to separate audio and video items in separate tracks v1.00 (#1460) --- ...dio and video items in separate tracks.lua | 131 ++++++++++++++++++ 1 file changed, 131 insertions(+) create mode 100644 Items Editing/amagalma_Explode video items to separate audio and video items in separate tracks.lua diff --git a/Items Editing/amagalma_Explode video items to separate audio and video items in separate tracks.lua b/Items Editing/amagalma_Explode video items to separate audio and video items in separate tracks.lua new file mode 100644 index 000000000..8e10c02b0 --- /dev/null +++ b/Items Editing/amagalma_Explode video items to separate audio and video items in separate tracks.lua @@ -0,0 +1,131 @@ +-- @description Explode video items to separate audio and video items in separate tracks +-- @author amagalma +-- @version 1.00 +-- @donation https://www.paypal.me/amagalma +-- @about +-- - Explodes each selected item into separate items for the video and the audio part. Original items are turned into video-only items, and the new audio--only items are placed in a new track underneath. +-- +-- Inside the script you can specify: +-- 1) the name for the new audio-only tracks +-- 2) the suffix for the video-only items +-- 3) the suffix for the audio-only items +-- 4) whether to group video-only and audio-only items together + +name_for_new_audio_only_tracks = " -- video Audio only" +suffix_for_video_only_items = " VIDEO" +suffix_for_audio_only_items = " AUDIO" +group_video_and_audio_items_together = true + +--------------------------------------------------------------- + +local sel_item_cnt = reaper.CountSelectedMediaItems(0) +if sel_item_cnt == 0 then + return reaper.defer(function() end) +end + +local videoitems_by_track = {} +local tracks_n = 0 +local takeGUIDsAndAddresses_by_item = {} +local new_items = {} + +for i = 0, sel_item_cnt - 1 do + local item = reaper.GetSelectedMediaItem(0, i) + local take = reaper.GetActiveTake(item) + if take then + local src = reaper.GetMediaItemTake_Source( take ) + if reaper.GetMediaSourceType( src ) == "VIDEO" then + local track = reaper.GetMediaItem_Track(item) + if not videoitems_by_track[track] then + videoitems_by_track[track] = {} + tracks_n = tracks_n + 1 + end + videoitems_by_track[track][#videoitems_by_track[track]+1] = item + local _, take_guid = reaper.GetSetMediaItemTakeInfo_String( take, "GUID", "", false ) + takeGUIDsAndAddresses_by_item[item] = {take_guid, take} + end + end +end + +if tracks_n == 0 then + return reaper.defer(function() end) +end + +local function DisableAudioOrVideo(item,take_guid,audio,take) + -- item must be video item + -- if audio == true then disable audio else disable video + local command = audio and "AUDIO 0" or "VIDEO_DISABLED" + local take_guid = "GUID " .. take_guid + local search_guid = true + local _, chunk = reaper.GetItemStateChunk( item, "", false ) + local t, t_n = {}, 0 + for line in chunk:gmatch("[^\r\n]+") do + t_n = t_n + 1 + if search_guid then + if line == take_guid then + search_guid = false + end + elseif search_guid == false then + if line == "