Wednesday, February 2, 2022

ffmpeg - zoom, ticker, xfade transitions, python

1. Tech videos often use a terminal screen, zoom in or out on some element, and then slide-transition to the speaker

2. Tech videos often cutaway from the narrator to a terminal (or other B-roll). However, how to keep voice synced when return to narrator?

1. zoom

This video has a slower, more dramatic, zoom. But we can decrease the number of seconds to "1" for a better effect.

zoom and pan example (5:10) The FFMPEG guy, 2021. Moves in directly, but also does corners.

2. ticker

The first question is how much text we need to scroll. If we want a ticker smoothly scrolling throughout a video, it seems we'd want to include a ticker filter only on the final edit: we don't want to have to match-up the ticker with the next clip's ticker. However, the ffmpeg command to add the ticker includes the text in the CLI -- the amount of text to scroll for an entire video might be 30 or 40 lines. So we'll want ffmpeg to call to a text file containing our ticker text, unless we've only got a very short ticker.

The second question is if we need our ticker to loop or only run once.

ticker example (3:09) The FFMPEG guy, 2021. Starts simple and progresses through polished effects.

3. transitions

The transitions in this post use the amazing xfade filter. But for a complete list of the filters in one's ffmpeg installation:

$ ffmpeg -filters |grep xfade

xfade points

  • OTT verse list with 5 second clips of each.
  • jitter solved for a zoom around 2:16 the solution in the zoom jitter is to add a scale flag that varies with the video resolution.
    scale=12800x7200
    ... this number match the video resolution later in the same command...
    s=1280x720

4. slow audio and video

This would halve both the audio and video speeds, as seen in the video beneath it. In this one, I also happened to convert the container to MP4.

$ ffmpeg -y -i normalspeed.mkv -filter_complex "[0:v]setpts=2.0*PTS[v];[0:a]atempo=0.5[a]" -map "[v]" -map "[a]" halfspeed.mp4

half-speed example (3:28) The FFMPEG guy, 2021. Does audio, video, then both audio and video. Reveals filter complex mapping.

I have a couple other posts that touch on ffmpeg transitions, but more needed to be done. The filters are complex and you just can't learn them all fast enough. A post is needed to gather

two prior posts

These were made when I attempted to do Picture in Picture (PIP) videos.

1. PIP screencast 1 (2020) Begins with PIP comands but moves into some ffmpeg
2. PIP screencast 2 (2020) Post is mostly all ffmpeg commands.

clip organization

In order to be efficient with editing, a set of columns for figuring the time offsets on the transitions and audio is helpful. I've used Google Sheeets for the 6 columns, and the result looks useful for a large project with a hundred clips, or for a neat looking business setup. But it's overkill for a hommade 10 minute video with 5-10 clips. It takes longer to enter spreadsheet data than paper, pen and a calculator. The back of an old envelope is fine or, if attempting to keep track of edits, Day-Timer has the Teacher's Planner. The pages are similar to this: 

I write all of the clips on the left, then as I concatenate them into larger clips, I put them more to the right. The movement is from left to right. I can parenthesis and put music at far right. Transitions are noted between each clip.

mixed media

Some clips are complex. For example, for a 5 second intro, I might need JPG's that fade into something with moving text, and with music and other audio mixed in. There also might be animation. If there's panning in the JPG's, then that needs to be noted in my clip editor also. A Teacher's Planner will keep these organized, and I can scan in the pages if I prefer a record. For the graphical text, Viddyoze is fairly cost effective, and for narration Speechelo (blastersuite) is cost effective, although they do attempt to upsell.

python

ticker example (20:14) PyGotham2014, 2014. Old, out of sync, but conceptually penetrating.

No comments: