Movie File In TOP

From TouchDesigner 099 Wiki

Summary

The Movie File In TOP loads movies, still images, or a sequence of still images into TOPs. It will read images in .jpg, .gif, .tif, or .bmp format. It will read movies in QuickTime's .mov format, .mp4, .mpg, .mpeg, .avi, .wmv, .dpx, Cineform and Hap Q formats (including Hap Q with Alpha). It also supports some .swf and .flv Flash files as well as DXT1, 3, and 5 compressed .DDS files. Images and movies can also be fetched from the web by using http:// to specify a URL.

For a complete list, see File Types.

Examine the state of a Movie File In TOP by attaching an Info CHOP to it (see below on Info CHOP). This will show static info like movie length, resolution, frames per second, and whether there is audio in the file. It also shows dynamic information like movie open status, current frame, readahead frames and queue size, dropped frame count, CPU decode time and GPU upload time.

See also Cineform, Hap, Movie File Out TOP, Movie Playback

PythonIcon.png moviefileinTOP_Class

Parameters - Play Page

File file - The path and name of the image or movie file to load. Image and movie formats are those found in File Types. You can specify files on the internet using http:// ...

To treat a folder of images as if they are one movie, specify the folder containing the images instead of a filename. All the files be the same resolution. It will treat all stills/movies in that folder as if each is a frame in one movie. The order of the images is the alphanumeric. By default the first image has an index of 0, second is 1, etc, regardless of their file names. Overriding the sample rate on the Trim parameter page will let you playback the image sequence at any frame rate.

Using an info.xml file in the directory containing a sequence of images allows you to specify the frames per second and an audio file to be used with the sequence of images. Example xml file:

 <?xml version="1.0" encoding="ISO-8859-1" standalone="yes" ?>
 <Settings>
     <attributes fps="30.0" />
     <audio filename="audio.wav" />
 </Settings>

URLs can be used to fetch images and movies. The image or movie is downloaded to the user's Derivative temp directory and is read into the Movie File In TOP.

Reload reload - Change from 0 to 1 to force the image to reload, useful when the file changes or did not exist at first.

Play Mode playmode - Specifies the method used to play the movie, there are 3 options.

  • Locked to Timeline locked - This mode locks the movie position to the timeline. Scrubbing or jumping in the timeline will change the movie position accordingly. The parameters Play, Reset, Speed, and Index are disabled in this mode since the timeline is directly tied to movie position.
  • Specify Index specify - This mode allows the user to specify a particular position in the movie using the Index parameter below. Use this mode for random access to any location in the movie.
  • Sequential sequential - This mode continually plays regardless of the timeline position (the Index parameter is disabled). Reset and Speed parameters below are enabled to allow some control.

Play play - Movie plays when 1, movie stops when 0.

Speed speed - This is a speed multiplier which only works when Play Mode is Sequential. A value of 1 is the default playback speed. A value of 2 is double speed, 0.5 is half speed and so on. Negative values will play the movie backwards.

Cue cue - jumps to Cue Point when set to 1. Only available when Play Mode is Sequential.

Cue Point cuepoint - Set any index in the movie as a point to jump to.

Cue Behavior cuebehavior - customize the Cue parameter's behavior.

  • On Release, Play Next Frame - When releasing the Cue parameter, immediately play the next frame.
  • On Release, Repeat Cued Frame - When releasing the Cue parameter, first play the cued frame before continuing to play the next frame.

Index index - This parameter explicitly sets the movie position when Play Mode is set to Specify Index. The units menu on the right lets you specify the index in the following units: Index, Frames, Seconds, and Fraction (percentage). For example, assume you have a movie that internally is 25 fps, and the timeline that is 60 fps. If you set Units to Index and the parameter value to 25, you get the image that is 1 second into the movie. If you set the Units to Frames and set the value to 60 you get the same image at 1 second into the movie.

Loop Crossfade loopcrossfade - Crossfades the beginning and end of the movie together to create a smooth transition when looping. If the movie uses Trim options, it will crossfade Trim Start with Trim End positions.

