This is where to start if you want to contribute to our ongoing project, thelocalworkflow. The goal here is to give you a couple of simplified chunks of the code to play with and build on as you learn javascript. Tutorials on how to get started can be found on Slack.
Here are the steps to get started:
- make sure your machine has node and git installed (should be no problem if on one of the LL machines)
- open up Terminal and get into your Development folder if you have one (type
cd ~/Development) - type
git clone https://github.com/ll-dev-team/thesimpleworkflow.gitto clone the repository--it will create a new folder for thesimpleworkflow. (Alternatively, if you have your own github account you can click the "fork" icon to fork thesimpleworkflow and work on this fork) - type
cd thesimpleworkflowto change dire - type
npm install - type
atom . - create a file in the root directory of thesimpleworkflow called
.envand add all your secret stuff (likeSLACK_TOKEN=XXXXXXXXXXXXandMONGODB_URL=XXXXXXXXXXetc.) - most currently existing functions are available by typing
node thesimpleworkflow+ an argument or two. For example,node thesimpleworkflow --slackchannelswill list all the Slack channels on the ll-dev slack team (as mk to invite you if you aren't part of it yet). For more complex commands you need to supply more arguments. For instance,node thesimpleworkflow --transcode --input [your file's path] --output [new filepath] --crf [a number like 23, say]will transcode a file at quality level 23, and it deposit it at [new filepath].
Take a look at the various files and try to get a sense of how the functions they contain get "required" at the top of thesimpleworkflow.js file before being used in the various blocks of code that follow. Also note the way we use if statements to check for various arguments and to assign values to variables before running the functions.
What should you do next? Here are some fun (and seriously useful) challenges to get you started:
- add a new
argsoption tothesimpleworkflow.jsand connect it to a simple function thatconsole.logs a message back. For bonus points, let the user specify the message by specifying an additional argument. - hook up
ffprobeSynctothesimpleworkflow.jsso that the user can get the stats on a sample video file by typingnode thesimpleworkflow --ffprobe. You can dump all the stats to start, but try working atconsole.loging out some of its features--what is its width? bitrate? starting timecode? Try logging these out for the user in an easily readable form. You can hardcode the file path for a sample file and the specified features to start, but ultimately you may want to let the user specify these as additional arguments. - now that you have the data on the file, write it out to a .txt file using
fs.writeFileSync. Check out this link for documentation on that function. - use
fs.readdirSyncto get an array of files in a folder, then loop through that folder to rename the files. Grab the metadata from each file usingffprobeSyncwhile you're at it and store it in an array that'll let you write out some interesting notes on the files to a.txtfile (this file could be part of the "shootnotes" for a given video shoot in our studio). Documentation on fs.readdirSync can be found in the same place as the rest of the fs documentation you saw above. - take a look at how we spawn "child processes" like ffprobe in
tools/ffprobetools.jsand ffmpeg intools/transcode_sync.js. Now spawn your ownffmpegchild process that does something else that ffmpeg does well. Maybe you can make an animated gif from a piece of video; maybe you can export a still. - find a completely new module on npmjs.com and require it at the top of
thelocalworkflow.js. Use it to do something useful. Some ideas = download a media file from YouTube or Instagram, tell us the date in a pretty format, parse anfcpxmlfile with xml2js and poke around in its contents, make some Trello cards that remind you to make more Trello cards. - build your own module in the
/toolsfolder and require it inthesimpleworkflow.js. This can just be the code you wrote in 3, 4, 5, or 6 above--or you can write something brand new. - much of
thelocalworkflowis based on going back and forth between .fcpxml and javascript objects or JSON. We read data (from video files with ffprobe or from Final Cut Events via.fcpxml) and turn it into js so that we can perform various operations on it (synchronizing clips, finding markers that have been inserted in FCPX, building sequences up from timecode-based ins and outs), then we build new.fcpxmlfiles to import into FCPX. Check out the sample.fcpxmlfiles in the /data folder to understand their structure. Process them withxml2jsandJSON.stringifyout the js object. Try to grab some of the stuff in the object and do stuff with it. How many clips are there? How many markers are there? Can you add the markers to an array and do something with them? Maybe generate some stills? Or animated gifs from the 2 seconds surrounding the marker? Alternatively, start from the video files, find their timecode, and generate sequences (projects or compound clips) from what you find. At this point, you are essentially rebuilding the thelocalworkflow, so . . . .
You can keep working on this repository as long as you'd like, but once you feel like you've got the basic gist of how it works (and certainly if you've made it through step 8), you may want to move over to thelocalworkflow itself. There is still a load of work to do on that project, and some of the new elements you've created here can probably be deployed there (particularly if you've written an elegant animated gif-maker).