qmasingarbe / pymiere

Python for Premiere pro
GNU General Public License v3.0
353 stars 46 forks source link

outputPath not passed to Adobe Media Encoder #46

Closed edmundsj closed 2 years ago

edmundsj commented 2 years ago

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.

qmasingarbe commented 2 years ago

I took a look at your problem and it seems to come from the export preset file. I had the problem when using an .epr file coming from the PremierePro install folder, but using an .epr file from MediaEncoder's install folder fixed it (this one for example C:\Program Files\Adobe\Adobe Media Encoder CC 2017\MediaIO\systempresets\4E49434B_48323634\01 - Match Source - High bitrate.epr ) It's not an outputPath problem as you can see it appear for a split second in the AME window. By the way this parameter is named outputFilePath .

edmundsj commented 2 years ago

Right you are! Using the .epr file from Media Encoder fixed the issue and it is now exporting as desired. Thanks!

qmasingarbe commented 2 years ago

Nice! I fixed the documentation to be a path in Encoder's directory