Step Size stepsize - Sets how many frames to skip before displaying next frame. For example, a StepSize of 30 will display every 30th frame. This timing of movie playback does not change, so with a Step Size of 30 and a sample rate of 30, a new frame will be displayed every second.

Audio Loop audioloop - This menu helps you determine how to treat the audio as the end of a movie approaches. This is needed because of all the cases of playing a movie, like when driving with an index, the TOP will not know if you intend to loop it or not.

  • Silence - Audio will go silent when movie ends.
  • Fade - Audio will fade out when movie ends.
  • Blend to Start - Audio will blend to start of movie when looped.
  • Join to Start - Audio will cut to start of movie when looped.

Image Sequence Indexing imageindexing - Determines how an image sequence is ordered.

  • Zero Based - Index the sequence of images starting at 0, after sorting them alphanumerically.
  • Filename Based - Index the sequence of images using the numbers on the end of the filenames. I.e a file named flower400.tiff will be frame index 400, regardless of if there are other files in the directory before it.

Parameters - Image Page

Interpolate Frames interpolation - Interpolates between frames based based on exact time. For example, if the index (in frames) is 1.5, then frames 1 and 2 will be blended 50-50. If the index is 1.7 then 30% of frame 1 is blended with 70% of frame 2 and so on.

Deinterlace deinterlace - For movies that are stored as fields, where each image is made of two images interleaved together. A 30-frame per second movie would contain 60 fields per second. For each image, the even scanlines of the first field are interleaved with the odd scanlines of the second field. The Movie File In TOP has several ways of dealing with this:

  • Off off - Output the movie images unchanged.
  • Even even - Take only the even scanlines of the file's images and create the odd scanlines by interpolating between the even scanlines. (For historic reasons, scanline 0 is at the top of the images for the purpose of the deinterlacing.)
  • Odd odd - Take only the odd scanlines of the file's images and create the even scanlines by interpolating between the odd scanlines.
  • Bob (Split) bob - This produces 60 images per second for a 30 frame-per-second movie file. It first outputs the even image (as in Even above) followed by the Odd image. This has the best time-smoothness.

Field Precedence precedence - Where fields are extracted one field at a time, this will extract the Even field first by default, otehrwise it will extract the odd field first. The video industry has not standardized on one or the other.

Bottom Half of Image is Alpha (AAA) bottomhalfalpha - This is a way of encoding alpha into RGB-only formats like H.264. and several other QuickTime formats. You need to create your movies so that the bottom half of the image is the alpha (RGB = AAA). Turning on this features tells the Movie File In TOP to take the bottom half of the image and put it into the alpha channel of the output. The image height will be cut in half.

Multiply RGB by Alpha multalpha - Premultiplies the image.

Parameters - Trim Page

Trim trim - Enables the Trim parameters below.

Trim Start tstart - Sets an In point from the beginning of the movie, allowing you to trim the starting position of the movie. The units menu on the right let you specify this position by index, frames, seconds, or fraction (percentage).

Trim End tend - Sets an Out point from the end of the movie, allowing you to trim the ending position of the movie. The units menu on the right let you specify this position by index, frames, seconds, or fraction (percentage).

Extend Left textendleft - Determines how the Movie File In TOP handles movie positions that lie before the Trim Start position. For example, if Trim Start is set to 1, and the movie's current index is -10, the Extend Left menu determines how the movie position is calculated.

  • Hold - Displays the first frame in the movie range (the frame specified by Trim Start) for any position before Trim Start.
  • Cycle - Loops the movie range continuously.
  • Mirror - Loops the movie range in a zig-zag pattern. For example, playing backwards from Trim Start the movie will index will climb towards Trim End, at which point is will decend down towards Trim Start again and continue to zig-zag (or mirror) the further the movie plays backwards.
  • Black - Displays black frame for any movie position before Trim Start.

