ffmpeg

I don’t know why I never tinkered with ffmpeg before, but it’s the bees knees. I can see it becoming super handy via a bash script or two and more exploring. I’m probably doing some stuff technically wrong here, but it all works. For the linux users who never used ffmpeg:

Any of you use ffmpeg?

It seems that ffmpeg can record interleaved multi-channel audio files. I have only tried up to 16 channels. But I have not yet figured out how to map specific sources to specific channels.

This records the pulse audio stereo output (all desktop output audio) and stereo mic input to a 4-channel audio file. The only thing new here over the above examples is -filter_complex amerge.

I’m still not sure how to specify which hardware channel gets mapped to which file channel, but it’s a start.

And I guess I could make that a little more legible:

ffmpeg \
-f pulse -i alsa_output.pci-0000_00_1b.0.analog-stereo.monitor \
-f pulse -i alsa_input.pci-0000_00_1b.0.analog-stereo \
-filter_complex amerge 4_chan_test.wav

I’ll give it a go tomorrow with my audio interface to see if I can record 8 audio channels without issues.

I don’t know what for (other than being really light weight), but I might like to have a straight up handy dandy pre-configured recorder or 3 available from the command line. I’m just imagining here typing rec -riff, rec -song, or rec -band, and everything is configured and rolling for those respective situations without any bs and distractions. And likely with video capture to boot. Of course, input levels would still need to be configured, and I think ffmpeg could output some numbers for checking levels. Btw, my run with a Zoom portable recorder didn’t last long. That thing really sucks to use. So much menu diving and and page changing to do very basic things, and it still can’t do some very basic things. A handheld 4-track it is not. I bet something like a Raspberry Pi could be though.

It seems like this could be useful for scripting drum samples too. It’s almost too bad that I got rid of my e-kit. But not really. Real drums rule. But I don’t get to play them much.

And of course, the nice thing here is that ffmpeg is going to already be installed for any linux desktop. So hopefully just some bash scripting can make it a pleasure to use.

It looks powerful, I’ve never played with it on the command line (or anywhere else). Got this from Stack Overflow for full screen capture in Windows, with audio from built-in mic:

ffmpeg \
    -rtbufsize 1500M \
    -f dshow \
    -i audio="Microphone Array (Realtek High Definition Audio)" \
    -f -y \
    -rtbufsize 100M \
    -f gdigrab \
    -t 00:00:30 \
    -framerate 30 \
    -probesize 10M \
    -draw_mouse 1 \
    -i desktop \
    -c:v libx264 \
    -r 30 \
    -preset ultrafast \
    -tune zerolatency \
    -crf 25 \
    -pix_fmt yuv420p \
    "c:\dev\ffmpeg_testing.mp4"

^ Combining some of that with previous posts for linux. Desktop capture with stereo desktop audio + stereo mic audio (4 audio channels) to mp4. Wear headphones of course to minimize audio bleed.

ffmpeg \
	-f x11grab \
	-i :0.0 \
	-f pulse \
	-i alsa_output.pci-0000_00_1b.0.analog-stereo.monitor \
	-f pulse \
	-i alsa_input.pci-0000_00_1b.0.analog-stereo \
	-filter_complex amerge \
    -c:v libx264 \
    -framerate 30 \
    -preset ultrafast \
    -tune zerolatency \
    -pix_fmt yuv420p \
    desktop_testing.mp4

It’s a funky doo dah, isn’t it? I had it installed on Windows for manim and Reaper uses it for video rendering too IIRC.

I might actually have to pick up the FFmpeg Basics book. See the PDF table of contents. So far everything I have tinkered with is cut+paste, combine this and that piece, man this and that option, trial and error until things work. It seems that some options don’t care much about sequence, where others do. And some options and parameters don’t seem to be documented. Powerful for sure. Just need a structured resource for learning it. I hate buying instructional books anymore though. Far too many are so poorly done in various ways that I almost always regret buying them. And I already have stacks (paper and digital) of lots of useless ones.

Found this one for grabbing webcam video on linux:

ffmpeg -f v4l2 -framerate 25 -video_size 640x480 -i /dev/video0 webcam.mkv

You can get your webcam device info with:

v4l2-ctl --list-devices

And device resolution info with:

ffmpeg -f v4l2 -list_formats all -i /dev/video0

I went ahead and grabbed that FFmpeg Basics book. Hopefully it isn’t horrible. I’ll report back on it.

@Snookoda, I never heard of manim btw. I will have to check it out at some point. It looks pretty nifty.