Code: Select all
ffmpeg -f alsa -ac 2 -i plughw:0,0 -async 1 -f x11grab -s 1920x1080 -i :0.0 -c:a libmp3lame -b:a 384k -c:v libx264 -b:v 4000k -r 30 -preset faster output.mkv
The tricky part for me was getting the sound and video to sync, it might actually be better to use a different program (audacity is a good choice) to record sound and then merge the files. To get it working I specifically needed to add the command "-async 1" and I needed to specify framerate at the output (-r 30) not at the input (this was in my older configuration located after the 1920x1080 setting) and finally, at any preset slower than "faster" my audio can break during recording (otherwise I would use the default medium). The alternative would be to figure this out or use pulseaudio. I'm lazy so I went for the easiest route by using a faster preset.
You can see a list of the available presets here i'm using "faster", but I hear even a low end 12" laptop can record on the ultrafast preset. (so just add "-preset ultrafast" if thats what you need) what a faster preset does is just lower the compression rate.
This yields truly nice quality video(x264 is known as one of the highest quality codecs) at very good compression and for me it worked out pretty well to record games too, you can always increase the FPS of the video too if needed but I haven't experimented with that (30 or more specifically 23/24 fps is usually what videos run at.) Just seeing if I can help sadly I don't have a mic, and would record voice separate from the video itself, but it can't be that hard to tell it to record mic. If it's hard to figure out though, you can just cheat and download teamspeak 3 and use that to record your voice through the mic while you're recording the video (that is actually what I do just make sure not to use voice activation detection when recording. For best quality I use the CELT Mono codec in teamspeak at maximum quality) (or you could use audacity for better quality control)
The alternative to the h264 codec would be VP8, here they are compared. Of course you can also look into h265 and vp9, the next gen codecs essentially. h265 might actually be available for ffmpeg already (i'll have to check) question is if youtube can decode it. (Edit: I actually tried, but failed to record anything with hevc, all i managed to get were either a black screen or errors)
I recommend recording first in lossless for maximum quality and performance together during the recording
Code: Select all
ffmpeg -f alsa -ac 2 -i plughw:0,0 -async 1 -f x11grab -s 1920x1080 -i :0.0 -c:a flac -c:v libx264 -r 60 -preset ultrafast -qp 0 output.mkv
then encode it again with the veryslow preset, like so
Code: Select all
ffmpeg -i output.mkv c:a flac -b:a 384k c:v libx264 -b:v 8000k -preset veryslow compressed.mkv
To get the most out of the codec's compression capabilities. (Encoding veryslow takes a long time, probably longer than the video itself)
What I think (but don't truly know) "-qp 0" does is set it to record losslessly, that is it records at the same bitrate as source (when I used it I had 28000k bitrate and a 2 minute file at 400mbs (seems lossless to me judging by that size)). If you don't want that enormous filesize, just set a bitrate on the original capture with "-b:v" but remember to erase the "-qp 0" setting.
More on recommended specs here. Note that I read somewhere Mkv is the best format for uploading to youtube (not mp4 like that page suggests)
Bitrates in video generally affect how smooth it is overall (8000 should be very very smooth) although I don't know how exactly it works for audio. This setting also has an enormous impact on the filesize.
If you want to deinterlace, go here.
Hint: You can set an alias for encoding by ending the command with "-i" instead of starting with it
Hint 2: You can set the naming of the output files in the alias to be bound to date and time so you won't have to overwrite everytime you run the command
Please tell me you saw this Josh! it was a lot of work to get this right.