Extend Right textendright - Determines how the Movie File In TOP handles movie positions that lie after the Trim End position. For example, if Trim End is set to 20, and the movie's current index is 25, the Extend Right menu determines how the movie position is calculated.

  • Hold - Displays the last frame in the movie range (the frame specified by Trim End) for any position after Trim End.
  • Cycle - Loops the movie range continuously.
  • Mirror - Loops the movie range in a zig-zag pattern. For example, playing forwards from Trim End the movie will index will start decending towards Trim Start, at which point is will start climbing towards Trim End and continue to zig-zag (or mirror) the further the movie plays.
  • Black - Displays black frame for any movie position after Trim End.

Override Sample Rate overridesample - Enables the Override Sample Rate parameter below.

Sample Rate samplerate - Allows you to change the playback frame rate of the movie. Think of this as overriding the frame rate, helpful when using the Sequential Play Mode.

Parameters - Tune Page

Pre-Read Frames prereadframes - Sets how many video frames TouchDesigner reads ahead and stores in memory. Using this, smooth reading of an image stream is possible even when the disk files are fragmented. The Movie File In TOP will read frames of the movie into memory before they are used, this can eliminate pops or stutters in playback that occur from fragmented files, other resources accessing the hard drive, or movie looping.

Frame Read Timeout frametimeout - The time (in milliseconds) TouchDesigner will wait for a frame from the hard drive before giving up. If the Disk Read Timeout time is reached, that frame is simply skipped. This also works for network files that are downloaded via http://.

Always Load Initial Frame alwaysloadinitial - If this parameter is turned on, then for the first loaded frame the Frame Read Timeout will be ignored, and it will always wait for the first frame to ensure the node always starts up with a valid image.

File Open Timeout opentimeout - The time (in milliseconds) TouchDesigner will wait for a movie to open. If the Disk Open Timout is reached, the Movie File In TOP will stop waiting and make its image all black, with a grey square in the bottom right corner. If the file still isn't opened the next time the TOP cooks, it'll wait again, and do the same. It'll keep doing this until the file is opened, or the open fails.

On Timeout, use Latest Avail uselatestontimeout - When on, if the Disk Read Timeout is reached TouchDesigner will use the latest available frame in place of the skipped frame.

Use Global CPU Cache usecpucache - Uses CPU cache to store image into main memory. The size of the Global CPU Cache is set under Edit > Preferences > TOPs. This CPU cache only works for very specific circumstances like looping a single movie. It will store frames of a movie in CPU cache, but the entire movie must fit in the cache or it will be pushed out. We do not use this feature regularly and recommend contacting support for more details if you think you need to use it.

Async Upload to GPU asyncupload - When enabled, this will use OpenGL features to upload movie images to the GPU asynchronously. This will reduce the cook time of the Movie File In TOP considerably (in the performance monitor the lines that say "Uploading Image to GPU" will go down to almost nothing). There is a GPU memory cost to using this feature however. It uses up another (Width * Height * 4 * Read Ahead Size) bytes of GPU memory. If you are having poor results with this feature, make sure your graphics drivers are up to date.

Update Image updateimage - Image will not update when set to 0. Movie index will continue to move forward but the output image will not update. This is useful when you are using a Movie Audio CHOP to get audio from the movie, but you don't care about the video.

Max Decode CPUs maxdecodecpus - Limit the maximum number of CPUs that will be used to decode certain codecs that are capable of multi-CPU decoding, such as H264 and Cineform.

High Performance Read highperfread - This option should be used when playing back files that require very high SSD read speeds such as high resolution (4K+) HAP Q files. It greatly improves read performance in those cases. It should not be used for low resolution or low data rate files such as 1080p H264 files.

High Performance Read Factor highperfreadfactor - When doing high performance reads, this parameter controls the size of the read operations that are done on disk. Whatever the largest operation the codec asks to be done, this is multiplied by the read factor and all subsequent reads will read that much data instead. This can result in higher throughput depending on the drives. For example if a request is made to read 1MB and the factor is set to 3, then instead the operations will read 3MB from the disk and the extra 2MB read will be ready for the next frame and will likely already have the next 2 frames available in CPU RAM.

Parameters - Common Page

