Showing posts with label obs. Show all posts
Showing posts with label obs. Show all posts

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.

Monday, February 14, 2022

stream and record - obs and ffmpeg 1

Links: OBS site w/forums

A high-speed internet connection is foundational for streaming, but what are some other considerations? Some live stream sites (YouTube, Discord, Glimesh) will need an OBS type app on the user's system to format a stream to transmit to their site. Other sites (Zoom) have a proprietary streaming app, but the app experience can sometimes be enhanced by routing it through an OBS-type app. A third issue is the various streaming protocols and site authentications. A fourth issue is hardware problems which can be specific to a streaming app. All this complexity allows for multiple problems and solutions.

Note: a fifth issue is that OBS is natively setup for the notorious Nvidia hardware and the PulseAudio software. Detection of audio is particularly difficult without PulseAudio, eg requiring JACK config.

protocols and authentication

RTMP streaming providers typically require a cell number via the "security" (forensic record) requirement of 2FA requiring a cell. This is an immense safety issue. Who knows how these providers tie cell numbers to credit reports, "trusted 3rd parties", etc? The answer is consumers are expected to understand a multi-page "privacy" policy filled with legalistic language and equivocations, which regularly changes, and which varies from site to site. Way to protect us Congress, lol. Accordingly, since I essentially have no idea what they're doing with my cell, I try to avoid streaming services which require a cell.

 

Although they require a cell*, YouTube's advantage is streaming directly from a desktop/laptop with nothing beyond a browser. Discord can do similarly with limited functionality, and they have a discord app which adds features. Glimesh works well with OBS -- it provides a stream key for OBS, or whatever a person is using.

*YouTube requires "account verification" at https://www.youtube.com/verify prior to streaming. The verification is 2FA to a cell.

obs

Those not intending to use OBS can still find utility in its attempts to stream or record. A great deal will be revealed about one's system. OBS logs are also valuable to identify/troubleshoot problems, eg the infamous 'ftl_output' not found issue -- you'll find it in the logs (~/.config/obs-studio/logs). OBS can encounter a couple of problems.

obs hardware issue: nvidia graphics card

Obviously, no one wants NVidia hardware: the associated bloatware is almost unbearable. However, its use is so common that many users have it in their system(s). OBS therefore makes Nvidia the default. This setting spawns errors for systems with AMD Radeons. Change the "NV12" (or 15 by now) circled below to an option which works for one's hardware.

1. obs audio problem - alsa and jack

Most desktops unfortunately have two audio systems: an MB chip, and a graphics card chip. Difficulty can arise when one source is needed for mic input, and the the other source is needed for playback (eg, for HDMI). This is bad enough. However there's an additional problem with OBS -- it doesn't detect ALSA. Your options are PulseAudio (gag), or JACK (some config work, depending). I end up using a modified PulseAudio. More about that here.

1. obs local configuration and usage: to MP4

Fffmpeg works great for screen and input captures, but OBS can be preferable for more mixing in during live. In OBS terminology "scenes" and "sources" are important words. Scenes is a collection of inputs (sources). OBS is good at hardware detection, but files can be played, websites shown, hardware (cams, mics), images (eg for watermarks) other videos, and so on. For making MP4's "Display Capture" is obviously an important source.

Scenes and Sources (8:08) Hammer Dance, 2021. How to add the scenes and sources to them.

V4L2 issues

1. loopback issue

Unimportant, though you might find it in the OBS logs

v4l2loopback not installed, virtual camera disabled.

The solution steps are here.

  • v4l2loopback-dkms: pacman. basic loopback. This makes a module, so you need to do, pacman -S linux-headers prior to the loopback. install.
  • v4l2loopback-dc-dkms: AUR. haven't tried this one. apparently allows connecting an Android device and using it as a webcam via wifi

We're not done because the loopback device will takeover /dev/video0, denying use of our camera. So we need to configure our loopback to run on /dev/video1. This has to be specified by putting a load-order file into /etc/modules-load.d/ .

Install the loopback, if desired.

# pacman -S v4l2loopback-dkms

2. ftl_output issue

This is one is important.

$ lsmod |grep video
uvcvideo 114688 1
videobuf2_vmalloc 20480 1 uvcvideo
videobuf2_memops 20480 1 videobuf2_vmalloc
videobuf2_v4l2 36864 1 uvcvideo
videobuf2_common 65536 2 videobuf2_v4l2,uvcvideo
videodev 282624 4 videobuf2_v4l2,uvcvideo,videobuf2_common
video 53248 3 dell_wmi,dell_laptop,i915
mc 65536 4 videodev,videobuf2_v4l2,uvcvideo,videobuf2_common

If we haven't installed loopback, then video0 is the default. Note this is verified by the lack of any settings or capabilities returned on video1.

$ v4l2-ctl --list-devices
Integrated_Webcam_HD: Integrate (usb-0000:00:14.0-2):
/dev/video0
/dev/video1
/dev/media0
$ v4l2-ctl -l -d 0
brightness 0x00980900 (int) : min=-64 max=64 step=1 default=0 value=0 contrast 0x00980901 (int) : min=0 max=95 step=1 default=0 value=0 saturation 0x00980902 (int) : min=0 max=100 step=1 default=64 value=64 hue 0x00980903 (int) : min=-2000 max=2000 step=1 default=0 value=0 white_balance_temperature_auto 0x0098090c (bool) : default=1 value=1 gamma 0x00980910 (int) : min=100 max=300 step=1 default=100 value=100 gain 0x00980913 (int) : min=1 max=8 step=1 default=1 value=1 power_line_frequency 0x00980918 (menu) : min=0 max=2 default=2 value=2 white_balance_temperature 0x0098091a (int) : min=2800 max=6500 step=1 default=4600 value=4600 flags=inactive sharpness 0x0098091b (int) : min=1 max=7 step=1 default=2 value=2 backlight_compensation 0x0098091c (int) : min=0 max=3 step=1 default=3 value=3 exposure_auto 0x009a0901 (menu) : min=0 max=3 default=3 value=3 exposure_absolute 0x009a0902 (int) : min=10 max=626 step=1 default=156 value=156 flags=inactive
$ v4l2-ctl -l -d 1
[nothing]

However, even with this default correct, there is a ftl_output error remaining which prevents an output video stream.

$ yay -S ftl-sdk

plug-ins

OBS has plugins, for example one that shows keystrokes and mouse clicks.

Streaming and Recording(11:08) Gaming Careers, 2019. OBS based tutorial, using the computer, not a capture card.
GoPro to WiFi(page) Action Gadgets, 2019. Used GoPros can work as well as newer cams.

settings - device

repurposed cams

attendance

  • meet: only in highly paid plans beginning about $12 per month (2023). The higher level educator plans also.
  • zoom: only in paid plans
  • teams: only in paid plans - teames is part of microsoft360 business suite
  • webex: webex is inherently pay-only

Streaming and Recording(11:08) Gaming Careers, 2019. OBS based tutorial, using the computer, not a capture card.