Login | Register 
FEATURES
APPLICATIONS
DOWNLOADS
EDUCATION
BLOG
WIKI
FORUM
STORE

Random video player from subtitles file

Still a little green? Ask your beginner's questions here

Random video player from subtitles file

Postby hmihalis1 » Mon Apr 16, 2018 9:04 am

Hi there,

I'm totally new to touchdesigner although I do have some familiarity with MaxMSP/Jitter.

What i'm trying to do is have a patch which reads a subtitles file, and when certain keywords come up in the text it will select a random video from a specific folder and send it to an output. The video is 4k but I have a pretty good graphics card (GeForce GTX 1080).

So basically a stream of data, something that checks to see if any of the words in that line match any of the keywords, if so then make random selection from matching folder, if not then continue to next video in current folder or something like that.

Hope that makes sense. I see there are some tutorials on video playback and selecting a random video index so that shouldn't be too hard, but it would good if anyone has any ideas on how to read out the subtitles file and check for the matching words>send the trigger to select the video.

Any help very much appreciated,
hmihalis1
 
Posts: 1
Joined: Tue Apr 10, 2018 8:03 am

Re: Random video player from subtitles file

Postby sam_hains » Wed Apr 18, 2018 12:41 pm

I would do this with python.

You create a python extension class on a ContainerCOMP and call it something like 'SubtitleReader'.
https://matthewragan.com/2016/07/14/python-in-touchdesigner-extensions-touchdesigner/

You'd then create a class variable called something like current_subtitle_index on the SubtitleReader class that keeps track of where you are up to in the subtitle file.

You can set up a public class function on the SubtitleReader called something like 'NextSubtitle' which will use a python library (eg. https://pypi.org/project/pysrt/) to get the next subtitle text from the file while updating the 'current_subtitle_index'. You can do your checking/matching logic in this function. You can also do your 'random video selection from a folder' logic and set various MovieTOP file parameter etc. in this function.By doing things like
Code: Select all
op("moviefilein1").par.file = insertRandomFileNameHere
inside your python code.

You can then use a TimerCHOP with a CHOP Execute to call this function at intervals.

I don't know how to do this without a heavy amount of python! Hope that is helpful!
Sam Hains
ITP, NYU
http://samhains.com
sam_hains
 
Posts: 29
Joined: Thu Sep 28, 2017 6:34 pm
Location: NYC, NY


Return to Beginners

Who is online

Users browsing this forum: No registered users and 9 guests