Getting the videofile path from Pro Tools for a Cut Detection/ Cut track script
Hey all!
I'm working on a a script streamlines making a cut track in Pro tools by 'grabbing the video file from Pro Tools' -> Detecting the cuts from that video -> And making a cut track immediately based on that cut detection without ever needing to leave Pro Tools. No more switching between programs and the cuts are immediately on the right place!
Most of the script is already very functional but i just can't to seem to figure out how to get the videofile path from Pro Tools. The only place i can find it in Pro Tools is in the workspace (i'm running Pro Tools Studio) under session video files but navigating the workspace with script is a bit above my league currently. Is there a better way i can tackle this?
This is the current script in action: https://www.dropbox.com/scl/fi/f0qsq3zpd7ap8lin58e6j/Example-Script-Automatic-Cut-Track_Loran-Keuning.mov?rlkey=uq9f92ro9it07xtipvf58nodf&st=tvcwazit&dl=0
- Dustin Harris @Dustin_Harris
with only the video file selected, try this:
const videoFilePath = sf.app.proTools.getFileLocation().fileLocations[0].path;
Loran Keuning @Loran_Keuning
Thank you for your reply! Sadly i get this: Error: Cannot read property 'path' of undefined
Dustin Harris @Dustin_Harris
What version of Pro Tools are you on? Maybe try it as this:
const videoFilePath = sf.app.proTools.invalidate().getFileLocation().fileLocations[0].path;
Loran Keuning @Loran_Keuning
It does work on all audio tracks but still gives me the same message on a selected video. I'm on Pro Tools Studio 2024.10 but have also tried it on Pro Tools Studio 2024.6. It's like the video track is a blind spot for my pro tools and i don't know if that's just Pro Tools being Pro Tools or something as gone wrong with the version on my laptop (MacOS 14.7.1 )
Dustin Harris @Dustin_Harris
Ahh I see. It might be a limitation of Pro Tools Studio...
Loran Keuning @Loran_Keuning
Ah i see. to bad! The only 2 ways i found the video filepath is by either, Saving a new session in a fixed location with Preserve Folder Hierarchy on or getting it trough the workspace session /session video files folder. The first way is way to convoluted and breaks easily but i haven't found a way to get the workspace way to work for me. I was hoping i could parse the path info from the ptx file somewhere but so far no luck (they have to store the info somewhere right?!). Thank you for looking into it Dustin!
Dustin Harris @Dustin_Harris
Yeah, I tried getting the path from the getSessionInfo() method, but for some reason pro tools doesn't include the video files in the sessionInfo list... I'll keep thinking about it.
Loran Keuning @Loran_Keuning
arg okay i made something that kinda works for the Studio Users. You need to have the video track selected for this to work right now as this is only meant to be a small part of the main script =0.
// =============== EXPENDS THE SELECTED VIDEO CLIP =============== // Activate Pro Tools sf.ui.proTools.appActivateMainWindow(); // Open Video Universe Window sf.ui.proTools.menuClick({ menuPath: ["Window", "Video Universe"], }); sf.wait(); const videoUniverse = sf.ui.proTools.windows.whoseTitle.is("Video Universe").first; videoUniverse.elementWaitFor(); // Click on the "Video Universe" window to activate it const clickPoint = videoUniverse.mouseClickElement({ relativePosition: { "x": 10, "y": 30 }, clickType: "Move", clickCount: 1, }).clickPoint; sf.wait(); // Double-click on the clicked point sf.mouse.doubleClick({ position: clickPoint, }); // Close Video Universe window sf.ui.proTools.menuClick({ menuPath: ["Window", "Video Universe"], }); videoUniverse.elementWaitFor({ waitType: "Disappear" }); sf.wait(); // =============== GETS THE VIDEO CLIP PARENT NAME =============== // --------------- menuitem: clip-rename.. doesn't work for video in ProTools Studio --------------- // Move mouse to selected track and get its position sf.ui.proTools.selectedTrack.mouseClickElement({ anchor: "MidCenter", clickType: "Move", }); // Retrieve relative mouse position const mainWindow = sf.ui.proTools.mainWindow; const mousePos = sf.mouse.getPosition().position; const relMousePos = { x: 0, y: mousePos.y - mainWindow.position.y }; // Click near the relative position and open the popup menu const clickPoint2 = mainWindow.mouseClickElement({ relativePosition: relMousePos, anchor: "TopCenter", clickType: "Move", }).clickPoint; const popupMenu = sf.menu.openPopupMenuFromPosition({ position: clickPoint2, isRightClick: true, }).popupMenu; // Open Rename dialog popupMenu.menuClickPopupMenu({ menuPath: ["Rename..."] }); const renameWin = sf.ui.proTools.windows.whoseTitle.is('Name').first; // Wait for Rename window to appear renameWin.elementWaitFor(); // Retrieve and log clip info const clipInfo = renameWin.groups.whoseTitle.is("Clip Info").first.children .whoseRole.is("AXStaticText").allItems; // Extract the second value (assuming it's the filename or relevant info) const clipFileName = clipInfo[1].value.invalidate().value; // Log the extracted clip info for reference log(clipFileName); // Click OK to close Rename window renameWin.buttons.whoseTitle.is("OK").first.elementClick(); renameWin.elementWaitFor({ waitType: "Disappear" }); // =============== OPENS WORKSPACE AND SEARCHES FOR VIDEO =============== // Now perform the workspace actions // Open workspace (always with alt+o) sf.keyboard.press({ keys: "alt+o" }); sf.wait(); // Wait for the workspace to open const workspaceWindow = sf.ui.proTools.windows.whoseTitle.startsWith("Workspace:").first; workspaceWindow.elementWaitFor(); // Wait for workspace window to appear // Click the search field and type the filename stored in clipFileName workspaceWindow.textFields.whoseTitle.is("text search").first.elementClick(); sf.wait(); sf.keyboard.type({ text: clipFileName }); // Use the clipFileName variable sf.wait(); // =============== REVEALS FINDER FOR VIDEO =============== // Click the upper left corner of the main UI element of the workspace to select the file workspaceWindow.tables.whoseTitle.is("TextGridView").allItems[3].mouseClickElement({ clickType: "Move" }); // Open the right-click menu at the current mouse position and click "Reveal in Finder" const position = sf.mouse.getPosition().position; const popupMenu2 = sf.menu.openPopupMenuFromPosition({ position, isRightClick: true }).popupMenu; popupMenu2.menuClickPopupMenu({ menuPath: ["Reveal in Finder"] }); sf.wait(); sf.ui.finder.appActivateMainWindow(); let path = sf.ui.finder.firstSelectedPath; log(path);
- In reply toLoran_Keuning⬆:
Dustin Harris @Dustin_Harris
for what it's worth, the code I posted about DOES work on Pro Tools ultimate or whatever they call it now?
Loran Keuning @Loran_Keuning
Ah thanks for checking! I will make sure to include it for the ultimate users. It the output just straight the filepath like if you do the same function for a audio track?