Difference between revisions of "Python Sample Export Videos"

From truxwiki.com
Jump to navigation Jump to search
(Created page with "This sample shows the how to export video files in Python. =Source Code= <source line lang="python"> import sys sys.path.append('C:/Program Files/Truxton/SDK') import truxton...")
 
Line 36: Line 36:
 
Line 12 sets the format of the output to [https://en.wikipedia.org/wiki/Tar_%28computing%29#UStar_format TAR] in a file named <code>UniqueVideosFromTruxton.tar</code>
 
Line 12 sets the format of the output to [https://en.wikipedia.org/wiki/Tar_%28computing%29#UStar_format TAR] in a file named <code>UniqueVideosFromTruxton.tar</code>
  
Line 43 changes the file type to our identifier for Acme.
+
Line 13 tells the exporter to only output one copy of a file.
We talked about [[Add A New File Type#Register a New Type | file type identifiers]] in a previous article.
+
Only unique file contents will be output, no copies.
  
Line 48-51 begins the process of sending this newly identified file to any ETL process that has registered for it.
+
Line 15 begins the process of exporting the files.
The first step is to overwrite the <code>filetype</code>, which should contain <code>[[Type_Unknown]]</code>, with the identifier for our file type.
+
This provides no feedback, we suggest you monitor the output folder.
The last step is to call <code>[[TruxtonMessage#route()|route()]]</code> which tells Truxton to send this message to any ETLs that want it.
 
 
 
Line 54 completes the loop by getting another message from the acme message queue.
 

Revision as of 15:16, 29 March 2021

This sample shows the how to export video files in Python.

Source Code

 1 import sys
 2 sys.path.append('C:/Program Files/Truxton/SDK')
 3 import truxton
 4 
 5 def main():
 6 
 7  t = truxton.create()
 8  exporter = t.newexporter()
 9  exporter.addcriteria( exporter.fqgroup, truxton.Type_VideoCategory )
10  exporter.addoption( exporter.eoname, "{hash}.{ext}" )
11  exporter.addoption( exporter.eofolder, "c:\\temp" )
12  exporter.addoption( exporter.eotar, "UniqueVideosFromTruxton.tar" ) 
13  exporter.addoption( exporter.eounique, "1" )
14 
15  exporter.execute()
16 
17 if __name__ == "__main__":
18     main()

Code Walkthrough

The above code shows how to export a category of file types from Truxton.

Line 8 creates the exporter.

Line 9 tells the exporter that we want all file types in the Type_VideoCategory.

Line 10 tells the exporter to use the MD5 hash as the filename and the extension registered for the type of file as the extension.

Line 11 will cause the exporter to write the output the file to the c:\temp folder.

Line 12 sets the format of the output to TAR in a file named UniqueVideosFromTruxton.tar

Line 13 tells the exporter to only output one copy of a file. Only unique file contents will be output, no copies.

Line 15 begins the process of exporting the files. This provides no feedback, we suggest you monitor the output folder.