qmasingarbe / pymiere Goto Github PK
View Code? Open in Web Editor NEWPython for Premiere pro
License: GNU General Public License v3.0
Python for Premiere pro
License: GNU General Public License v3.0
Thank you for developing this module! I'd like to let you know because there's an issue.
This issue occurs in the motion graphic template code in the example.
The problem does not occur until mgt_component is obtained from the mgt clip, but if the value is of the dict type when the set value is called, the execution is stopped with an Illlegal Parameter type error.
I am currently running Premier Pro 2021 and using Python 3.8 version.
Below is an error message:
Position
{'pymiere_id': 'VCRAgJl6DO'}
Traceback (most recent call last):
File "C:/Coding/premiere/main.py", line 70, in <module>
prop.setValue(value, True)
File "C:\Coding\venv\lib\site-packages\pymiere\objects\premiere_objects.py", line 4924, in setValue
return self._eval_on_this_object("setValue({}, {})".format(_format_object_to_es(value), _format_object_to_es(updateUI)))
File "C:\Coding\venv\lib\site-packages\pymiere\core.py", line 176, in _eval_on_this_object
result = _eval_script_returning_object(line)
File "C:\Coding\venv\lib\site-packages\pymiere\core.py", line 469, in _eval_script_returning_object
result = eval_script(script, decode_json=True)
File "C:\Coding\venv\lib\site-packages\pymiere\core.py", line 114, in eval_script
raise ExtendScriptError(response_decoded)
pymiere.core.ExtendScriptError:
Error at line 2 : Illegal Parameter type
1 try{
2 var tmp = $._pymiere['xa9jqbfCgf'].setValue({"""pymiere_id""": """VCRAgJl6DO"""}, true);
3 if(typeof tmp === 'object' && tmp !== null){
I'd appreciate it if you could solve it!
I am trying to export a sequence in premiere using pymiere, and it's chugging along nicely until after about 3 minutes, I get the following error:
Traceback (most recent call last):
File "C:\Users\Jordan\AppData\Local\Programs\Python\Python39\lib\site-packages\urllib3\connectionpool.py", line 703, in urlopen
httplib_response = self._make_request(
File "C:\Users\Jordan\AppData\Local\Programs\Python\Python39\lib\site-packages\urllib3\connectionpool.py", line 449, in _make_request
six.raise_from(e, None)
File "<string>", line 3, in raise_from
File "C:\Users\Jordan\AppData\Local\Programs\Python\Python39\lib\site-packages\urllib3\connectionpool.py", line 444, in _make_request
httplib_response = conn.getresponse()
File "C:\Users\Jordan\AppData\Local\Programs\Python\Python39\lib\http\client.py", line 1345, in getresponse
response.begin()
File "C:\Users\Jordan\AppData\Local\Programs\Python\Python39\lib\http\client.py", line 307, in begin
version, status, reason = self._read_status()
File "C:\Users\Jordan\AppData\Local\Programs\Python\Python39\lib\http\client.py", line 276, in _read_status
raise RemoteDisconnected("Remote end closed connection without"
http.client.RemoteDisconnected: Remote end closed connection without response
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Users\Jordan\AppData\Local\Programs\Python\Python39\lib\site-packages\requests\adapters.py", line 440, in send
resp = conn.urlopen(
File "C:\Users\Jordan\AppData\Local\Programs\Python\Python39\lib\site-packages\urllib3\connectionpool.py", line 785, in urlopen
retries = retries.increment(
File "C:\Users\Jordan\AppData\Local\Programs\Python\Python39\lib\site-packages\urllib3\util\retry.py", line 550, in increment
raise six.reraise(type(error), error, _stacktrace)
File "C:\Users\Jordan\AppData\Local\Programs\Python\Python39\lib\site-packages\urllib3\packages\six.py", line 769, in reraise
raise value.with_traceback(tb)
File "C:\Users\Jordan\AppData\Local\Programs\Python\Python39\lib\site-packages\urllib3\connectionpool.py", line 703, in urlopen
httplib_response = self._make_request(
File "C:\Users\Jordan\AppData\Local\Programs\Python\Python39\lib\site-packages\urllib3\connectionpool.py", line 449, in _make_request
six.raise_from(e, None)
File "<string>", line 3, in raise_from
File "C:\Users\Jordan\AppData\Local\Programs\Python\Python39\lib\site-packages\urllib3\connectionpool.py", line 444, in _make_request
httplib_response = conn.getresponse()
File "C:\Users\Jordan\AppData\Local\Programs\Python\Python39\lib\http\client.py", line 1345, in getresponse
response.begin()
File "C:\Users\Jordan\AppData\Local\Programs\Python\Python39\lib\http\client.py", line 307, in begin
version, status, reason = self._read_status()
File "C:\Users\Jordan\AppData\Local\Programs\Python\Python39\lib\http\client.py", line 276, in _read_status
raise RemoteDisconnected("Remote end closed connection without"
urllib3.exceptions.ProtocolError: ('Connection aborted.', RemoteDisconnected('Remote end closed connection without response'))
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Users\Jordan\My Drive\GTD\YouTube\Automation\pymiere_test.py", line 19, in <module>
File "C:\Users\Jordan\My Drive\GTD\YouTube\Automation\video_maker.py", line 32, in make
sequence = self.get_sequence_from_clip_array(clip_array)
File "C:\Users\Jordan\My Drive\GTD\YouTube\Automation\video_maker.py", line 80, in export_sequence
def export_sequence(self, sequence):
File "C:\Users\Jordan\AppData\Local\Programs\Python\Python39\lib\site-packages\pymiere\objects\premiere_objects.py", line 1315, in exportAsMediaDirect
return self._eval_on_this_object("exportAsMediaDirect({}, {}, {})".format(_format_object_to_es(outputFilePath), _format_object_to_es(presetPath), _format_object_to_es(workAreaType)))
File "C:\Users\Jordan\AppData\Local\Programs\Python\Python39\lib\site-packages\pymiere\core.py", line 176, in _eval_on_this_object
result = _eval_script_returning_object(line)
File "C:\Users\Jordan\AppData\Local\Programs\Python\Python39\lib\site-packages\pymiere\core.py", line 472, in _eval_script_returning_object
result = eval_script(script, decode_json=True)
File "C:\Users\Jordan\AppData\Local\Programs\Python\Python39\lib\site-packages\pymiere\core.py", line 97, in eval_script
response = requests.post(PANEL_URL, json={"to_eval": "try{\n" + code + "\n}catch(e){e.error=true;ExtendJSON.stringify(e)}"})
File "C:\Users\Jordan\AppData\Local\Programs\Python\Python39\lib\site-packages\requests\api.py", line 117, in post
return request('post', url, data=data, json=json, **kwargs)
File "C:\Users\Jordan\AppData\Local\Programs\Python\Python39\lib\site-packages\requests\api.py", line 61, in request
return session.request(method=method, url=url, **kwargs)
File "C:\Users\Jordan\AppData\Local\Programs\Python\Python39\lib\site-packages\requests\sessions.py", line 529, in request
resp = self.send(prep, **send_kwargs)
File "C:\Users\Jordan\AppData\Local\Programs\Python\Python39\lib\site-packages\requests\sessions.py", line 645, in send
r = adapter.send(request, **kwargs)
File "C:\Users\Jordan\AppData\Local\Programs\Python\Python39\lib\site-packages\requests\adapters.py", line 501, in send
raise ConnectionError(err, request=request)
requests.exceptions.ConnectionError: ('Connection aborted.', RemoteDisconnected('Remote end closed connection without response'))
I'm not sure what to make of it. Does premiere become non-responsive during export to whatever protocol is being used to query it? Is there a relatively painless workaround here, or a way to explicitly re-establish communication?
<class 'pymiere.core.ExtendScriptError'>
TypeError at line 2 : Cannot set property start
1 try{
2 var tmp =
3 if(typeof tmp === 'object' && tmp !== null){ <traceback object at 0x0000020C1320F480>
Traceback (most recent call last):
File "d:\Pete's Data\OneDrive\Python Scripts\pymiere\demo_ui.py", line 22, in wrapper
result = func(self, *args, **kwargs)
File "d:\Pete's Data\OneDrive\Python Scripts\pymiere\demo_ui.py", line 179, in move_selected_func
wrappers.move_clip(clip, seconds)
File "d:\Pete's Data\OneDrive\Python Scripts\pymiere\pymiere\wrappers.py", line 134, in move_clip
setattr(clip, param, time_object)
File "d:\Pete's Data\OneDrive\Python Scripts\pymiere\pymiere\objects\premiere_objects.py", line 3787, in start
self._eval_on_this_object("start = {}".format(_format_object_to_es(start)))
File "d:\Pete's Data\OneDrive\Python Scripts\pymiere\pymiere\core.py", line 163, in _eval_on_this_object
result = _eval_script_returning_object(line)
File "d:\Pete's Data\OneDrive\Python Scripts\pymiere\pymiere\core.py", line 425, in _eval_script_returning_object
result = eval_script(script, decode_json=True)
File "d:\Pete's Data\OneDrive\Python Scripts\pymiere\pymiere\core.py", line 102, in eval_script
raise ExtendScriptError(response_decoded)
pymiere.core.ExtendScriptError:
TypeError at line 2 : Cannot set property start
1 try{
2 var tmp =
3 if(typeof tmp === 'object' && tmp !== null){
weird issue when I try to run this code via a .py file:
import pymiere print(pymiere.objects.app.isDocumentOpen())
AttributeError: module 'pymiere' has no attribute 'objects'
if I open python in a shell and manually run that code it works (returns true if premiere is open and breaks if premiere is not open)
anyone else get this?
I am trying to export multiple videos by replacing source video everytime using the script.
When I use exportAsMediaDirect to export video, the actual source video is locked, so I could not process the next file. However if I perform same from Premiere UI all works good.
Line 112 in b0c6556
Traceback (most recent call last):
File "c:\file.py", line 39, in
param.setValue(json, True)
File "c:\Users\user\AppData\Local\Programs\Python\Python310\lib\site-packages\pymiere\objects\premiere_objects.py", line 5012, in setValue
return self._eval_on_this_object("setValue({}, {})".format(_format_object_to_es(value), _format_object_to_es(updateUI)))
File "c:\Users\user\AppData\Local\Programs\Python\Python310\lib\site-packages\pymiere\core.py", line 176, in _eval_on_this_object
result = _eval_script_returning_object(line)
File "c:\Users\user\AppData\Local\Programs\Python\Python310\lib\site-packages\pymiere\core.py", line 472, in _eval_script_returning_object
result = eval_script(script, decode_json=True)
File "c:\Users\user\AppData\Local\Programs\Python\Python310\lib\site-packages\pymiere\core.py", line 114, in eval_script
raise ExtendScriptError(response_decoded)
pymiere.core.ExtendScriptError:
Error at line 2 : Illegal Parameter type
1 try{
2 var tmp =
3 if(typeof tmp === 'object' && tmp !== null){
Hi! First off, thank you so much. This module has been a life saver. I did have an issue when trying to import a mogurt. I'm running Python 3.9.1. and I'm on Premiere 2020.
I used the code in the example documentation here (replacing path with my own mogrt of course):
import pymiere
from pymiere.wrappers import time_from_seconds
sequence = pymiere.objects.app.project.activeSequence
mogrt_path = r"C:\path\to\template.mogrt"
mgt_clip = sequence.importMGT(
path=mogrt_path,
time=time_from_seconds(1), # start time
videoTrackIndex=1, audioTrackIndex=1 # on which track to place it
)
mgt_component = mgt_clip.getMGTComponent()
for prop in mgt_component.properties:
print(prop.displayName)
value = prop.getValue()
print(value)
prop.setValue(value, True)
And I received this traceback:
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/pymiere/objects/premiere_objects.py", line 1284, in importMGT
return TrackItem(**self._eval_on_this_object("importMGT({}, {}, {}, {})".format(_format_object_to_es(path), _format_object_to_es(time), _format_object_to_es(videoTrackIndex), _format_object_to_es(audioTrackIndex))))
TypeError: pymiere.objects.premiere_objects.TrackItem() argument after ** must be a mapping, not NoneType
I've been spinning my wheels and googling hard to try to figure out a solution, so figured I'd just ask. Thank you so much in advance.
I'm going to just post the error messages for the next few issues - they all relate to demo_up.py on the same environment as follows:
Windows 10 latest version, Premiere Pro (CC) latest version, Python 3.9.
Please let me know if you don't want this level of detail as there may well be a common root cause e.g. incompatible versions or known bug in Premiere Pro 14.5.0... otherwise I'll keep posting and hope that's not too demoralising!
<class 'pymiere.core.ExtendScriptError'>
Error at line 2 : Illegal Parameter type
1 try{
2 var tmp = $._pymiere['D6zv6ieWY0'].setPlayerPosition(11552436000000);
3 if(typeof tmp === 'object' && tmp !== null){ <traceback object at 0x000001CC28323780>
Traceback (most recent call last):
File "d:\Pete's Data\OneDrive\Python Scripts\pymiere\demo_ui.py", line 151, in backward_func
self.active_sequence.setPlayerPosition(current_time.ticks)
File "d:\Pete's Data\OneDrive\Python Scripts\pymiere\pymiere\objects\premiere_objects.py", line 1095, in setPlayerPosition
self._eval_on_this_object("setPlayerPosition({})".format(_format_object_to_es(pos)))
File "d:\Pete's Data\OneDrive\Python Scripts\pymiere\pymiere\core.py", line 163, in _eval_on_this_object
result = _eval_script_returning_object(line)
File "d:\Pete's Data\OneDrive\Python Scripts\pymiere\pymiere\core.py", line 425, in _eval_script_returning_object
result = eval_script(script, decode_json=True)
File "d:\Pete's Data\OneDrive\Python Scripts\pymiere\pymiere\core.py", line 102, in eval_script
raise ExtendScriptError(response_decoded)
pymiere.core.ExtendScriptError:
Error at line 2 : Illegal Parameter type
1 try{
2 var tmp = $._pymiere['D6zv6ieWY0'].setPlayerPosition(11552436000000);
3 if(typeof tmp === 'object' && tmp !== null){
Hi,
Thanks for making this awesome Python wrapper for ExtendScript. The results have been excellent so far.
Seems like it's missing the createNewSequenceFromClips()
method.
It will be cool if the Python package is in sync with the latest ExtendScript API.
Nevertheless, your work is excellent. I cannot thank you enough.
The intended attribute numItems does not seem to work. Iterating over the collection is still doable though.
But other than that this has been incredible. Sub-request: Please add a link for me to buy you a coffee or something
I get the following error after clicking the Import / Import & Insert buttons in demo_ui.py and selecting a media file to import:
<class 'TypeError'> pymiere.core.Array() argument after ** must be a mapping, not str <traceback object at 0x000001920A80AB00>
Traceback (most recent call last):
File "d:\Pete's Data\OneDrive\Python Scripts\pymiere\demo_ui.py", line 22, in wrapper
result = func(self, *args, **kwargs)
File "d:\Pete's Data\OneDrive\Python Scripts\pymiere\demo_ui.py", line 211, in import_insert_func
item = self.import_func()
File "d:\Pete's Data\OneDrive\Python Scripts\pymiere\demo_ui.py", line 22, in wrapper
result = func(self, *args, kwargs)
File "d:\Pete's Data\OneDrive\Python Scripts\pymiere\demo_ui.py", line 201, in import_func
pymiere.objects.app.project.importFiles([file_to_import], True, root_bin, True)
File "d:\Pete's Data\OneDrive\Python Scripts\pymiere\pymiere\objects\premiere_objects.py", line 425, in importFiles
return self._eval_on_this_object("importFiles({}, {}, {}, {})".format(_format_object_to_es(arrayOfFilePathsToImport), _format_object_to_es(suppressUI), _format_object_to_es(targetBin), _format_object_to_es(importAsNumberedStills)))
File "d:\Pete's Data\OneDrive\Python Scripts\pymiere\pymiere\core.py", line 380, in _format_object_to_es
return "$._pymiere['{}']".format(Array.from_python_list(obj)._pymiere_id)
File "d:\Pete's Data\OneDrive\Python Scripts\pymiere\pymiere\core.py", line 362, in from_python_list
return cls(_eval_script_returning_object("[{}]".format(", ".join([_format_object_to_es(item) for item in python_list])), as_kwargs=True))
TypeError: pymiere.core.Array() argument after ** must be a mapping, not str
Is there functionality in pymiere to pass explicit ExtendScript snippets to Premiere and have them executed?
Trying out the following:
import pymiere
project = pymiere.objects.app.project
print(project.rootItem.children[0].children[1].videoComponents[0].displayName)
Currently, there are 2 master clip effects on this file.
Gives me this error:
Traceback (most recent call last):
File "d:/Dropbox/_CORA_LA/code/xablau-premiere/premiere.py", line 5, in <module>
print(project.rootItem.children[0].children[1].videoComponents[0].displayName)
File "D:\Dropbox\_CORA_LA\code\xablau-premiere\.venv\lib\site-packages\pymiere\objects\premiere_objects.py", line 676, in videoComponents
return ComponentCollection(**kwargs) if kwargs else None
TypeError: type object argument after ** must be a mapping, not str
Is there an analogous function to qe_project.getVideoEffectList()
for audio effects? I am trying to apply a noise gate that uses the "dynamics" plugin, and I'm not sure if it is accessible using QE or through some other method.
Can we add new video tracks by api๏ผ
Hi,
I've made some function for my workflow thanks for your pymiere lib.
But I noticed than the pymiere.objects.qe is treated as a PymiereGenericObject and I cannot access its methods.
It will be a great improvement if we could access it.
Do you think it would be possible ?
Maybe you can just lead me to a solution, using your work code.
Thanks a lot
Bryan
Hi,
I try to create bin in my project
import pymiere
from pymiere.core import *
from pymiere.exe_utils import *
from pymiere.wrappers import *
from pymiere.objects.premiere_objects import *
from pymiere.objects.start_vars import *
ProjectItem.createBin("Create New Bin")
But I have this error
Traceback (most recent call last):
File "Z:\DAPControls\Trash\python\Projets\pyPremiere\pyProjet.py", line 49, in
ProjectItem.createBin("Create New Bin")
TypeError: ProjectItem.createBin() missing 1 required positional argument: 'name'
Any idea ?
Feature Request:
Hi Quentin, I hope you've seen and will approve my recent Pull Request to make Pymiere
installable via pip
soon. In the spirit of making software super-easy to install, and possibly make Pymiere
attractive to end users as well as developers, is there any way we could automate the download and installation of Adobe's Extension Manager Command Line tool and pymiere_link.zxp
?
I see there's at least one .bat file in Pymiere
already which gives me hope you might have the skills to do this, particularly as we're only looking at Windows 10 installation currently!
Pymiere
is opened, check if the extension is already installed (maybe create a micro config file after installation, unless there's a more elegant/fast way to 'detect' the extension exists?).If not installed:
Both files presumably default to user's home/downloads folder, you could use very quick and simple PySimpleGui popups to confirm location (I can provide, if you're not familiar with PySimpleGui yet... though the learning curve is amazingly fast!).
If you need popups for any user confirmations I can easily provide those too.
All the best,
Peter
I don't know if it's only for my config, but the python environment must be at least 3.7, cause on 3.6 got an issue with => from subprocess import check_output
Originally posted by @bryhimself in #3 (comment)
I am trying to use pymiere to export a sequence using adobe media encoder. Below is my code to do that, copied from the documentation:
app.encoder.launchEncoder()
job_id = pymiere.objects.app.encoder.encodeSequence(
sequence,
output_path, # path of the exported file
presetPath=export_settings_file,
workArea=pymiere.objects.app.encoder.ENCODE_ENTIRE, # what part of the sequence to export. Others are: ENCODE_IN_TO_OUT or ENCODE_WORKAREA
removeOnCompletion=False, # clear this job of media encoder render queue on completion
startQueueImmediately=False # seem not to be working in Premiere 2017? Untested on versions above
)
app.encoder.startBatch()
When I try to export the sequence using Premiere itself, everything works fine. However, when I attempt to export using the above code with media encoder, media encoder fails to export the file, and for good reason, the output file appears to be empty:
An error was encountered while writing the output file. The output destination could not be found. Check that the output directory still exists. If the output directory is on a network or external device, check that the connection is active.
- Source File: C:\Users\Jordan\AppData\Local\Temp\0309.prproj
- Output File: .mp4
- Preset Used: Custom
- Video:
- Audio:
- Bitrate:
- Encoding Time: 00:00:00
01/31/2022 09:25:22 PM : Encoding Failed
(taken from the text output of Media encoder)
When I run with the outputPath explicitly as a keyword argument, as per the official premiere pro documentation, it isn't recognized:
app.encoder.launchEncoder()
job_id = pymiere.objects.app.encoder.encodeSequence(
sequence,
outputPath=output_path, # path of the exported file
presetPath=export_settings_file,
workArea=pymiere.objects.app.encoder.ENCODE_ENTIRE, # what part of the sequence to export. Others are: ENCODE_IN_TO_OUT or ENCODE_WORKAREA
removeOnCompletion=False, # clear this job of media encoder render queue on completion
startQueueImmediately=False # seem not to be working in Premiere 2017? Untested on versions above
)
app.encoder.startBatch()
yields the following error:
Traceback (most recent call last):
File "C:\Users\Jordan\My Drive\GTD\YouTube\Automation\pymiere_test.py", line 57, in <module>
job_id = pymiere.objects.app.encoder.encodeSequence(
TypeError: encodeSequence() got an unexpected keyword argument 'outputPath'
This tells me that the argument perhaps isn't getting parsed or properly sent to the function.
Some methods like pymiere.objects.app.project.createNewSequence() and .save() cause Premiere to pop-up a dialog box prompting for "OK" or "Save Yes/N". This pauses the entire automation workflow while waiting for a user to manually move a script on to the next step.
Feature Request: For such functions, is there a way we can specify the arguments/actions in advance, e.g. using *args/**kwargs, so the pop-up boxes are handled programmatically?
according to this https://ppro-scripting.docsforadobe.dev/general/marker.html#marker-start, marker start and end support read/write? However my attempt to set start and end after marker creation never works. What is the proper way to do so? Thanks
From the function in exe_utils.py
I understand this library is written for Windows.
Does anybody know if (and how) I can change this so it works on a Mac?
the docstring says that clone() returns the cloned sequence but it returns None. The reason this is an issue is because if I call clone() on the same sequence more than once, I will create 2 new sequences with the same name ("<cloned_sequence_name> Copy") and I don't have a way of identifying which one is which.
Possible solutions:
Hi! I was try to change the value to - (18374966859398184000), while the default value is (18374686479671623000). For some reason after this line property.setValue(18374966859398184000, True)
my "Key Color" is still black and the new value is - (0). If I try to change the value to a shorter number like property.setValue(1837496685, True)
it's work, but the color isn't what I need, and when I add more numbers, the value isn't changed like I expected.
P.s. I just need to change the "Key Color" in "Ultra Key" to "FFFEFE".
Python 3.9, Windows 10.
Hello,
I've seen a little omission in ComponentParam.getKeys() method.
The returned object isn't of the correct type. for example, I got following result.
>>> p.sequences[41].videoTracks[1].clips[0].components[2].properties[8].getKeys()
{'pymiere_id': '7UEROfIzdT'}
I think it should return an Array and I'm getting the list of keys when I do
keys = Array(**self._parameter._eval_on_this_object("getKeys()"))
So, it should be:
def getKeys(self):
return Array(**self._parameter._eval_on_this_object("getKeys()"))
Regards,
Louise
I was creating and rendering auto reframe sequences when I noticed premiere will render the sequence before it's finished analyzing. This causes the video to render without any reframing. Adding a while loop solves this.
while not pymiere.Sequence.isDoneAnalyzingForVideoEffects(auto_reframe_sequence): print('Analyzing video effects') sleep(1)
Added this to premiere_objects:
def isDoneAnalyzingForVideoEffects(self): return (self._eval_on_this_object("isDoneAnalyzingForVideoEffects()"))
I'm trying to move imported images into a sequence, and am having problem with this path:
C:/Users/Corey/Desktop/testFolder/download21/0.jpg
When replacing the path in the example code with this new path, I get the error below. This same error happens whether I use the example code or my full code even further below. Any thoughts?
Traceback (most recent call last): File "C:/Users/Corey/Documents/OrganizedDocs/python/PremiereScripts/downloadFilesAndCreateSequence.py", line 17, in <module> project.activeSequence.videoTracks[0].insertClip(items[0], time_from_seconds(0)) File "C:\Python27\lib\site-packages\pymiere\objects\premiere_objects.py", line 3764, in insertClip self._check_type(clipProjectItem, ProjectItem, 'arg "clipProjectItem" of function "Track.insertClip"') File "C:\Python27\lib\site-packages\pymiere\core.py", line 209, in _check_type raise ValueError("{} shoud be of type {} but got '{}' (type {})".format(name, cls, obj, type(obj))) ValueError: arg "clipProjectItem" of function "Track.insertClip" shoud be of type <class 'pymiere.objects.premiere_objects.ProjectItem'> but got 'undefined' (type <type 'str'>)
My code below if it helps, but as I said the path itself is the problem, since I tried it manually with the example code. [edit] Apologies, a quote somewhere is messing up the code formatting here in github.
import pymiere
import requests
import os
from pymiere.wrappers import get_system_sequence_presets
from pymiere.wrappers import time_from_seconds
downloadListURLs = ["https://rarest.org/wp-content/uploads/2018/10/shadowless-first-edition-charizard.jpg", "https://i.pinimg.com/originals/b9/bc/64/b9bc643730761af9692ab9cf7a7af03a.jpg"]
downloadedFiles = []
downloadLocation = "C:/Users/Corey/Desktop/testFolder/"
isPremiereOpen = False
project = None
try:
isOpen = pymiere.objects.app.isDocumentOpen()
print "Connected successfully: %s" % isOpen
isPremiereOpen = True
project = pymiere.objects.app.project
except:
print "Premiere, or the pymiere panel is not open."
if isPremiereOpen:
folderCount = 1
newFolderName = ""
while True:
if os.path.exists(downloadLocation + "download" + str(folderCount)):
folderCount += 1
continue
else:
newFolderName = downloadLocation + "download" + str(folderCount) + "/"
os.makedirs(newFolderName)
break
count = 0
for url in downloadListURLs:
print "Downloading: %s" % url
r = requests.get(url, allow_redirects=True)
extension = url.split('.')[-1]
print "extension: %s" % extension
downloadedFilename = newFolderName + str(count) + "." + extension
open(downloadedFilename, "wb").write(r.content)
count += 1
downloadedFiles.append(downloadedFilename)
projPath = newFolderName + "compiledImages.pproj"
pymiere.objects.app.newProject(projPath)
sequence_preset_path = get_system_sequence_presets(category="HDV", resolution=None, preset_name="HDV 1080p25")
sequence_name = "Image Sequence"
pymiere.objects.qe.project.newSequence(sequence_name, sequence_preset_path)
sequence = [s for s in pymiere.objects.app.project.sequences if s.name == sequence_name][0]
pymiere.objects.app.project.openSequence(sequenceID=sequence.sequenceID)
for image in downloadedFiles:
success = project.importFiles([image], suppressUI = True, targetBin = project.getInsertionBin(), importAsNumberedStills=False)
print image
items = project.rootItem.findItemsMatchingMediaPath(image, ignoreSubclips=False)
print items
for i in items:
print i
sequence.videoTracks[0].insertClip(items[0], time_from_seconds(0))
Hello,
I love pymiere; it is wonderful! I found something I can't figure out though:
I am completely unable to code "pymiere.objects.app.openFCPXML" correctly.
in premiere_objects.py @ line 229, there's:
def openFCPXML(self):
return self._eval_on_this_object("openFCPXML()")
but the official docs have more arguments found @ 5.2.8
here: https://readthedocs.org/projects/premiere-scripting-guide/downloads/pdf/latest/
app.openFCPXML(path, projPath)
I've tested in on Mac and PC, and I seem to return either too few arguments or provide three.
I would have thought it was this, Mac version:
pymiere.objects.app.openFCPXML("foo-path/build.xml", "foo-path/build.proj")
Thank you for any advice you could suggest.
~D.
For some reason when i run this it will say that the Tempseq is 3 mins long, when the clip i am importing is 11 seconds long. The tick count is correct only when i recreate an error (See below) after the code that is supposed to grab the tick count.
Error:
Traceback (most recent call last):
File "c:\twitchclipadobe\twitchcliptoreel.py", line 97, in
tempSeqEndSeconds = tempSeqEndticks.seconds
AttributeError: 'int' object has no attribute 'seconds'
import pymiere as pym
import time
# gets input for the File Path of the Raw Twitch Clip.
# currently only set up for the cam on the right side.
rawClip = input("Enter File Path")
rawClipPath = rawClip.replace('"', "")
print(rawClipPath)
# opens the project file. Premiere must already be open.
pym.objects.app.openDocument("D:\JonDotYT\Reel template.prproj")
# Counts number of project items in the project folder
numofItems = pym.objects.app.project.rootItem.children.numItems
print("")
print("Number of Project Items: ")
print(numofItems)
print("")
# takes items in the project list as an list
itemList = pym.objects.app.project.rootItem.children
# enumerates (splits the list up) for each item in the list
iLenumerated = enumerate(itemList)
for i in iLenumerated:
print("pymiere ID of Items ")
print(i)
print("Item Name: " + itemList[i[0]].name)
print("")
# safety check to make sure that the offline clip that is to be replaced is found and selected
i = 0
clipToReplacestr = pym.objects.app.project.rootItem.children[0].name
while clipToReplacestr != "1. REPLACE WITH RAW CLIP":
clipToReplacestr = pym.objects.app.project.rootItem.children[i].name
clipToReplace = pym.objects.app.project.rootItem.children[i]
i += 1
if i > numofItems:
print("No item found with name: 1. REPLACE WITH RAW CLIP. Please ensure you have the correct file.")
quit()
# prints status check
print("found " + clipToReplacestr)
print("")
print("Pymiere project item ID:")
print(clipToReplace)
# replaces Offline video placeholder with selected video footage.
clipToReplace.changeMediaPath(rawClipPath, False)
# Creates a Sequence from the replaced clip to get the start and end time codes
tempSequence = pym.objects.app.project.createNewSequenceFromClips(
"Tempseq", clipToReplace, None)
# Counts number of project items in the project folder
numofItems = pym.objects.app.project.rootItem.children.numItems
print("")
print("Number of Project Items: ")
print(numofItems)
print("")
itemList = pym.objects.app.project.rootItem.children
# enumerates (splits the list up) for each item in the list
iLenumerated = enumerate(itemList)
for i in iLenumerated:
print("pymiere ID of Items ")
print(i)
print("Item Name: " + itemList[i[0]].name)
print("")
# safety check to make sure that the Sequencec that is to be measured is found and selected
i = 0
tempSeqVar = pym.objects.app.project.rootItem.children[0].name
while tempSeqVar != "Tempseq":
tempSeqVar = pym.objects.app.project.rootItem.children[i].name
tempSeqindex = i
i += 1
if i > numofItems:
print("No item found with name: Tempseq. Please ensure you have the correct file.")
quit()
#added wait for debugging the ticks issue, didn't resolve
#time.sleep(5)
print("Tempseq index:")
print(tempSeqindex)
print("")
tempSeqEndticks = pym.objects.app.project.sequences[tempSeqindex].end
print("Tempseq in Ticks:")
print(tempSeqEndticks)
print("")
tickPS = 254016000000
# ISSUE IS WHEN TRACEBACK ERROR WITH .seconds IS IN TICK VALUE COMES BACK CORRECTLY. WHEN IT THE MATH IS CORRECT THE VALUE
# FOR TICKS OF TEMPSEQ COMES BACK AS 3 MINUTES INSTEAD OF 11 SECONDS
#UNCOMMENTING BELOW WILL SHOW CORRECT VALUE FOR temSeqEndticks
#tempSeqEndSeconds = tempSeqEndticks.seconds
print("Tempseq in Seconds:")
# print(tempSeqEndSeconds)
I fixed the function setInterpolationTypeAtKey()
in /premiere_objects.py
I added more parameters, now i'ts working.
Premiere docs
def setInterpolationTypeAtKey(self, time, interpolationType, updateUI):
"""
:type time: Object
:type interpolationType: int
:type updateUI: bool
"""
self._check_type(interpolationType, int, 'arg "interpolationType" of function "ComponentParam.setInterpolationTypeAtKey"')
self._check_type(updateUI, bool, 'arg "updateUI" of function "ComponentParam.setInterpolationTypeAtKey"')
return self._eval_on_this_object("setInterpolationTypeAtKey({}, {}, {})".format(_format_object_to_es(time), _format_object_to_es(interpolationType), _format_object_to_es(updateUI)))
Thank you so much for creating this! I use it every day and it works flawlessly when I run it as a script.
When I try to create an exe, I get the following error when trying to run it:
File "pymiere\objects\start_vars.py", line 56, in app File "pymiere\core.py", line 469, in _eval_script_returning_object File "pymiere\core.py", line 77, in eval_script File "pymiere\core.py", line 30, in check_premiere_is_alive File "pymiere\exe_utils.py", line 36, in is_premiere_running File "pymiere\exe_utils.py", line 83, in exe_is_running File "pymiere\exe_utils.py", line 121, in _get_pids_from_name File "subprocess.py", line 411, in check_output File "subprocess.py", line 488, in run File "subprocess.py", line 753, in __init__ File "subprocess.py", line 1090, in _get_handles OSError: [WinError 6] The handle is invalid
I was wondering if there was a solution you can think of?
Function now:
def closeDocument(self):
return self._eval_on_this_object("closeDocument()")
Problem:
closeDocument() has a bool parameter that determines if the document will be saved at closeup, but pymiere's function doesn't account for it.
by executing closeDocument("false")
, premiere will quit from the document without saving it.
It would be great if you added a parameter like save:bool to pymiere's function:
def closeDocument(self, save=True):
return self._eval_on_this_object(f"closeDocument({save_document})")
then a check to convert from python bool to javascript bool in string
def closeDocument(self, save=True):
save_document = "true" if save == True else "false"
return self._eval_on_this_object(f"closeDocument({save_document})")
Traceback (most recent call last):
File "", line 1, in
File "D:\Pete's Data\OneDrive\Python Scripts\pymiere\demo.py", line 38, in
wrappers.edit_clip(clips[0], start_frame + increment, end_frame + increment, start_frame, end_frame, fps=fps)
File "D:\Pete's Data\OneDrive\Python Scripts\pymiere\pymiere\wrappers.py", line 117, in edit_clip
clip.end = time_from_seconds(end_on_timeline / fps)
File "D:\Pete's Data\OneDrive\Python Scripts\pymiere\pymiere\objects\premiere_objects.py", line 3796, in end
self._eval_on_this_object("end = {}".format(_format_object_to_es(end)))
File "D:\Pete's Data\OneDrive\Python Scripts\pymiere\pymiere\core.py", line 163, in _eval_on_this_object
result = _eval_script_returning_object(line)
File "D:\Pete's Data\OneDrive\Python Scripts\pymiere\pymiere\core.py", line 425, in _eval_script_returning_object
result = eval_script(script, decode_json=True)
File "D:\Pete's Data\OneDrive\Python Scripts\pymiere\pymiere\core.py", line 102, in eval_script
raise ExtendScriptError(response_decoded)
pymiere.core.ExtendScriptError:
TypeError at line 2 : Cannot set property end
1 try{
2 var tmp =
3 if(typeof tmp === 'object' && tmp !== null){
Line 38 seems to be the problem:
wrappers.edit_clip(clips[0], start_frame + increment, end_frame + increment, start_frame, end_frame, fps=fps)
I'm running Windows 10 64 bit, Premiere Pro v14.5.0 (Build 51) (Creative Cloud); Pymiere 1.0 and installed using latest version of ZXP installer.
<class 'pymiere.core.ExtendScriptError'>
Error at line 2 : Illegal Parameter type
1 try{
2 var tmp = $._pymiere['nHrZr6M6kW'].setPlayerPosition(11755648800000);
3 if(typeof tmp === 'object' && tmp !== null){ <traceback object at 0x0000025ED8A43C40>
Traceback (most recent call last):
File "d:\Pete's Data\OneDrive\Python Scripts\pymiere\demo_ui.py", line 22, in wrapper
result = func(self, *args, **kwargs)
File "d:\Pete's Data\OneDrive\Python Scripts\pymiere\demo_ui.py", line 145, in forward_func
self.active_sequence.setPlayerPosition(current_time.ticks)
File "d:\Pete's Data\OneDrive\Python Scripts\pymiere\pymiere\objects\premiere_objects.py", line 1095, in setPlayerPosition
self._eval_on_this_object("setPlayerPosition({})".format(_format_object_to_es(pos)))
File "d:\Pete's Data\OneDrive\Python Scripts\pymiere\pymiere\core.py", line 163, in _eval_on_this_object
result = _eval_script_returning_object(line)
File "d:\Pete's Data\OneDrive\Python Scripts\pymiere\pymiere\core.py", line 425, in _eval_script_returning_object
result = eval_script(script, decode_json=True)
File "d:\Pete's Data\OneDrive\Python Scripts\pymiere\pymiere\core.py", line 102, in eval_script
raise ExtendScriptError(response_decoded)
pymiere.core.ExtendScriptError:
Error at line 2 : Illegal Parameter type
1 try{
2 var tmp = $._pymiere['nHrZr6M6kW'].setPlayerPosition(11755648800000);
3 if(typeof tmp === 'object' && tmp !== null){
It seems the .bat
file was introduced to not start Premiere Pro as the child process of the Python process. However, I believe that is also possible from subprocess directly.
# pseudocode
import subprocess
CREATE_NEW_CONSOLE = 0x00000010
subprocess.Popen(call, creationflags=CREATE_NEW_CONSOLE)
For example also used here. That code can start applications just fine without it keeping parent connections with the Python process.
Would this be applicable and usable for pymiere
to start Premiere too?
Hi, I'm having an issue with the eval_script function from core.py. I can give it a string of extendscript code and that code is executed correctly, but when I try using a file pathstring that points to a jsx, file I get 'EvalScript error.' I'm not sure if it's a syntax error. I'm currently on Mac, but I had the same issue on windows.
my code : eval_script('/Users/myUserName/Desktop/stamp.jsx')
I also tried eval_script(r'/Users/myUserName/Desktop/stamp.jsx')
Has anyone else had any issues with this function? I seem to recall being able to do successfully give it file paths when I tested it a few months ago, but now I can't. is it a syntax error on my part? Does anyone else have this problem?
example:
project = pymiere.objects.app.project
r=project.activeSequence.videoTracks
print ( r[0].clips[0].name )
There will be garbled if the clip name have non English character
I noticed in demo_ui.py
the final argument (importAsNumberedStills
) is given as True
but the normal expected way of importing clips should IMHO be False
by default. It took me quite a while to work out what was going on and why my timeline was looking odd (missing the full video clips), and I fear other new users learning from the demo programs may find this confusing too.
Could I suggest simply changing Line 233 to:
pymiere.objects.app.project.importFiles([file_to_import], True, root_bin, False)
I don't recognise the file shown in the Premiere popup message below... pretty sure it's not an image to do with the sample project I have open, and curious to see file extension jpeg not jpg as well...
After I close the popup I get the following:
d:\Pete's Data\OneDrive\Python Scripts\pymiere\demo_ui.py:23: DeprecationWarning: an integer is required (got type sip.voidptr). Implicit conversion to integers using
int is deprecated, and may be removed in a future version of Python.
win32gui.SetForegroundWindow(self.ui_id)
<class 'pywintypes.error'> (0, 'SetForegroundWindow', 'No error message is available') <traceback object at 0x0000023EBF2546C0>
Traceback (most recent call last):
File "d:\Pete's Data\OneDrive\Python Scripts\pymiere\demo_ui.py", line 23, in wrapper
win32gui.SetForegroundWindow(self.ui_id)
pywintypes.error: (0, 'SetForegroundWindow', 'No error message is available')
Following the Motion Graphics Example for adding text I get the following error:
>>> mgt_clip.getMGTComponent()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python3.7/site-packages/pymiere/objects/premiere_objects.py", line 5773, in getMGTComponent
return Component(**self._eval_on_this_object("getMGTComponent()"))
TypeError: type object argument after ** must be a mapping, not NoneType
Run the check_output
of subprocess with a hidden window to avoid the extra cmd
popup.
We can pass the CREATE_NO_WINDOW
bits for creation flags:
CREATE_NO_WINDOW = 0x08000000
check_output(call, creationflags=CREATE_NO_WINDOW)
See also here.
Is there any reason in this case not to do so?
I quickly added it to the subprocess calls in pymiere.exe_utils
and it seemed to work. Tested in Python 2.7 (sorry, old Python I had laying around).
As title, thank you
Hi,
This library has been great! I am just having problems rendering a list of sequences I want to render from a render folder. I basically create a list, then for each chosen sequence, I make it an activeSequence and then attempt to render that active sequence however I am crashing each time on the exportAsMediaDirect() function for Premiere Pro 2021 for osx 11.3.1. Is there any way the list of chosen sequences from the render folder could be sent to adobe media encoder for render? See code below:
def render_seq(render_preset_path):
project = pymiere.objects.app.project
all_children = project.rootItem.children
seq = project.sequences
print(seq)
seq_list=[]
for s in seq:
print(s.name)
seq_list.append(s)
print(seq_list)
for a in all_children:
if a.name == 'RENDER_SEQUENCES':
print(a.name)
for r in a.children:
print(r.name)
for item in seq_list:
if item.name == r.name:
print(item)
print(item.name)
project.openSequence(sequenceID=item.sequenceID)
print(project.activeSequence)
fileName = r.name #.replace('.mp4','')
# print(sequence)
os.chdir(SOCIAL_DIR)
try:
os.mkdir(SOCIAL_FOLDER_DATE)
print('Making Directory')
RENDER_DIR = SOCIAL_DIR + SOCIAL_FOLDER_DATE + '/'
print(RENDER_DIR)
render_file_path = RENDER_DIR + fileName
print(render_file_path)
result = project.activeSequence.exportAsMediaDirect(render_file_path, render_preset_path, pymiere.objects.app.encoder.ENCODE_IN_TO_OUT)
print(result)
print(result.strip() == "No result")
except:
print('Directory already made')
RENDER_DIR = SOCIAL_DIR + SOCIAL_FOLDER_DATE + '/'
print(RENDER_DIR)
render_file_path = RENDER_DIR + fileName
print(render_file_path)
result = project.activeSequence.exportAsMediaDirect(render_file_path, render_preset_path, pymiere.objects.app.encoder.ENCODE_IN_TO_OUT)
print(result)
print(result.strip() == "No result")
I notice "playblast" is the default filename for demo_ui.py import/export/save/load.
A "nice to have" would be for the actual path/filename of the open project to be picked up dynamically, rather than hard coded as it is currently i.e. default_folder = r"C:\Users\Quentin\Desktop\temp\playblast"
I'm a recent convert to pathlib
for file and directory operations, so perhaps overwrite default_folder
after confirming there is an open project with something like:
from pathlib import Path
default_folder = Path(pymiere.objects.app.project.path).parent
Also, got issue with the get_installed_software_info() function inside exe_utils, the function returned a bad path or incomplete
so in get_installed_software_info() function I changed:
exe_path = last_version_info["InstallLocation"]
into:
exe_path = last_version_info["InstallLocation"]+'\' +last_version_info["DisplayName"]
Cause in Premiere Pro 14.x the path returned in "InstallLocation" is incomplete
Originally posted by @bryhimself in #3 (comment)
I'm trying to implement Project.importSequences() as described in the Premiere Pro Scripting Guide
Here is what I did:
`sequenceIDs = ["2714b58d-10a0-4801-9646-8a4f6f1e2a98"]
path = r"E:\path\untitled.prproj"
pymiere.objects.app.project.importSequences(path, sequenceIDs)
`
But I get this error:
TypeError: importSequences() takes 2 positional arguments but 3 were given
Any help is appreciated. Thank you!
I have installed pymiere_link
and I can see "Pymiere Link" in the extension of Window menu.
But when I run "print(pymiere.objects.app.isDocumentOpen())" in python shell, it shows these error:
Traceback (most recent call last):
File "D:\Python36\lib\site-packages\pymiere\core.py", line 39, in check_premiere_is_alive
response = requests.get(PANEL_URL)
File "D:\Python36\lib\site-packages\requests\api.py", line 76, in get
return request('get', url, params=params, **kwargs)
File "D:\Python36\lib\site-packages\requests\api.py", line 61, in request
return session.request(method=method, url=url, **kwargs)
File "D:\Python36\lib\site-packages\requests\sessions.py", line 542, in request
resp = self.send(prep, **send_kwargs)
File "D:\Python36\lib\site-packages\requests\sessions.py", line 655, in send
r = adapter.send(request, **kwargs)
File "D:\Python36\lib\site-packages\requests\adapters.py", line 516, in send
raise ConnectionError(e, request=request)
requests.exceptions.ConnectionError: HTTPConnectionPool(host='127.0.0.1', port=3000): Max retries exceeded with url: / (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x000001B824B38828>: Failed to establish a new connection: [WinError 10061] ',))
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "D:\Python36\lib\site-packages\pymiere\objects\start_vars.py", line 56, in app
return Application(**_eval_script_returning_object('app', as_kwargs=True))
File "D:\Python36\lib\site-packages\pymiere\core.py", line 469, in _eval_script_returning_object
result = eval_script(script, decode_json=True)
File "D:\Python36\lib\site-packages\pymiere\core.py", line 77, in eval_script
check_premiere_is_alive(crash=True)
File "D:\Python36\lib\site-packages\pymiere\core.py", line 43, in check_premiere_is_alive
raise IOError(msg)
OSError: No connection could be established to Premiere Pro, check that the pymiere pannel is loaded
The version of Premiere Pro is 14.4.0
Os: Windows 10
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.