In April of 2020, I wrote a Picture in Picture blogpost, using ffplay to show everything on a desktop and then a ffmpeg screen capture to get all of them. We can do these more simply if just capturing one at a time. The video below from Luke Smith, is a good review of the commands, even though 2017.
Simple screencast (12:05) Luke Smith, 2017. Linux based. Simple ways to capture both webcams and screens (get their names from /dev ) and to-the-point.
In addition,I like to do cutaways to B-roll while keeping the audio going, so the best way is usually for me to make the entire video and overlay a narration after complete.
1. Video
screen usually :0.0
screen usually :0.0
Active window can't be captured -- have to do the whole screen or do a bunch of offset information for some window. I don't bother. For capture, use the -f tag instead of the usual "i", because it's not a file, it's a format, x11grab. The input file will be the default tty, :0.0, set the size the usual "-s" way -- I typically leave off the bottom 30 pixels to keep off my taskbar. Get the size from xrandr, here lets say it was 1366x768...
$ ffmpeg -s 1366x738 -f x11grab -i :0.0 somefile.mp4
webcam usually /dev/video0
With the webcam, I add a bitrate -- start around 2M -- if it looks a little teary.
$ ffmpeg -i /dev/video0 -b:v 2M somefile.mp4
USB cam usually /dev/video2
Not always /dev/video1, and it's hard to find a reliable device list command. I usually try video1 and 2 -- a USB is often "2". The problem with ffmpeg -devices or (if you hate that big banner) ffmpeg -hide-banner -devices, is that only lists the programs that run them, not the hardware
$ ffmpeg -i /dev/video2 -b:v 2M somefile.mp4
2. Audio added (usually 0,0)
Note: I like to adjust mic volumes in alsamixer to get them just right. However, since we know that PulseAudio is a kludge, I sometimes must fall back to "Input Devices" in pavucontrol. Something like the setting below typically works without clipping.
This command give a huge list, some might find helpful.
$ pactl list sources
audio and screen
After reading this page, I find that simply adding it to the screen is awesome. So here was the basic command from above...
$ ffmpeg -s 1366x738 -f x11grab -i :0.0 somefile.mp4
...and then add the hw device from aplay -l, typically 0,0, and whatever codec/bitrate shit...
$ ffmpeg -s 1366x738 -f x11grab -i :0.0+0,0 -f alsa -ac 2 -i pulse -acodec aac -b:a 192k somefile.mp4
This above is a gold standard, and also in some cases mic 0,1 is available. Pick whichever one is better. There's also a way to make this simpler, which works in some cases...
$ ffmpeg -s 1366x738 -f x11grab -i :0.0 -f pulse -ac 2 -i default -acodec aac -b:a 192k somefile.mp4
audio and webcam
With the webcam, it also works fine
$ ffmpeg -i /dev/video0 -f pulse -ac 2 -i default -b:a 192k -b:v 2M somefile.mp4
audio sink
To real-time mux application sounds and microphone is slightly annoying: it appears users are forced to create a virtual microphone. Further, re-establishing the virtual mic is required after reboot or update. Also the order related apps are used appears to be important to sync audio and video.
$ pactl list sinks short
3. b-roll
There are multiple problems and solutions. The largest problem: maintain sync of narrator's mouth-2-speech, when cutting back and forth from b-roll. There are three ffmpeg solutions for me; sometimes I pull from all three:
- overlay b-roll onto completed videos: Complete video with narration. Overlay video-only clips (so doesn't silence the narration) with 100% opacity.
- complete all video without human speaking shots. Overlay narration final step: this works especially well if narrator need not be seen, so no syncing to mough movements. It's easy to overlay a consistent human, or AI (eg. Speechelo), track over the video.
- chunk it: create several clips with narrator at start of chunk, ending chunk with b roll and narrators voice-over. Be sure to use same mic settings talking over b-roll. Compile all these clips into one longer video. Appears as if going back and forth from narrator to b-roll.
Luke Smith has a video that hints at some of these solutions, and then the second link gets at it a little more difrectly
some ffmpeg features (7:42) Luke Smith, 2021. Stabilizing, horizontal display, syncing scripts.
overlaying videos ffmpeg (page), 2019.
No comments:
Post a Comment