Saturday, September 9, 2017

Generating Video Intros for Training Segments

Our company had some training.  We are large enough that we have dedicated videographers and video editors, but they were unavailable.  After recording the webex, we needed to break the videos into segments, and throw a header on each segment.  That meant I had to generate some fancy-schmancy header that included a company logo, followed by the vendor logo, and then enough time to put segment-specific text.  Here's how I built the header :

First, I generated four separate images I wanted to use.  The first was "white".  The second was the company logo on white.  The third was the vendor logo and faded-company logo on white, and the last was both vendor and company logos faded on a white background.  I called them "frame-01.jpg", "frame-02.jpg", "frame-03.jpg", and "frame-04.jpeg".  I know, I know, fairly creative naming convention.

Next, I needed to create video segments for each of those.  Seeing as how I love the open-source world, and I prefer Linux as my workstation, I ended up using a command line :
    ffmpeg -loop 1 -i frame-01.jpg -c:v libx264 -t 2 -r 30 -pix_fmt yuv420p -vf scale=1920:1080,setdar=16:9 01-white.mp4
    ffmpeg -loop 1 -i frame-02.jpg -c:v libx264 -t 7 -r 30 -pix_fmt yuv420p -vf scale=1920:1080,setdar=16:9 02-company.mp4
    ffmpeg -loop 1 -i frame-03.jpg -c:v libx264 -t 7 -r 30 -pix_fmt yuv420p -vf scale=1920:1080,setdar=16:9 03-vendor.mp4
    ffmpeg -loop 1 -i frame-04.jpg -c:v libx264 -t 2 -r 30 -pix_fmt yuv420p -vf scale=1920:1080,setdar=16:9 04-faded-2_seconds.mp4
That gave me four separate videos. I wanted it to be fancy, so I thought I would use a fancy video editor to generate some cross fade/transition segments between each of them.  I used Cinelerra. It is fairly complex, but you can do a TON of stuff with it. I could have done the entire video - but kept ending up at the command line because that's where I felt most comfortable with it.  Anyway, I used that to generate transitions between the white and company videos, the company and vendor videos, and the vendor to faded videos.  I also generated a fade from the faded to the white video, just so I could fade it back to white.

Once I had those videos and transition videos, I could finally assemble them into a single header video.  This was done by creating a file with the file names listed in the following format :
    file '015-transition_from_white_to_intermountain.mp4'
    file '025-transition_from_ihc_to_sav.mp4'
    file '035-transition_from_sav_to_faded.mp4'
    file '04-faded-2_seconds.mp4'
    file '04-faded-2_seconds.mp4'
    file '04-faded-2_seconds.mp4'
    file '045-transition_from_faded_to_white.mp4'
After that, it was simply running the following command to assemble them into a single video file :
    ffmpeg -f concat -i files.txt -c copy saviynt-training_header.mp4
There was a small problem - my monitor resolution was a wee bit smaller than the 1920x1080 video I had generated.  So, on a whim, I down-scaled that video into something smaller I could play as a preview :
    ffmpeg -i saviynt-training_header.mp4 -vf scale=720:480,setdar=16:9 saviynt-training_header-smaller.mp4
Not a bad days' work!

No comments:

Post a Comment