Welcome to WSL!

Make yourself at home, but before posting, please may I ask you to read the following topics.


Posting 101
Server space, screenshots, and you

Thank you!

PS. please pretty please:


Image

Add MediaPoolItem as a new MediaIn Node to comp via Python 2 script

User avatar
D E S T I I N Y
Posts: 2
Joined: Mon Feb 10, 2020 8:21 am

Add MediaPoolItem as a new MediaIn Node to comp via Python 2 script

#1

Post by D E S T I I N Y » Mon Feb 10, 2020 9:38 am

Hi,

I recently started working with Davinci Resolve Studio 16. I am very new to both Resolve and scripting in python. (Big noob ;))
I'm currently working on a project in which I want to create about 1000, 10 second long, animated (via macro) videos.

The script is supposed to create the video with two different Media items (png's) every time.
I've managed to find out all the things I need, to create the videos via script. Except for one thing.

And that's my Question:

How do I add a MediaPoolItem as a new MediaIn Node to my comp?
I've managed to get my MediaPoolItem object but can't figure out how to add it to the comp

AddNodes.PNG

I want to create a new "MediaIn2" and "MediaIn3" node each iteration. (new *.png file from the media pool)

Is it even possible to do that?
Is there a way you can maybe change "MEDIA_PATH" of a MediaIn Node because I can't figure it out with (comp.MediaIn2.GetData('MediaProps'))

I hope everything makes sense, because I honestly don't know the terms etc.

Best regards

D E S T II N Y
You do not have the required permissions to view the files attached to this post.

User avatar
SecondMan
Site Admin
Posts: 4491
Joined: Thu Jul 31, 2014 5:31 pm
Answers: 28
Location: Vancouver, Canada
Been thanked: 117 times
Contact:

Re: Add MediaPoolItem as a new MediaIn Node to comp via Python 2 script

#2

Post by SecondMan » Mon Feb 10, 2020 6:51 pm

As for an answer that doesn't necessarily answer your question at all... :)

Are you sure that Resolve is the best tool for the job here?

1000 separate 10 second renders, that's creeping up on being 3 hours of material. Three times that in inputs (MediaIn), makes 3000 items in the Media Pool?

I'm very far from being a Resolve expert, but given the overhead of it in general, I'd be wary of attempting such a project in there.

Now you have Resolve Studio - if that's a version with a dongle you have access to Fusion Studio. Creating 1000 Fusion comps using scripting (if you're starting out anyway, do consider Lua, but Python is fine) and submitting those to the Render Manager to cook over as many machines as you like, now that I'd be much more confident about.

User avatar
D E S T I I N Y
Posts: 2
Joined: Mon Feb 10, 2020 8:21 am

Re: Add MediaPoolItem as a new MediaIn Node to comp via Python 2 script

#3

Post by D E S T I I N Y » Tue Feb 11, 2020 7:42 am

I actually figuered it out myself via trial and error and the help of print dir(object).
I found out that you have to change a MediaIn-node's MediaID in order to change the .png file used.

I managed the mediaPoolItems over a folder structure, so that's not a problem.
And I add the video to the renderQueue, render it and then delete the renderjob. I do this so I can use the same nodes every time.

So how to change a MediaIn-node's MediaID to a mediaPoolItem's MediaID:
  1. 'Setup'
  2. resolve = dvr_script.scriptapp("Resolve")
  3. fusion = resolve.Fusion()
  4. projectManager = resolve.GetProjectManager()
  5. project = projectManager.GetCurrentProject()
  6. timeline = project.GetCurrentTimeline()
  7. timelineItem = timeline.GetCurrentVideoItem()
  8. mediaPool = project.GetMediaPool()
  9.  
  10. 'Get example comp'
  11. comp = timelineItem.GetFusionCompByIndex(1.0)
  12.  
  13. 'Get example mediaPoolItem'
  14. rootFolder = mediaPool.GetRootFolder()
  15. clips = rootFolder.GetClips()
  16. mediaPoolItem = clips[1.0]
  17.  
  18. 'Change mediaIn1s picture'
  19. comp.MediaIn1.SetInput('MediaID' , mediaPoolItem.GetMediaId())
  20. #----> changed picture

User avatar
Iddos
Posts: 30
Joined: Sat Oct 06, 2018 4:21 pm
Answers: 1
Been thanked: 2 times

Re: Add MediaPoolItem as a new MediaIn Node to comp via Python 2 script

#4

Post by Iddos » Tue Feb 11, 2020 8:38 pm

Nice!
Thanks for sharing