我正在嘗試使用 ffmpeg 錄製我的螢幕、麥克風和遊戲音訊。該命令僅記錄我的螢幕。
ffmpeg \
-video_size 2560x1440 \
-framerate 60 \
-f x11grab -i :0 \
-map 0 \
-c:a copy \
-c:v libx264rgb \
-crf 0 \
-preset ultrafast \
video.mkv
它以穩定的 60 fps 錄製,ffmpeg 給出輸出
[x11grab @ 0x55717ef22dc0] Stream #0: not enough frames to estimate rate; consider increasing probesize
Input #0, x11grab, from ':0':
Duration: N/A, start: 1635606965.195981, bitrate: N/A
Stream #0:0: Video: rawvideo (BGR[0] / 0x524742), bgr0, 2560x1440, 60 fps, 1000k tbr, 1000k tbn, 1000k tbc
Stream mapping:
Stream #0:0 -> #0:0 (rawvideo (native) -> h264 (libx264rgb))
Press [q] to stop, [?] for help
[libx264rgb @ 0x55717ef30a40] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX FMA3 BMI2 AVX2
[libx264rgb @ 0x55717ef30a40] profile High 4:4:4 Predictive, level 5.1, 4:4:4 8-bit
[libx264rgb @ 0x55717ef30a40] 264 - core 155 r2917 0a84d98 - H.264/MPEG-4 AVC codec - Copyleft 2003-2018 - 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=18 lookahead_threads=3 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
Output #0, matroska, to 'video.mkv':
Metadata:
encoder : Lavf58.29.100
Stream #0:0: Video: h264 (libx264rgb) (H264 / 0x34363248), bgr0, 2560x1440, q=-1--1, 60 fps, 1k tbn, 60 tbc
Metadata:
encoder : Lavc58.54.100 libx264rgb
Side data:
cpb: bitrate max/min/avg: 0/0/0 buffer size: 0 vbv_delay: -1
frame= 174 fps= 60 q=-1.0 Lsize= 3866kB time=00:00:02.91 bitrate=10854.0kbits/s dup=0 drop=1 speed=1.01x
如果我嘗試透過向命令添加輸入來錄製音訊:
ffmpeg \
-video_size 2560x1440 \
-framerate 60 \
-f x11grab -i :0 \
-f pulse -i "alsa_output.usb-DeSheng_Electronics_Inc._XIBERIA-00.iec958-stereo.>
-f pulse -i "alsa_input.usb-DeSheng_Electronics_Inc._XIBERIA-00.mono-fallback" \
-map 0 -map 1 -map 2 \
-c:a copy \
-c:v libx264rgb \
-crf 0 \
-preset ultrafast \
video.mkv
ffmpeg 給出輸出
[x11grab @ 0x55bf9b4e80c0] Stream #0: not enough frames to estimate rate; consider increasing probesize
Input #0, x11grab, from ':0':
Duration: N/A, start: 1635606747.731781, bitrate: N/A
Stream #0:0: Video: rawvideo (BGR[0] / 0x524742), bgr0, 2560x1440, 60 fps, 1000k tbr, 1000k tbn, 1000k tbc
Guessed Channel Layout for Input Stream #1.0 : stereo
Input #1, pulse, from 'alsa_output.usb-DeSheng_Electronics_Inc._XIBERIA-00.iec958-stereo.monitor':
Duration: N/A, start: 1635606747.770507, bitrate: 1536 kb/s
Stream #1:0: Audio: pcm_s16le, 48000 Hz, stereo, s16, 1536 kb/s
Guessed Channel Layout for Input Stream #2.0 : stereo
Input #2, pulse, from 'alsa_input.usb-DeSheng_Electronics_Inc._XIBERIA-00.mono-fallback':
Duration: N/A, start: 1635606747.811649, bitrate: 1536 kb/s
Stream #2:0: Audio: pcm_s16le, 48000 Hz, stereo, s16, 1536 kb/s
Stream mapping:
Stream #0:0 -> #0:0 (rawvideo (native) -> h264 (libx264rgb))
Stream #1:0 -> #0:1 (copy)
Stream #2:0 -> #0:2 (copy)
Press [q] to stop, [?] for help
[libx264rgb @ 0x55bf9b519d80] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX FMA3 BMI2 AVX2
[libx264rgb @ 0x55bf9b519d80] profile High 4:4:4 Predictive, level 5.1, 4:4:4 8-bit
[libx264rgb @ 0x55bf9b519d80] 264 - core 155 r2917 0a84d98 - H.264/MPEG-4 AVC codec - Copyleft 2003-2018 - 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=18 lookahead_threads=3 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
Output #0, matroska, to 'video.mkv':
Metadata:
encoder : Lavf58.29.100
Stream #0:0: Video: h264 (libx264rgb) (H264 / 0x34363248), bgr0, 2560x1440, q=-1--1, 60 fps, 1k tbn, 60 tbc
Metadata:
encoder : Lavc58.54.100 libx264rgb
Side data:
cpb: bitrate max/min/avg: 0/0/0 buffer size: 0 vbv_delay: -1
Stream #0:1: Audio: pcm_s16le ([1][0][0][0] / 0x0001), 48000 Hz, stereo, s16, 1536 kb/s
Stream #0:2: Audio: pcm_s16le ([1][0][0][0] / 0x0001), 48000 Hz, stereo, s16, 1536 kb/s
[pulse @ 0x55bf9b4f4000] Thread message queue blocking; consider raising the thread_queue_size option (current value: 8)
[matroska @ 0x55bf9b518280] Non-monotonous DTS in output stream 0:1; previous: 364, current: 358; changing to 364. This may result in incorrect timestamps in the output file.
frame= 21 fps=0.0 q=0.0 size= 1kB time=00:00:01.01 bitrate= 7.7kbits/sframe= 21 fps= 21 q=0.0 size= 1kB time=00:00:01.01 bitrate= 7.7kbits/s
[matroska @ 0x55bf9b518280] Non-monotonous DTS in output stream 0:1; previous: 843, current: 838; changing to 843. This may result in incorrect timestamps in the output file.
[x11grab @ 0x55bf9b4e80c0] Thread message queue blocking; consider raising the thread_queue_size option (current value: 8)
並以 20 fps 進行記錄,同時每隔幾秒鐘列印「非單調 DTS」和「線程訊息佇列阻塞」訊息。我假設音訊在某種程度上減慢了視訊錄製速度,我該如何修復它?
答案1
對於將來遇到此問題的任何人,我透過在錄製期間開啟 pavucontrol 來修復它。