Notice: Function _load_textdomain_just_in_time was called incorrectly. Translation loading for the cycloneslider domain was triggered too early. This is usually an indicator for some code in the plugin or theme running too early. Translations should be loaded at the init action or later. Please see Debugging in WordPress for more information. (This message was added in version 6.7.0.) in /home2/wacggq0abkde/public_html/wp-includes/functions.php on line 6114

Notice: Function _load_textdomain_just_in_time was called incorrectly. Translation loading for the cartel domain was triggered too early. This is usually an indicator for some code in the plugin or theme running too early. Translations should be loaded at the init action or later. Please see Debugging in WordPress for more information. (This message was added in version 6.7.0.) in /home2/wacggq0abkde/public_html/wp-includes/functions.php on line 6114

Warning: Cannot modify header information - headers already sent by (output started at /home2/wacggq0abkde/public_html/wp-includes/functions.php:6114) in /home2/wacggq0abkde/public_html/wp-includes/rest-api/class-wp-rest-server.php on line 1893

Warning: Cannot modify header information - headers already sent by (output started at /home2/wacggq0abkde/public_html/wp-includes/functions.php:6114) in /home2/wacggq0abkde/public_html/wp-includes/rest-api/class-wp-rest-server.php on line 1893

Warning: Cannot modify header information - headers already sent by (output started at /home2/wacggq0abkde/public_html/wp-includes/functions.php:6114) in /home2/wacggq0abkde/public_html/wp-includes/rest-api/class-wp-rest-server.php on line 1893

Warning: Cannot modify header information - headers already sent by (output started at /home2/wacggq0abkde/public_html/wp-includes/functions.php:6114) in /home2/wacggq0abkde/public_html/wp-includes/rest-api/class-wp-rest-server.php on line 1893

Warning: Cannot modify header information - headers already sent by (output started at /home2/wacggq0abkde/public_html/wp-includes/functions.php:6114) in /home2/wacggq0abkde/public_html/wp-includes/rest-api/class-wp-rest-server.php on line 1893

Warning: Cannot modify header information - headers already sent by (output started at /home2/wacggq0abkde/public_html/wp-includes/functions.php:6114) in /home2/wacggq0abkde/public_html/wp-includes/rest-api/class-wp-rest-server.php on line 1893

Warning: Cannot modify header information - headers already sent by (output started at /home2/wacggq0abkde/public_html/wp-includes/functions.php:6114) in /home2/wacggq0abkde/public_html/wp-includes/rest-api/class-wp-rest-server.php on line 1893

Warning: Cannot modify header information - headers already sent by (output started at /home2/wacggq0abkde/public_html/wp-includes/functions.php:6114) in /home2/wacggq0abkde/public_html/wp-includes/rest-api/class-wp-rest-server.php on line 1893
{"id":2209,"date":"2017-11-29T04:50:01","date_gmt":"2017-11-29T03:50:01","guid":{"rendered":"http:\/\/boris-mc.com\/?p=2209"},"modified":"2017-11-29T14:29:15","modified_gmt":"2017-11-29T13:29:15","slug":"muzzle-flash-my-friend","status":"publish","type":"post","link":"https:\/\/boris-mc.com\/?p=2209","title":{"rendered":"MUZZLE FLASH, MY FRIEND"},"content":{"rendered":"

 <\/p>\n

\n
\n

tl;dr:\u00a0<\/strong>Locate and sort out your muzzle flashes and other stock footage elements quick and easy.<\/p>\n<\/div><\/div>\n

\n
\n
Face it, digital comping is not only about putting together the pieces of a Transformer, bringing back to life a roaring T-Rex, or giving to a lightsaber the right glowy touch… often it\u00b4s also about tackling some tedious, repetitive and highly time-consuming tasks that on top of that usually remain unnoticed and unaccounted for.
\n
<\/div><\/div>\n
\n
Thankfully, there is Python, and here is where being able to write some wise code really comes in handy :).<\/div>\n<\/div>\n
<\/div><\/div>\n
1 – The challenge<\/strong><\/div>\n
<\/div><\/div>\n
\n
Consider this, you have been given the task of processing a library of stock footage in search of nice muzzle-flashes to use on a given show.<\/strong> Imagine there are around 100-150, 4k clips that you have to play and examine (either in Nuke or Nuke Studio, or Hiero or any other player) to eventually locate the frame or frames where the muzzles flashes are happening on.<\/div>\n
\n
<\/div><\/div>\n
\u00a0As you probably know, those footage are shot in the dark, so usually you would be watching at noisy black footage up until the moment that, voila, a muzzle flash shows up.<\/div>\n<\/div>\n<\/div>\n
<\/div><\/div>\n
\n

\"\"<\/a><\/p>\n

<\/div><\/div>\n
2 – Approach A (be -very- patient)<\/strong><\/div>\n<\/div>\n
\n
<\/div><\/div>\n

Ok, once one of those guys appear, you would ideally want to lock down the frame<\/strong> where this is happening. For such a thing, you can use a FrameHold Node in Nuke, a timeline marker in After Effects or just take a note on a notebook, to mention a few options. You would continue the same way up until you would have located all the muzzle flashes.<\/p>\n<\/div>\n

\n
<\/div><\/div>\n<\/div>\n
\n
<\/div>\n

I leave you to reckon with how long any of these approaches would take…<\/p>\n<\/div>\n

<\/div><\/div>\n
3 – Aproach B (go -moderately- smart)<\/strong><\/div>\n
\n
<\/div><\/div>\n

Let\u00b4s get this straight. What if you could, just by clicking on a button, automatically build a contact sheet displaying all the different muzzle flash elements there are<\/strong>, therefore enabling you to easily check out the different types, camera angles and so on, and then, once you have built that contact-sheet up, go to any of the individual files and extract<\/strong> all the muzzle flashes in that file?<\/p>\n<\/div>\n

\n
<\/div><\/div>\n

Well, that<\/strong>, along with other fancy add-ons, is exactly what this script does.<\/strong><\/p>\n<\/div>\n

\n
<\/div><\/div>\n
4 – How it does it.<\/strong><\/div>\n
\n
<\/div><\/div>\n

Honestly, this is a fairly simple code. Just a few functions, a class definition to help build a nuke Python Panel, and some global variables<\/strong>. In the form of “pseudo code”, here is the thing:<\/p>\n<\/div>\n

\n
<\/div><\/div>\n
1 – analyze:<\/strong> all (selected) nodes, provided they are Read Nodes, to automatically detect, off of luminance intensities, on which frame or frames a muzzle flash is taking place.<\/div>\n
\n
\n
<\/div><\/div>\n<\/div>\n<\/div>\n
\"\"<\/a><\/div>\n
\n
<\/div><\/div>\n<\/div>\n

2 – detect:<\/strong> depending on the so-called “build mode” (I\u00b4ll go over this later), it either drops a Framehold<\/strong> node each time a muzzle flash is detected or just one for the muzzle flash that has the maximum luminance intensity<\/strong>, thus locking down either all of them, or just the brightest one.<\/p>\n<\/div>\n

\n
\n
\n
<\/div><\/div>\n
\"\"<\/a><\/div>\n<\/div>\n
<\/div>\n<\/div>\n

3 – build:<\/strong> with all detected muzzle flashes locked down with a Framehold node, the script then builds a contact sheet with all of them<\/strong>, and then drops a text node connected to each of the files displaying its name on the screen, automatically.<\/p>\n<\/div>\n

\n
<\/div><\/div>\n
\"\"<\/a><\/div>\n
\n
\n
<\/div><\/div>\n<\/div>\n<\/div>\n
\u00a0And as an image is often worth more than a thousand words, this is how it would look like.<\/div>\n
\n
<\/div><\/div>\n
\n
<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n
\n
\"\"<\/a><\/div>\n
<\/div><\/div>\n
\n

5 – How to use it.<\/strong><\/p>\n

<\/div><\/div>\n
Ok, with all that being said, now we should basically place the code where it can be reached, call its main function and then deal with a few options on a Nuke Panel<\/strong>. Let\u00b4s see how this works.<\/div>\n
\n
<\/div><\/div>\n
\n

1 – distribute the code.<\/strong> As we know, when it comes to Python Scripts, we need to be able to import them in Nuke with the command “import module_name”<\/span><\/strong>. We can do this either by defining the PYTHON_PATH\u00a0<\/strong>environment <\/strong>variable or simply by adding within the init.py<\/strong> file the folder structure where we will place our Gizmos, Plugins, Python Scripts and so on, using the command “nuke.pluginAddPath”<\/strong><\/span>. If none of this options sound familiar to you, then just drop the script on to the user\u00b4s .nuke<\/strong> folder and hope for the best.<\/p>\n

<\/div><\/div>\n
2 – run the tool.<\/strong> Open the Nuke\u00b4s Script Editor and type “import module_name”<\/strong> <\/span>and then type “module_name.main_function()”<\/strong><\/span>… Other than this basic way of importing a module and calling a module\u00b4s function from Nuke\u00b4s Script Editor, you can also implement the code on a Gizmo\u00b4s Custom Python Script Button, or create a Nuke menu from where to call your Python Scripts, or even set up a hotkey to easily access to the tool.<\/strong> I\u00b4ll leave the implementation part to you.<\/div>\n
\n
<\/div><\/div>\n
\n
3 – deal with a few options.<\/strong> Right after running the tool, a pop-up Nuke Panel will appear displaying a few options.<\/div>\n
\n
<\/div><\/div>\n
\n
\"\"<\/a><\/div>\n
<\/div><\/div>\n
<\/div>\n<\/div>\n
– time range:<\/strong> classic “input\/global\/custom” pulldown menu. Enables you to analyze your files according to any of these options.
<\/div><\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n

\u00a0– build mode:<\/strong> extract will get all the muzzle flashes in all selected clips. Build will get one muzzle flash per clip, exactly that with the maximum brightness.<\/p>\n

<\/div>\n
As a rule of thumb, you probably want to run the tool with the “build”<\/strong> option first and then, once u have built a contact-sheet with a muzzle flash per clip, select a clip from which you would like to extract all the muzzle-flash instances and run the tool in “extract”<\/strong> mode.<\/div>\n<\/div>\n<\/div>\n
\n
\n
<\/div><\/div>\n<\/div>\n
\n
\n

important<\/strong>: If you find this usefull, it\u00b4s always better to create a Nuke menu from where to call the function.<\/p>\n<\/div>\n

<\/div><\/div><\/div>\n
\n<\/div>\n
<\/div>\n