ffmpeg Screen Recording - Easy Capture of Desktop Audio & Mic

preview_player
Показать описание
Want to record your sound card output + mic (and other audio sources) in your ffmpeg screen recording? Forget about virtual sound cards, null sinks, loopback sinks, and all that jazz... You can capture multiple sources using ffmpeg's "amix" complex filtergraph, and it's much easier to do than you'd think.

Command reference:

pactl list sources -- Output PulseAudio source list information.

Full ffmpeg string used to record this video:

ffmpeg \
-filter_complex amix=inputs=2 \
-f x11grab -r 30 -s 1366x768 -i :0.0+0,0 \
-vcodec libx264 -preset veryfast -crf 18 \
-acodec libmp3lame -ar 44100 -q:a 1 \
-pix_fmt yuv420p \
Рекомендации по теме
Комментарии
Автор

Exactly what I'm looking for. Thank you so much.

TFHavingFun
Автор

Thanks from Argentina for your wonderful tutorial, I do not even speak English but you have explained it so well that I get to understand it.

joulsteam
Автор

Thanks for the video. I didn't know Ron Swanson was so handy with shell scripts!

SockPuppetSuperstar
Автор

Tysm. This is exactly what ive been looking for and ive been needing

msdcrafter
Автор

Very Well explained.. Thank You very much.

msr
Автор

Thanks a lot, works like a charm! I tried before a lot of variations with the map option that did not work.

alexandersofianos
Автор

Thank you very much -- this is exactly the info I needed! I brought up pavucontrol to ensure that the Input Devices' Monitor of Built-in Audio Analog Stereo wasn't muted (by me earlier, dumbly) -- and, perhaps, to make sure that my Q2U mic input settings were somehow adequate (I don't find pavucontrol intuitive).

slowtennis
Автор

Thanks you helped me get audio and video recording to work in ffmpeg. Actually I didn't need all these complex options. This did it for me: -f pulse -ac 2 -i default -f x11grab -r 30 -s 1280x720 -i :0.0 -c:v libx264 -c:a pcm_s16le filename.mkv

theodorn
Автор

3:02 "It actually makes it a little lot easier..." say what? But still thanks for great explanation.

TheMieszkoIV
Автор

Thx! You helped me alot. Yet I had to use -filter:v instead of -filter_complex to finally get it right. The reason was that my version of ffmpeg prompts the following error: " Unrecognized option 'filter_complex' ".

dlwavex
Автор

WOW! ffmpeg is incredible. You've made my life so much easier. I just close the terminal when I want it to stop recording and it doesn't hurt the file at all, just wraps it up. It's amazing. Thank you!!

I was trying to get Simple Screen Recorder to work, and I probably could have futzed with JACK audio or those other two, but this is way preferable for recording virtual meetings or pretty much anything I can think of!!

I could kiss you but that's weird. Do you have some kind of ko-fi donation link?

unikadas
Автор

This is incredible, you are a Where on earth did you find documentation to do all of this? Google results are awful, this worked first try, perfectly, flawlessly!!! Thanks!

artifex
Автор

hi i am suffering form uac popups you know in window . When pop up comes ffmpeg stop recording is there any solution that pop up comes but recoding not stop ?

Amodarling
Автор

YOU ROCK !!

couple of problems : I get *terrrrible* audio tearing no matter if i use mp3 codec or pcm-s16le whenever i change volume (I guess it's linked)

also both mic is entirely dependent on current desktop sound level, and will follow it like it's the best love story ever. (I guess that's how pulse works)

It's a bit of a bum because I'd like for desktop to be a bit less loud compared to my voice (I guess I have to do it for individual apps)

here's my current code :
ffmpeg \
-f pulse -ac 2 -ar 44100 -i \
-f pulse -ac 1 -ar 48000 -i -filter_complex amix=inputs=2 \
-f x11grab -r 30 -s 1920x1080 -i :0.0+0, 0 -vf "movie=/dev/video0:f=v4l2, setpts=PTS-STARTPTS [movie]; [in][movie] [out]" \
-acodec pcm_s16le \
-vcodec libx264 -preset ultrafast -crf 22 -threads 0 -y \


according to you is there a better way to record the camera? it has a tendency to drop massive amounts of frames (without harming the dektop stream though)

tatsuuuuuu
Автор

Every single thing I tried to capture audio (including the commands in this video and in all the comments) failed.
Then I realized Mint 17.3 doesn't come with something related to pulseaudio out of the box.
sudo apt-get install pavucontrol
And all of a sudden everything works dandy. Thank you!
ffmpeg \
-f pulse -ac 2 -ar 44100 -i \
-f x11grab -r 30 -s 1440x900 -i :0.0+0, 0 \
-vcodec libx264 -preset veryfast -crf 18 \
-acodec libmp3lame -ar 44100 -q:a 1 \
-pix_fmt yuv420p \
./output_ffmpeg_15.mkv

daggawagga
Автор

it not work on windows any solution for windows please ?

Amodarling