Output Resolution - quickly change the resolution of the TOP's data.

  • Use Input - uses the input's resolution.
  • Eighth, Quarter, Half, 2X, 4X, 8X - multiply the input's resolution by that amount.
  • Fit Resolution - Resizes the input to the size specified in Resolution using the best possible match that does not crop any of the input. It will resize the image to be larger than the input resolution if a larger resolution is specified. It's a "fit inside", Aspect Ratio is maintained.
  • Limit Resolution - Limits the input to the size specified in Resolution using the best possible match that does not crop any of the input. It will NOT resize the image to be larger than the input resolution if a larger resolution is specified. It's a "fit inside", Aspect Ratio is maintained.
  • Custom Resolution - enables the Custom Res parameter below, giving direct control over res in the X and Y axis.

Resolution - enabled only when the Output Resolution parameter is set to Custom Resolution. Some Generators like Constant and Ramp do not use inputs and only use this field to determine their size. The drop down menu on the right provides some commonly used resolutions.

Use Global Res Multiplier - Uses the Global Resolution Multiplier found in Edit>Preferences>TOPs. This multiplies all the TOPs resolutions by the set amount. This is handy when working on computers with different hardware specifications. If a project is designed on a desktop workstation with lots of graphics memory, a user on a laptop with only 64MB VRAM can set the Global Resolution Multiplier to a value of half or quarter so it runs at an acceptable speed. By checking this checkbox on, this TOP is affected by the global multiplier.

Output Aspect - sets the image aspect ratio, which is the visible width vs height, independent of the pixel resolution. If the pixels are not square, the aspect ratio is not the resolution's width/height. Watch for unexpected results when compositing TOPs with different aspect ratios.

  • Input - uses the input's aspect ratio.
  • Resolution - uses the aspect of the image's defined resolution (ie 512x256 would be 2:1), whereby each pixel is square.
  • Custom Aspect Ratio - lets you explicitly define a custom aspect ratio in the Aspect parameter below.

Aspect - Use when Output Aspect parameter is set to Custom Aspect.

Fill Viewer - determine how the TOP image is displayed in the viewer.

  • Input - uses the same Fill Viewer settings as it's input.
  • Fill - stretches the image to fit the edges of the viewer.
  • Fit Horizontal - stretches image to fit viewer horizontally.
  • Fit Vertical - stretches image to fit viewer vertically.
  • Fit Best - stretches or squashes image so no part of image is cropped.
  • Fit Worst - stretches or squashes image so image fills viewer while constraining it's proportions. This often leads to part of image getting cropped by viewer.
  • Native Resolution - displays the native resolution of the image in the viewer.

NOTE: To get an understanding of how TOPs works with images, you will want to set this to Native Resolution as you lay down TOPs when starting out. This will let you see what is actually happening without any automatic viewer resizing.

Viewer Smoothness - This controls pixel filtering in the viewers.

  • Nearest Pixel - uses nearest pixel or accurate image representation. Images will look jaggy when viewing at any zoom level other than Native Resolution.
  • Interpolate Pixels - uses linear filtering between pixels. This is how you get TOP images in viewers to look good at various zoom levels, especially useful when using any Fill Viewer setting other than Native Resolution.
  • Mipmap Pixels - uses mipmapfiltering when scaling images. This can be used to reduce artifacts and sparkling in moving/scaling images that have lots of detail. When the input is 32-bit float format nearest filtering will always be used, regardless of what is selected in the menu.

