Hi, this is my script so far to capture the screen and audio from one Mic input on my six channel USB sound card. I am not confident that it is optimal and would love some feedback. I am using Centos 8.2 with FFMPEG 4.2.4:
#!/usbin/env bash buffer_size="4096" ffmpeg \ -thread_queue_size "$buffer_size" -f x11grab -video_size 1920x1080 -framerate 30 -i "$DISPLAY" \ -thread_queue_size "$buffer_size" -f alsa -acodec pcm_s32le -ac 6 -i sysdefault \ -c:v libx264 -preset ultrafast -crf 0 \ -c:a pcm_s32le -af "pan=mono|c0=FR" \ "$1".mkv
- I am attempting to bypass PulseAudio and capture audio direcly in ALSA in the hope to avoid any sample rate conversion or other nonsense. When I type ffmpeg -sources it tells me:
* default [Default ALSA Output (currently PulseAudio Sound Server)] sysdefault:CARD=USB [Default Audio Device]
So I am using sysdefault, but the output of FFMPEG looks identical:
Input #1, alsa, from 'sysdefault': Duration: N/A, start: 1604837938.951852, bitrate: 9216 kb/s Stream #1:0: Audio: pcm_s32le, 48000 Hz, 5.1, s32, 9216 kb/s Input #1, alsa, from 'default': Duration: N/A, start: 1604837699.971844, bitrate: 9216 kb/s Stream #1:0: Audio: pcm_s32le, 48000 Hz, 5.1, s32, 9216 kb/s
Am I dong this right?
- I am capturing a lot of text for coding tutorials, but YouTube etc converts my 4:4:4 capture to 4:2:0 and it makes some text blurry and some colors dull. I have tried adding -pix_fmt yuv420p and the results are much better than OBS studio, but still not great. Is there some filter I can add to at least get the colors to match better?
- I am adding buffers in the hope of avoiding dropouts in audio/video but don't really know what I am doing, is my script correct?
- Is libx264 -preset ultrafast -crf 0 actually lossless? How about changing to fast, would it make any difference?
- I have tried to capture using VAAPI and my Intel QuickSync CPU in H264, but nothing seems to work. Does anyone know how I could do that? It works in OBS studio and the CPU load is much lower, so I know my system is up to it. What settings for the hightest quality are I have no idea.
The results are all going to go through a video editor, so I just want the highest quality with a reasonable file size and it will be rendered out for YouTube at the end. Here is my output, in case it helps:
[x11grab @ 0x564127cb0080] Stream #0: not enough frames to estimate rate; consider increasing probesize Input #0, x11grab, from ':0': Duration: N/A, start: 1604839513.885589, bitrate: N/A Stream #0:0: Video: rawvideo (BGR / 0x524742), bgr0, 1920x1080, 30 fps, 1000k tbr, 1000k tbn, 1000k tbc Guessed Channel Layout for Input Stream #1.0 : 5.1 Input #1, alsa, from 'sysdefault': Duration: N/A, start: 1604839513.556539, bitrate: 9216 kb/s Stream #1:0: Audio: pcm_s32le, 48000 Hz, 5.1, s32, 9216 kb/s Stream mapping: Stream #0:0 -> #0:0 (rawvideo (native) -> h264 (libx264)) Stream #1:0 -> #0:1 (pcm_s32le (native) -> pcm_s32le (native)) [alsa @ 0x564127cb9b80] ALSA buffer xrun. [libx264 @ 0x564127d0f6c0] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX FMA3 BMI2 AVX2 [libx264 @ 0x564127d0f6c0] profile High 4:4:4 Predictive, level 4.0, 4:4:4, 8-bit [libx264 @ 0x564127d0f6c0] 264 - core 157 r2980 34c06d1 - H.264/MPEG-4 AVC codec - Copyleft 2003-2019 - http://www.videolan.org/x264.html - options: cabac=0 ref=1 deblock=0:0:0 analyse=0:0 me=dia subme=0 psy=0 mixed_ref=0 me_range=16 chroma_me=1 trellis=0 8x8dct=0 cqm=0 deadzone=21,11 fast_pskip=0 chroma_qp_offset=0 threads=12 lookahead_threads=2 sliced_threads=0 nr=0 decimate=1 interlaced=0 bluray_compat=0 constrained_intra=0 bframes=0 weightp=0 keyint=250 keyint_min=25 scenecut=0 intra_refresh=0 rc=cqp mbtree=0 qp=0 [Parsed_pan_0 @ 0x564128623300] Pure channel mapping detected: 1 Output #0, matroska, to 'hello.mkv': Metadata: encoder : Lavf58.29.100 Stream #0:0: Video: h264 (libx264) (H264 / 0x34363248), yuv444p(progressive), 1920x1080, q=-1--1, 30 fps, 1k tbn, 30 tbc Metadata: encoder : Lavc58.54.100 libx264 Side data: cpb: bitrate max/min/avg: 0/0/0 buffer size: 0 vbv_delay: -1 Stream #0:1: Audio: pcm_s32le ( / 0x0001), 48000 Hz, mono, s32, 1536 kb/s Metadata: encoder : Lavc58.54.100 pcm_s32le frame= 111 fps= 30 q=-1.0 Lsize= 2357kB time=00:00:06.16 bitrate=3129.8kbits/s dup=0 drop=74 speed=1.69x video:1749kB audio:604kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.169490%