AWS Thinkbox Discussion Forums

large input image cropped to three outputs

Hey there,

I wonder if you can have a highres image (almost three times 1080) as input image and split it into three seperate HD outputs.
I tried the crop function but I already fail to use it correctly and hope you can help me out (:.
This is my idea:

[code]
firstframePath = ReplaceFilenameHashesWithNumber(params[‘inFile’],params[‘startFrame’])

Create left, center, right crops

firstFrame = Draft.Image.ReadFromFile(firstframePath)
firstFrameL = firstFrame.Crop( 0, 0, 1919, 1079)
firstFrameC = firstFrame.Crop( 1649, 0, 3569, 1079)
firstFrameR = firstFrame.Crop( 3299, 0, 5219, 1079)

width = 1920
height = 1080

#Set up variables for video encoding
fps = 50
kBitRate = 18990
codec = “H264”

videoEncoderL = Draft.VideoEncoder( outBase + “LEFT” + outExt, fps, width, height, kBitRate, codec )
videoEncoderC = Draft.VideoEncoder( outBase + “CENTER” + outExt, fps, width, height, kBitRate, codec )
videoEncoderR = Draft.VideoEncoder( outBase + “RIGHT” + outExt, fps, width, height, kBitRate, codec ) [/code]

What I don’t understand is how the encoder gets information about the processed input. Is it possible even to create three variations of the input and encode them seperately in one .py (like frameFirstL.VideoEncoder)?

Another completely different issue is the audio support. I wonder if there will be a possibility to choose an audio file on the job submission dialog. I have to admit that I didn’t do any research concerning audio and just saw one post where it was “hard coded” in the video encoder. I mean, it should be possible to add a file browser to the submission dialog and get the string value inside the .py or am I wrong? :smiley:

I appreciate any help or suggestions! Thanks.

Best regards,
Dziga

Hi Dziga,

Crop modifies the image being cropped, so, instead of assigning the return value (which is nothing) to the other variable, you want to do a deep copy and then crop the copy.

[code]from copy import deepcopy

firstframePath = ReplaceFilenameHashesWithNumber(params[‘inFile’],params[‘startFrame’])

Create left, center, right crops

firstFrame = Draft.Image.ReadFromFile(firstframePath)
firstFrameL = deepcopy(firstFrame)
firstFrameL.Crop( 0, 0, 1919, 1079)
firstFrameC = deepcopy(firstFrame)
firstFrameC.Crop( 1649, 0, 3569, 1079)
firstFrameR = firstFrame # this is a shallow copy, but we not longer need the original frame, so it’s okay
firstFrameR.Crop( 3299, 0, 5219, 1079)

width = 1920
height = 1080

#Set up variables for video encoding
fps = 50
kBitRate = 18990
codec = “H264”

videoEncoderL = Draft.VideoEncoder( outBase + “LEFT” + outExt, fps, width, height, kBitRate, codec )
videoEncoderC = Draft.VideoEncoder( outBase + “CENTER” + outExt, fps, width, height, kBitRate, codec )
videoEncoderR = Draft.VideoEncoder( outBase + “RIGHT” + outExt, fps, width, height, kBitRate, codec )[/code]

Your next question was how the encoder gets the information about the processed input. We have to explicitly give the image to the encoder using EncodeNextFrame:

videoEncoderL.EncodeNextFrame( firstFrameL ) videoEncoderC.EncodeNextFrame( firstFrameC ) videoEncoderR.EncodeNextFrame( firstFrameR )

Your third question is audio support. Deadline currently doesn’t have a separate input field for audio, but you can always add additional parameters using the “Additional Args” field. If you were to add something like audio=path/to/audiofile in the additional args field, then you could add expectedTypes['audio'] = '<string>' to the expected types dictionary, and access it just like you do the other parameters. (Where “expectedTypes” is the first argument you’ll be sending to ParseCommandLine, of course.) This doesn’t give you a file browser, but, assuming your audio file is in the same directory as your images, you could simply copy that part from the input file field, and substitute in the correct audio name.

I think the reason there is only one input field is that that field could be used for images/frames, movies, audio, or whatever you want… and if you want more than one input, you use the Additional Args field where you can add as many as you want, with whatever names you want. I’ll add a wishlist card for an audio input field, and link to this thread.

Cheers,
Andrea

Wow, thank you Andrea. That works like a charm. Another step for me towards getting to know what happens under the hood of Draft :smiley:

Unfortunately, I don’t find the right spot for the expectedType arguments. I tried several variations after adding audio = “L:\musikarchiv\Wassermusik\1-02 Ein Zarter Weißer Unterleib 02.mp3” to the additional args field.

  1. try was to create a seperate dictionary before the params = dict() part

[code]expectedTypes = dict()

expectedTypes[‘audio’] = ‘’

expectedTypes = ParseCommandLine ( expectedTypes, sys.argv )[/code]

Then I tried to create a variable audio = expectedTypes[‘audio’] and add it here:

videoEncoderL = Draft.VideoEncoder( outBase + "_LEFT_" + outExt, fps, width, height, kBitRate, codec, audio )
  1. try was to leave out the creation of the variable and directly add expectedTypes[‘audio’] to the encoder

  2. try was to add audio in the params dictionary (I know you told me to add it to expectedTypes) with params[‘audio’] = ‘’

I get an error in Deadline and can immediately see that my audio path isn’t returned as the value.

0: STDOUT: Command line args: 0: STDOUT: username=om20 0: STDOUT: entity=DRAFT_PY_TEST_pc.aep - Comp 1 0: STDOUT: version= 0: STDOUT: inFile=V:\_versuchslabor\pipeline_check_rendertest\draft_ae_crop\out\Comp 1_#####.dpx 0: STDOUT: outFile=V:\_versuchslabor\pipeline_check_rendertest\draft_ae_crop\out\Draft\Comp 1.mov 0: STDOUT: startFrame=0 0: STDOUT: endFrame=5 0: STDOUT: frameList=0-5 0: STDOUT: deadlineJobID=002_097_999_1ad2582f 0: STDOUT: audio

0: STDOUT: StandardError: Bad argument: audio. Should be in the form ‘arg=value’.

I guess, I need some more help on where to read the string in my .py. I attach the complete .py. Thank you!

Take care,
Dziga
OM_uv_tmc_crop_50p.zip (1.55 KB)

As the audio file I used before wasn’t the safest with all the spaces in between I tried a different now.

For testing purposes I added

audio = “v:_versuchslabor\pipeline_check_rendertest\draft_ae_crop\test.mp3”

to my .py and append audio to the encoder.

Deadline changes the path to “v:_versuchslabor\pipeline_check_rendertest\draft_ae_crop est.mp3”, how is that? is \t a code that transforms into ‘space’ even in a string?

Yes, \t translates to a whitespace character, in particular, a tab. Normally, \ acts as an “escape” character, so that the combination of \ and the next character are used to represent special characters: \n is a newline, \t is tab, and so on. (The fact that Python sometimes leaves the escape character as a backslash just confuses the issue.) You can fix this problem by escaping the backslash: \ is how to represent a single \ character, and so your filename would become:
audio = “v:\_versuchslabor\pipeline_check_rendertest\draft_ae_crop\test.mp3”

An alternate method is to use an r before the string, as in:
audio = r"v:_versuchslabor\pipeline_check_rendertest\draft_ae_crop\test.mp3"
which specifies to use the string in “raw” mode (don’t process the backslashes). However, you can’t have the raw string end with a backslash (if, for example, you want to specify a path name), because " (or ') are still escape characters, even in raw mode. For more on escape characters and raw mode, see:
http://docs.python.org/reference/lexical_analysis.html#string-literals

Next, your question about expectedTypes/params: I think the reason you were confused by what I wrote is that you are reusing the dictionary variable when you call ParseCommandLine. I was using expectedTypes/params as:

expectedTypes['audio'] = '<string>'
expectedTypes['username'] = '<string>'
expectedTypes['entity'] = '<string>'
expectedTypes['version'] = '<string>'
expectedTypes['startFrame'] = '<int>'
expectedTypes['endFrame'] = '<int>'
expectedTypes['frameList'] = '<string>'
expectedTypes['outFile'] = '<string>'
expectedTypes['inFile'] = '<string>'

params = ParseCommandLine( expectedTypes, sys.argv )

Whereas you had params (or expectedTypes) both as an argument and saving the return value… which works, but disguises the fact that the dictionary stored in params after the method call is different from the one before the method call. It’s fine, and works, but that’s the difference. After the call to ParseCommandLine, you should be able to access your audio filename using params[‘audio’].

After doing a bit of testing and talking to a Deadline guy, the main reason you were getting an error using the additional args is due to the fact that you had spaces between audio, the equal sign, and the filename. (The spaces cause Deadline/Draft to think that the three pieces are separate arguments.) You need :
audio=“L:\musikarchiv\Wassermusik\1-02 Ein Zarter Weißer Unterleib 02.mp3”
(No spaces, besides those in the file name.) If that doesn’t work, try:
audio=“L:\musikarchiv\Wassermusik\1-02 Ein Zarter Weißer Unterleib 02.mp3”

Let me know if that works for you.

Cheers,
Andrea

Thank you Andrea,

audio works now. I was quite confused indeed :smiley:

Glad to hear! (That it was working, not that you were confused… I hope the confusion is gone now!)

Cheers,
Andrea

Privacy | Site terms | Cookie preferences