Saturday, January 21, 2023

obs and ffmpeg - animated text

In Linux, ppl are stuck with combining different applications to edit videos. We can apparently use OBS as a super-screenrecorder which we can play our FFMpeg videos and add OBS effects as it OBS records the screen.

Look back at a rudimentary prior post, or further down this page, for OBS hardware settings. Don't forget that each OBS "scene" is a collection of sources and configurations. It's good to at least have at least two "scenes"; one for voice and textovers (and then resave), and one for live streaming. OBS is versatile, but bare bones. Users must buy packs for anything they need. Add-ons are a mess. Who knows where to inventory and organize these add-ons for reinstallation. Users have to download all of the add-ons they can remember again. The hardest thing about OBS is no intuitive way to retrieve video files.

strategy

Once the clips are concatenated, transitioned, and so on in FFMpeg, we can use OBS as an enhanced screencapture tool that allows us to cut away to other docs, clips, pix, and overlays animated text, if needed. One type of text scroller (horizontal-scroll/ crawler/ chyron/ ticker) *can* be done in ffmpeg as described in vid below

horizontal scroller (3:10) The FFMpeg Guy, 2022. Does not loop but can be read either from the command, or from a created file.

fonts

Animated and static text require different types of fonts throughout a page. If we look at the professionally produced screen below, we have two different colors on names, which are also italicized. We have stretch caps on a white background above. The logo casts a shadow over the background to make the logo appear slightly lifted. We could add a scroller at bottom; it would be tricky to have a non-distracting font and probably would require occasional team logos.

For a block (possible scroller), I downloaded Vanilla Dreamers from fontspace.com, unzipped, put into /usr/share/fonts/manual, chmodded, then updated the database. It has limited symbols but looks OK.

$ chmod 644 VanillaDreamers.otf
$ fc-cache

I doubt I needed to put it into the system fonts for FFMpeg if I used a hard path in my commands. Also, overall there are too many font sites. I need to make a table I guess. Design Trends has some good ones to look at but are not downloadable.

animated text - obs

Even simply fading text in and out -- let alone basic crawlers, scrolling, etc -- is a PITA in FFMpeg.

clip editing - ffmpeg

The key here are clips already made. For real time adding audio or narration to existing clips, a person can configure a scene with audio setup to overdub in OBS.


crawler/chyron -- ffmpeg

subtitles

Supposedly more configurable than drawtext and easier to fade and such.

drawtext

horizontal scroller (3:10) The FFMpeg Guy, 2022. Does not loop but can be read either from the command, or from a created file.

We'll limp into the command with a weakly static text display and then get it moving. First, get a list of all installed fonts installed in /usr/share/fonts.

$ fc-list ':' file

If a person decides to install new fonts (eg, on the AUR, ttf-graduate-git is a good one for scrollers), then it's good to update the font database. Otherwise they won't be available to applications until the next boot.

$ fc-cache

I put the bitrate --in this case 3000Kbps -- prior to any filter to be sure it implements. Separate filters with commas. Here's a basic static display with a small reduction in gamma and saturation. We'll morph this into moving.

NB: - if you get errors check the font name. These sometimes change with updates. Eg, I've seen Cantarell-Regular.otf installed as Cantarell-VF.otf recently.

$ ffmpeg -i foo.mp4 -b:v 3M -vf "eq=gamma=1.1:saturation=0.9","drawtext=fontfile=/usr/share/fonts/cantarell/Cantarell-Regular.otf:fontsize=50:fontcolor=white:x=100:y=150:enable='between(t,5,15)':text='Friday\, January 13\, 2023'","drawtext=fontfile=/usr/share/fonts/cantarell/Cantarell-Regular.otf:fontsize=40:fontcolor=white:x=100:y=210:enable='between(t,10,15)':text='7\:01 PM PST'" 70113st.mp4

Which displays well. If the font appears in fc-list (as does Cantarell), we don't need a hard path and can shorten the path name. But a person can use a fontfile wherever it is with a hard path. For the x position to move to the left, we need a negative constant which we multiply by the clock. t is in seconds.

$ ffmpeg -i foo.mp4 -b:v 3M -vf "eq=gamma=1.1:saturation=0.9","drawtext=fontfile=Cantarell-Regular.otf:fontsize=50:fontcolor=white:x=300-40*t:y=600:text='Friday\, January 13\, 2023'" fooscroller.mp4

Starts the scroll at 300 and moves it off left at 40pix x clock speed. We could also enable it as above for a period. But instead of counting pixels for location on bottom of screen, it might be better to use something that places relatively, without counting pixels.If I subract a tenth from the height of the screen, it should place it 9/10 of the way to the bottom of the screen.

$ ffmpeg -i foo.mp4 -b:v 3M -vf "eq=gamma=1.1:saturation=0.9","drawtext=fontfile=Cantarell-Regular.otf:fontsize=50:fontcolor=white:x=300-40*t:y=(h-text_h)-(h-text_h)/10:text='Friday\, January 13\, 2023'" fooscroller.mp4

Some final adjustments: 1/10th is too high up the screen, let's divide by 28 or 30, let's start the scroller further right so it starts off the screen. Tweak the scroll speed up to 45, and decrease the font by 10. Still need a better block font.

$ ffmpeg -i foo.mp4 -b:v 3M -vf "eq=gamma=1.1:saturation=0.9","drawtext=fontfile=Cantarell-Bold.otf:fontsize=40:fontcolor=white:x=(w-text_w)-45*t:y=(h-text_h)-(h-text_h)/28:text='Friday\, January 13\, 2023'" fooscroller.mp4

start working on theclip. You'll have to bring a media source and label it something, and odds are the sound will be muted and you'll never figure that out. So just focus on whatever text you want to put in there.

OBS recording

Not as complicated as blender, but quirky and can crash. When screen and settings are arranged, record a 10 second test vid and tweak them. Once this is correct, can stream and/or record without surprises.

  • Overlays are tricky. In the video below, we can jump to 5:25 and overlays are discussed in a rudimentary manner.

    Scenes, sources, overlay (11:53) Hammer Dance, 2023. basic setup, including locking and so on. 3:15 audio information. 5:25 priority of source layers.

    Within sources, moving items up or down gives them layer priorty.
  • In the screen capture source, recorded video will be blank (black) if the captured application window, eg geeqie is made "full screen". Audio OK
  • Hold the ALT key when resizing window to cut out parts of a source. The border moves in or out of the image.

settings

Defaults are in parentheses.

  • video format (MKV): Go to Settings --> Output --> Recording Format and select MP4 (for other devices/YT uploads) or any other desired format.
  • canvas (16:9): 1920x1080 which it reduces to 1280x720 in the recording.
  • bitrate, etc: bitrate 2500K, 60fps, 1k tbn (clock). These are fine, however it might be ok to fiddle with 3M bitrate, 30 fps (unless need slomo), 15232 clock. I couldn't find where to change the clock.

Screens you may want are for clips, or to just show the screen window, allowing clips and PDF's to be shown as needed. For example.