Pixel Format - format used to store data for each channel in the image (ie. R, G, B, and A). Refer to Pixel Formats for more information.

  • Input - uses the input's pixel format.
  • 8-bit fixed (RGBA) - uses 8-bit integer values for each channel.
  • sRGB 8-bit fixed (RGBA) - uses 8-bit integer values for each channel and stores color in sRGB colorspace.
  • 16-bit float (RGBA) - uses 16-bits per color channel, 64-bits per pixel.
  • 32-bit float (RGBA) - uses 32-bits per color channel, 128-bits per pixels.


  • 10-bit RGB, 2-bit Alpha, fixed (RGBA) - uses 10-bits per color channel and 2-bits for alpha, 32-bits total per pixel.
  • 16-bit fixed (RGBA) - uses 16-bits per color channel, 64-bits total per pixel.
  • 11-bit float (RGB), Positive Values Only - A RGB floating point format that has 11 bits for the Red and Green channels, and 10-bits for the Blue Channel, 32-bits total per pixel (therefore the same memory usage as 8-bit RGBA). The Alpha channel in this format will always be 1. Values can go above one, but can't be negative. ie. the range is [0, infinite).
  • 8-bit fixed (Mono) - Single channel, where RGB will all have the same value, and Alpha will be 1.0. 8-bits per pixel.
  • 16-bit fixed (Mono) - Single channel, where RGB will all have the same value, and Alpha will be 1.0. 16-bits per pixel.
  • 16-bit float (Mono) - Single channel, where RGB will all have the same value, and Alpha will be 1.0. 16-bits per pixel.
  • 32-bit float (Mono) - Single channel, where RGB will all have the same value, and Alpha will be 1.0. 32-bits per pixel.
  • 8-bit fixed (RG) - A 2 channel format, R and G have values, while B is 0 always and Alpha is 1.0. 8-bits per channel, 16-bits total per pixel.
  • 16-bit fixed (RG) - A 2 channel format, R and G have values, while B is 0 always and Alpha is 1.0. 16-bits per channel, 32-bits total per pixel.
  • 16-bit float (RG) - A 2 channel format, R and G have values, while B is 0 always and Alpha is 1.0. 16-bits per channel, 32-bits total per pixel.
  • 32-bit float (RG) - A 2 channel format, R and G have values, while B is 0 always and Alpha is 1.0. 32-bits per channel, 64-bits total per pixel.
  • 8-bit fixed (A) - An Alpha only format that has 8-bits per channel, 8-bits per pixel.
  • 16-bit fixed (A) - An Alpha only format that has 16-bits per channel, 16-bits per pixel.
  • 16-bit float (A) - An Alpha only format that has 16-bits per channel, 16-bits per pixel.
  • 32-bit float (A) - An Alpha only format that has 32-bits per channel, 32-bits per pixel.
  • 8-bit fixed (Mono+Alpha) - A 2 channel format, one value for RGB and one value for Alpha. 8-bits per channel, 16-bits per pixel.
  • 16-bit fixed (Mono+Alpha) - A 2 channel format, one value for RGB and one value for Alpha. 16-bits per channel, 32-bits per pixel.
  • 16-bit float (Mono+Alpha) - A 2 channel format, one value for RGB and one value for Alpha. 16-bits per channel, 32-bits per pixel.
  • 32-bit float (Mono+Alpha) - A 2 channel format, one value for RGB and one value for Alpha. 32-bits per channel, 64-bits per pixel.


Info CHOP

Create an Info CHOP and drag-drop the Movie File In TOP to it.

The interpretation of the channels last_frame_hd_read_time and last_frame_decode_time:

Both of those occur in a different thread, so they wont show up in the cook time. As long as the sum of those two is below your target FPSs frame time, then they wont impact your fps. If they are two large itll cause you to drop frames. Smaller files often have a larger decode time since its more work to decompress a heavily compressed file vs a lightly compressed one.

Feature Technology Notes

Read-Ahead

Through TouchDesigner's Read-Ahead setting, smooth reading of an image stream is possible, even when the disk files are fragmented. TouchDesigner will read frames of the movie into memory before they are used. By reading ahead into the movie and storing the frames away, TouchDesigner can eliminate pops or stutters in playback that occur from fragmented files, other resources accessing the hard drive, or movie looping.

Working with TOPs

Using the Global Resolution Multiplier

The Global Resolution Multiplier is found under Edit>Preferences>TOPs. This multiplier is applied to the resolution of all TOPs in the project. This lets you tailor the TOPs resolution based on the computer or footage you are using. This can be very useful for running on slower computers, as setting this value to 0.5 will reduce the resolution of the TOPs images to half. Inversely, if you have a fast workstation which can handle higher resolutions, a setting above 1.0 will multiply the resolution to a larger value, letting you process movies at higher res. Default value is 1.0.