Python Forum
Python - Import file sequence into Media Pool
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Python - Import file sequence into Media Pool
#1
MacOS 10.13.2 | Python 3.6.8 | External API Application: DaVinci Resolve v15.3.1

Hi. I am working on some automation for DVR and got the following issue. I have a .txt file that contains python created links to video clips (with full path) for import into DaVinci Resolve. Like this:

clip_import.txt
'/Volumes/RAID/Data/Media/TWO_CHAIRS/footage/FW_A01_2021-12-12_2002_C0127/FW_A01_2021-12-12_2002_C0127_000000.dng', '/Volumes/RAID/Data/Media/TWO_CHAIRS/footage/FW_A01_2021-12-12_2003_C0129/FW_A01_2021-12-12_2003_C0129_000000.dng', '/Volumes/RAID/Data/Media/TWO_CHAIRS/footage/FW_A01_2021-12-12_2003_C0130/FW_A01_2021-12-12_2003_C0130_000000.dng',
I am loading the .txt file as follows: (python 3.6.8)
# Read the search result clipList
with open("/Volumes/audio/TRANSCRIBE/SearchPhrases/" + searchPhrase + ".txt") as f:
    clipListRead = f.readlines()
    print('cliplistRead: ' + str(clipListRead))
Here is the OUTPUT:
["'/Volumes/RAID/Data/Media/TWO_CHAIRS/footage/FW_A01_2021-12-12_2002_C0127/FW_A01_2021-12-12_2002_C0127_000000.dng', '/Volumes/RAID/Data/Media/TWO_CHAIRS/footage/FW_A01_2021-12-12_2003_C0129/FW_A01_2021-12-12_2003_C0129_000000.dng', '/Volumes/RAID/Data/Media/TWO_CHAIRS/footage/FW_A01_2021-12-12_2003_C0130/FW_A01_2021-12-12_2003_C0130_000000.dng', '/Volumes/RAID/Data/Media/TWO_CHAIRS/footage/FW_A01_2021-12-12_2003_C0131/FW_A01_2021-12-12_2003_C0131_000000.dng', "]
I created a variable called clipListRead (see above) and plugged that into the (API) code below:
clips = resolve.GetMediaStorage().AddItemsToMediaPool(clipListRead)
But that does not work for some reason. My question is: Do I need to create an object or an array to make this work? Or is this a Davinci Resolve API issue? Any other tricks to this? The focus seems to be on what can be plugged into that function provided by the DVR API. AddItemsToMediaPool(??????). I couldn't find anything in the docs so far.
As a note, the same code below (path filled in by hand) works fine and is the correct format to import the two clips into resolve.
clips = resolve.GetMediaStorage().AddItemsToMediaPool('/Volumes/RAID/Data/Media/TWO_CHAIRS/footage/FW_A0_C0135/FW_A0_C0135_000000.dng', '/Volumes/RAID/Data/Media/TWO_CHAIRS/footage/FW_A0_C0135/FW_A0_C0135_000000.dng',)
Thank you!
MacOS 10.13.2. | DVR v15.3.1 | Python 3.6.8
Reply
#2
you read all the file paths as one big string inside a list. It looks all paths are on one line in the text file
not tested but something like
with open(f"/Volumes/audio/TRANSCRIBE/SearchPhrases/{searchPhrase}.txt") as f:
    clipListRead = [item.strip() for item in f.readline().split(',') if item.strip()]
    print('cliplistRead:', clipListRead)
    clips = resolve.GetMediaStorage().AddItemsToMediaPool(clipListRead)
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs

Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  How would I be able to detect a media player app playing a video. phpjunkie 2 526 Oct-16-2023, 02:09 PM
Last Post: phpjunkie
Video doing data treatment on a file import-parsing a variable EmBeck87 15 2,665 Apr-17-2023, 06:54 PM
Last Post: EmBeck87
  Import XML file directly into Excel spreadsheet demdej 0 798 Jan-24-2023, 02:48 PM
Last Post: demdej
  Multiprocessing Pool Multiple Instances How to Kill by Pool ID sunny9495 0 735 Nov-16-2022, 05:57 AM
Last Post: sunny9495
  Python & Windows Media Player Extra 9 4,745 Apr-05-2022, 10:34 PM
Last Post: Extra
  Python multiprocessing Pool apply async wait for process to complete sunny9495 6 6,213 Apr-02-2022, 06:31 AM
Last Post: sunny9495
  How from sklearn.datasets import load_diabetes change to import to CSV file Anldra12 0 1,811 Dec-25-2021, 07:20 PM
Last Post: Anldra12
  How to import file and function in another folder SriRajesh 1 3,075 Dec-18-2021, 08:35 AM
Last Post: Gribouillis
  Pool multiprocessing - know current status in loop? korenron 0 1,604 Jul-28-2021, 08:49 AM
Last Post: korenron
  pool mysql error - not catch by try\except? korenron 1 2,101 Jul-05-2021, 11:26 AM
Last Post: ibreeden

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020