Difference between revisions of "Virtual File System"
(Created page with "TouchDesigner's Virtual File system (VFS) allows image, movie, audio, fonts, other media and any files to be embedded in a <code>.tox</code> or <code>.toe</code> file....") |
|||
(19 intermediate revisions by 4 users not shown) | |||
Line 1: | Line 1: | ||
− | + | {{Glossary | |
+ | |Title=VFS, Virtual File System | ||
+ | |Short=Lets you embed files inside a <code>[[.tox]]</code> or <code>[[.toe]]</code> file. Operators like the Movie File In TOP that read regular files can also read the embedded VFS files using a <code>vfs:</code> syntax. | ||
+ | |Long= | ||
+ | }} | ||
− | + | == Overview == | |
− | It will of course make your <code>.tox</code> and <code>.toe</code> files larger by whatever the hard drive file size is, but one virtual file can be referred to by multiple OPs at the same time. | + | TouchDesigner's Virtual File system (VFS) allows image, movie, audio, fonts, other media and any files to be embedded in a <code>[[.tox]]</code> or <code>[[.toe]]</code> file. You can open and read them as if they are files in the filesystem. This makes <code>.tox</code> and <code>.toe</code> files more portable if they depend on images or sounds or font files. It will of course make your <code>.tox</code> and <code>.toe</code> files larger by whatever the hard drive file size is, but one virtual file can be referred to by multiple OPs at the same time. |
− | + | The palette component [[Palette:virtualFile|virtualFile]] in the Tools section lets you store virtual files without scripting. | |
− | + | === Accessing Files === | |
− | + | Internal files can be addressed directly with the <code>vfs:</code> prefix. Example: <code>vfs:/project1:test.jpg</code>. This VFS address will work in any parameter that is used to point at external files. All Operators that open files, like the [[Movie File In TOP]] and [[Audio File In CHOP]] allow the VFS syntax in their file parameters. | |
− | + | === Details === | |
− | VFS can hold entire movie files and audio files including H.264 and <code>.mp3</code> files. It can also hold <code>.ttf</code> font files and in some circumstances, <code>.dll</code> files for the [[ | + | Unlike locking a TOP where the image saved in the <code>.tox</code>/<code>.toe</code> is compressed with LZW, a Movie File In TOP that refers to a <code>.jpeg</code> file in VFS, it remains fully JPEG compressed. VFS can hold entire movie files and audio files including H.264 and <code>.mp3</code> files. It can also hold <code>.ttf</code> font files and in some circumstances, <code>.dll</code> files for the [[CPlusPlus TOP]], [[CPlusPlus SOP]] and [[CPlusPlus CHOP]]. |
Together with the [[Privacy]] option (can be set using TouchDesigner Pro only), VFS allows for additional privacy of media built into your TouchDesigner <code>.tox</code>/<code>.toe</code> files. | Together with the [[Privacy]] option (can be set using TouchDesigner Pro only), VFS allows for additional privacy of media built into your TouchDesigner <code>.tox</code>/<code>.toe</code> files. | ||
+ | |||
+ | === Avoiding Disk Bloat === | ||
+ | When using the Virtual File System during development, you can run into problems with large toe/tox file sizes, especially if you keep backup files. The best solution for this is to avoid storing virtual files until you are in the final stages of development. To simulate a Virtual File System during development, reference external files in your operators and either: | ||
+ | * change their file parameters to use vfs in final stages. | ||
+ | * use an expression in their file parameters that switches between external and virtual files based on a global variable. | ||
+ | |||
+ | {{OPSection | ||
+ | |sectionName=Usage}} | ||
+ | Two python classes give you full access to VFS functionality. | ||
+ | * [[VFS Class]] - describes a COMP's virtual file system. | ||
+ | * [[VFSFile_Class|VFSFile Class]] - describes a virtual file contained within a virtual file system. | ||
+ | |||
+ | === Examples === | ||
+ | See the above class wikis for full details. | ||
+ | {| class="wikitable" | ||
+ | | scope="row" | Add a file from disk | ||
+ | | <code>op('/base1').vfs.addFile('Banana.tif')</code> | ||
+ | |- | ||
+ | | scope="row" | Add an image from TOP | ||
+ | | <code>op('/base1').vfs.addByteArray(op('someTop').saveByteArray('.jpg'), 'imageName.jpg')</code> | ||
+ | |- | ||
+ | | scope="row" | Delete an image | ||
+ | | <code>op('/base1').vfs['Banana.tif'].destroy() | ||
+ | |- | ||
+ | | scope="row" | Save virtual file to disk | ||
+ | | <code>op('/base1').vfs['Banana.tif'].export('diskFolderName')</code> | ||
+ | |- | ||
+ | | scope="row" | Access virtual file in OP's file parameter (constant mode) | ||
+ | | <code>vfs:/base1:Banana.tif</code> | ||
+ | |} | ||
+ | |||
+ | {{OPSection | ||
+ | |sectionName=Palette Example}} | ||
+ | Use the [[Palette:virtualFile]] component in the [[Palette]] (under <code>Tools</code>) as a user interface for VFS. This allows you to use VFS without the scripting that is otherwise required. | ||
+ | |||
[[Category: Touch Glossary]] | [[Category: Touch Glossary]] |
Latest revision as of 00:23, 17 February 2021
Overview[edit]
TouchDesigner's Virtual File system (VFS) allows image, movie, audio, fonts, other media and any files to be embedded in a .tox
or .toe
file. You can open and read them as if they are files in the filesystem. This makes .tox
and .toe
files more portable if they depend on images or sounds or font files. It will of course make your .tox
and .toe
files larger by whatever the hard drive file size is, but one virtual file can be referred to by multiple OPs at the same time.
The palette component virtualFile in the Tools section lets you store virtual files without scripting.
Accessing Files[edit]
Internal files can be addressed directly with the vfs:
prefix. Example: vfs:/project1:test.jpg
. This VFS address will work in any parameter that is used to point at external files. All Operators that open files, like the Movie File In TOP and Audio File In CHOP allow the VFS syntax in their file parameters.
Details[edit]
Unlike locking a TOP where the image saved in the .tox
/.toe
is compressed with LZW, a Movie File In TOP that refers to a .jpeg
file in VFS, it remains fully JPEG compressed. VFS can hold entire movie files and audio files including H.264 and .mp3
files. It can also hold .ttf
font files and in some circumstances, .dll
files for the CPlusPlus TOP, CPlusPlus SOP and CPlusPlus CHOP.
Together with the Privacy option (can be set using TouchDesigner Pro only), VFS allows for additional privacy of media built into your TouchDesigner .tox
/.toe
files.
Avoiding Disk Bloat[edit]
When using the Virtual File System during development, you can run into problems with large toe/tox file sizes, especially if you keep backup files. The best solution for this is to avoid storing virtual files until you are in the final stages of development. To simulate a Virtual File System during development, reference external files in your operators and either:
- change their file parameters to use vfs in final stages.
- use an expression in their file parameters that switches between external and virtual files based on a global variable.
Usage
Two python classes give you full access to VFS functionality.
- VFS Class - describes a COMP's virtual file system.
- VFSFile Class - describes a virtual file contained within a virtual file system.
Examples[edit]
See the above class wikis for full details.
Add a file from disk | op('/base1').vfs.addFile('Banana.tif')
|
Add an image from TOP | op('/base1').vfs.addByteArray(op('someTop').saveByteArray('.jpg'), 'imageName.jpg')
|
Delete an image | op('/base1').vfs['Banana.tif'].destroy()
|
Save virtual file to disk | op('/base1').vfs['Banana.tif'].export('diskFolderName')
|
Access virtual file in OP's file parameter (constant mode) | vfs:/base1:Banana.tif
|
Palette Example
Use the Palette:virtualFile component in the Palette (under Tools
) as a user interface for VFS. This allows you to use VFS without the scripting that is otherwise required.