ooooooooooooooooooo
Influencer Marketing Manager
2
MONTHS
2 2 MONTHS OF SERVICE
LEVEL 1
300 XP
So you want to do a proper screen capture on linux? OBS is still in beta and a little slow, and pulseaudio is a pain in the ass. The good news is you can use it's ffmpeg backend has a standalone client. Here is a basic screen capture command:
You can run that, but it probably looks and sounds like shit. I did this intentionally, because you should tweak it.
Here's a rundown of these basic options:
and use pcm_format as your audio codec.
[alsa @ 0xffffffffffff] ALSA buffer xrun.
[x11grab @ 0xffffffffffff] Thread message queue blocking; consider raising the thread_queue_size option (current value: 8)
If you want to record what you hear, it's time to fuck with alsa.
Some soundcards have a loopback channel you can use, look for it with aplay -l. If not, you need to modprobe snd_aloop, (to do this at boot dig around in your distro's docs,)
which is a virtual output device on Loopback,1,0 that plays to a virtual input device on Loopback,0,0. This sounds confusing, but trust me it works.
ALSA's configs are ~/.asoundrc for your user, or /etc/asound.conf for global. What we need to do is split alsa's default output between your speakers and
Loopback,1,0 then record Loopback,0,0 with ffmpeg. You can also use this to micspam over VoIPs, so pay attention
--jc0n
Edited by l3tm31n, 14 September 2015 - 02:35 PM.
Code:
ffmpeg -f x11grab -s 1280x720 -r 30 -i $DISPLAY -f alsa -i default \
-c:v libx264 -preset ultrafast -crf 18 -pix_fmt yuv444p -c:a libfdk_aac -\
-threads 0 nulled.mkv
Here's a rundown of these basic options:
- -f x11grab: x11grab records x11's video buffer, which is probably what you see on your screen.
- -s 1280x720 sets the resolution, match this to the monitor you are recording.
- -i $DISPLAY is the x11grab's input, $DISPLAY is an environment variable that is set to the display number xorg is running on.
- -f alsa: alsa is a common linux soundsystem, if you use pulseaudio use -f pulse
- -i default sets alsa capture to the default input, if you don't have a microphone or don't want to use one remove this.
- -c:v libx264 encodes the video stream with h.264, a very common codec.
- -crf 18 is the compression level h.264 uses. A lower number means higher quality frames at the cost of hdd overhead.
- -pix_fmt yuv444p is the newest standard color profile, you might want yuv420p for legacy support and dank weed
- -c:a encodes the audio stream with ffmpeg's native aac library. It's shitty, either use libmp3lame, or recompile with --enable-nonfree and --enable-libfdk_aac and use libfdk_aac.
and use pcm_format as your audio codec.
- -threads 0 tells ffmpeg to multithread with as many threads as it possibly can
- nulled.mkv saves the output in a matroska video container file.
[alsa @ 0xffffffffffff] ALSA buffer xrun.
[x11grab @ 0xffffffffffff] Thread message queue blocking; consider raising the thread_queue_size option (current value: 8)
If you want to record what you hear, it's time to fuck with alsa.
Some soundcards have a loopback channel you can use, look for it with aplay -l. If not, you need to modprobe snd_aloop, (to do this at boot dig around in your distro's docs,)
which is a virtual output device on Loopback,1,0 that plays to a virtual input device on Loopback,0,0. This sounds confusing, but trust me it works.
ALSA's configs are ~/.asoundrc for your user, or /etc/asound.conf for global. What we need to do is split alsa's default output between your speakers and
Loopback,1,0 then record Loopback,0,0 with ffmpeg. You can also use this to micspam over VoIPs, so pay attention
- adding -channel_layout stereo after your -i's will prevent ffmpeg from showing the auto-detect warning.
- setting the libx264 preset from ultrafast to fast, veryfast, or superfast will affect compression quality.
- using filename "$HOME/$(date +"%F %T.mkv")" will save the file with a timestamp, useful for scripts.
--jc0n
Edited by l3tm31n, 14 September 2015 - 02:35 PM.