{"id":322,"date":"2007-12-13T20:58:02","date_gmt":"2007-12-14T04:58:02","guid":{"rendered":"http:\/\/zachfine.com\/blog\/2007\/12\/13\/command-line-batch-processing-of-clips-with-shake\/"},"modified":"2007-12-13T21:10:04","modified_gmt":"2007-12-14T05:10:04","slug":"command-line-batch-processing-of-clips-with-shake","status":"publish","type":"post","link":"https:\/\/zachfine.com\/blog\/2007\/12\/13\/command-line-batch-processing-of-clips-with-shake\/","title":{"rendered":"command-line batch processing of clips with Shake"},"content":{"rendered":"<p>This post is going to be very geeky, and is probably only relevant for those of you who do any film editing or VFX work.<\/p>\n<p>\nToday I needed to process a few clips with <a href=\"http:\/\/www.apple.com\/shake\/\">Shake<\/a> to convert their colorspace from Panalog to linear. Rather than just do a bunch of pointing and clicking in the Shake gui to process each clip, I figured it might be worthwhile to spend a little bit of time scripting now to save a lot of time and finger joint wear and tear later.<\/p>\n<p>\nI wanted my script to process any clip thrown at it, and to render out the result as a 1920&#215;1080 Apple Prores 422 QuickTime file at 23.98fps. The script would append &#8220;_PL&#8221; to the filename before the extension to indicate that a panalog conversion had been done, so if the original file was A38.mov, the resulting file after running the command &#8220;myscript.sh A38.mov&#8221; would be &#8220;A38_PL.mov&#8221;.<\/p>\n<p>\nI typed &#8220;<tt>shake -help |& less<\/tt>&#8221; to browse through Shake&#8217;s available command line arguments, and to find out how to address the &#8220;<a href=\"http:\/\/www.doubleultra.com\/?page_id=33\">panalog4lin<\/a>&#8221; macro I would be using to do the conversion.<\/p>\n<p>\nThere were two problems that made this a not-so-straightforward task. The first was that there is no way that I can find to tell Shake what kind of QuickTime file you&#8217;d like it to write (most professional users likely have it write out individual Cineon or DPX files for each frame, which would have been a simpler solution but didn&#8217;t fit our workflow). I found in the manual how to set Shake&#8217;s default QuickTime format, and set it to ProRes 422 1920&#215;1080 in a .h file. The second problem was that Shake only renders out one frame by default unless you tell it the time range you&#8217;d like it to render. My script would have to know the duration of a clip to process all of its frames. Luckily I could use Shake&#8217;s &#8220;-info&#8221; flag to determine the duration of a clip.<\/p>\n<p>\nHere&#8217;s the script (looks pretty simple eh?):<\/p>\n<p>\n<tt><\/p>\n<pre>\r\n#!\/bin\/tcsh\r\nset duration = `shake \"$1\" -info |& grep \"Duration\" | cut -d \":\" -f 3`\r\nshake -fi \"$1\" -t $duration -panalog4lin 1 1 -fps 23.98 -fo \"$1:r_PL.mov\"\r\n<\/pre>\n<p><\/tt><\/p>\n<p>\nI wanted to apply the conversion to all of the clips whose name contained the string &#8220;AT&#8221;, so I typed the following at the tcsh prompt:<\/p>\n<p>\n<tt><\/p>\n<pre>\r\n% foreach foo (*AT*)\r\nforeach? echo \"processing $foo\"\r\nforeach? myscript.sh \"$foo\"\r\nforeach? end\r\n<\/pre>\n<p><\/tt><\/p>\n<p>\nI walked away, ates some food, came back, and a set of clips that had been converted to linear space were sitting there waiting for me. Excellent!<\/p>\n<p><!-- technorati tags start --><\/p>\n<p style=\"text-align:right;font-size:10px;\">Technorati Tags: <a href=\"http:\/\/www.technorati.com\/tag\/Apple\" rel=\"tag\">Apple<\/a>, <a href=\"http:\/\/www.technorati.com\/tag\/Macintosh\" rel=\"tag\">Macintosh<\/a>, <a href=\"http:\/\/www.technorati.com\/tag\/OS X\" rel=\"tag\">OS X<\/a>, <a href=\"http:\/\/www.technorati.com\/tag\/Panavision Genesis\" rel=\"tag\">Panavision Genesis<\/a>,  <a href=\"http:\/\/www.technorati.com\/tag\/software\" rel=\"tag\">software<\/a>, <a href=\"http:\/\/www.technorati.com\/tag\/unix\" rel=\"tag\">unix<\/a>, <a href=\"http:\/\/www.technorati.com\/tag\/vfx\" rel=\"tag\">vfx<\/a><\/p>\n<p><!-- technorati tags end --><\/p>\n","protected":false},"excerpt":{"rendered":"<p>This post is going to be very geeky, and is probably only relevant for those of you who do any film editing or VFX work. Today I needed to process a few clips with Shake to convert their colorspace from Panalog to linear. Rather than just do a bunch of pointing and clicking in the [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_hide_featured_image":false,"_jetpack_featured_image_duplicate_dismissed":0,"_jetpack_feature_clip_id":0,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2},"jetpack_post_was_ever_published":false},"categories":[14,28,13,3],"tags":[],"class_list":["post-322","post","type-post","status-publish","format-standard","hentry","category-apple","category-filmmaking","category-geeky","category-video"],"jetpack_publicize_connections":[],"jetpack_shortlink":"https:\/\/wp.me\/ptNpF-5c","jetpack_sharing_enabled":true,"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/zachfine.com\/blog\/wp-json\/wp\/v2\/posts\/322","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/zachfine.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/zachfine.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/zachfine.com\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/zachfine.com\/blog\/wp-json\/wp\/v2\/comments?post=322"}],"version-history":[{"count":0,"href":"https:\/\/zachfine.com\/blog\/wp-json\/wp\/v2\/posts\/322\/revisions"}],"wp:attachment":[{"href":"https:\/\/zachfine.com\/blog\/wp-json\/wp\/v2\/media?parent=322"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/zachfine.com\/blog\/wp-json\/wp\/v2\/categories?post=322"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/zachfine.com\/blog\/wp-json\/wp\/v2\/tags?post=322"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}