在ffmpeg中使用x264编解码器时没有录制视频

在ffmpeg中使用x264编解码器时没有录制视频

我的脚本使用以下命令来录制整个屏幕:

ffmpeg -f x11grab -y -r 24  -s 1366x768 -i :0.0 -f alsa -i default -vcodec libx264 out.avi

但运行后,out.avi不包含视频,只有声音。

这是完整的输出(通过Ctrl+中断C):

ffmpeg version 3.4.6-0ubuntu0.18.04.1 Copyright (c) 2000-2019 the FFmpeg developers
  built with gcc 7 (Ubuntu 7.3.0-16ubuntu3)
  configuration: --prefix=/usr --extra-version=0ubuntu0.18.04.1 --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --enable-gpl --disable-stripping --enable-avresample --enable-avisynth --enable-gnutls --enable-ladspa --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libmp3lame --enable-libmysofa --enable-libopenjpeg --enable-libopenmpt --enable-libopus --enable-libpulse --enable-librubberband --enable-librsvg --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx265 --enable-libxml2 --enable-libxvid --enable-libzmq --enable-libzvbi --enable-omx --enable-openal --enable-opengl --enable-sdl2 --enable-libdc1394 --enable-libdrm --enable-libiec61883 --enable-chromaprint --enable-frei0r --enable-libopencv --enable-libx264 --enable-shared
  libavutil      55. 78.100 / 55. 78.100
  libavcodec     57.107.100 / 57.107.100
  libavformat    57. 83.100 / 57. 83.100
  libavdevice    57. 10.100 / 57. 10.100
  libavfilter     6.107.100 /  6.107.100
  libavresample   3.  7.  0 /  3.  7.  0
  libswscale      4.  8.100 /  4.  8.100
  libswresample   2.  9.100 /  2.  9.100
  libpostproc    54.  7.100 / 54.  7.100
[x11grab @ 0x56271f542e00] Stream #0: not enough frames to estimate rate; consider increasing probesize
Input #0, x11grab, from ':0.0':
  Duration: N/A, start: 1592158154.433194, bitrate: N/A
    Stream #0:0: Video: rawvideo (BGR[0] / 0x524742), bgr0, 1366x768, 24 fps, 1000k tbr, 1000k tbn, 1000k tbc
Guessed Channel Layout for Input Stream #1.0 : stereo
Input #1, alsa, from 'default':
  Duration: N/A, start: 1592158154.486958, bitrate: 1536 kb/s
    Stream #1:0: Audio: pcm_s16le, 48000 Hz, stereo, s16, 1536 kb/s
Stream mapping:
  Stream #0:0 -> #0:0 (rawvideo (native) -> h264 (libx264))
  Stream #1:0 -> #0:1 (pcm_s16le (native) -> mp3 (libmp3lame))
Press [q] to stop, [?] for help
[swscaler @ 0x56271f57d220] Warning: data is not aligned! This can lead to a speed loss
[libx264 @ 0x56271f56c8c0] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX FMA3 BMI2 AVX2
[libx264 @ 0x56271f56c8c0] profile High 4:4:4 Predictive, level 3.2, 4:4:4 8-bit
[alsa @ 0x56271f54cd20] Thread message queue blocking; consider raising the thread_queue_size option (current value: 8)
Output #0, avi, to 'out.avi':
  Metadata:
    ISFT            : Lavf57.83.100
    Stream #0:0: Video: h264 (libx264) (H264 / 0x34363248), yuv444p(progressive), 1366x768, q=-1--1, 24 fps, 24 tbn, 24 tbc
    Metadata:
      encoder         : Lavc57.107.100 libx264
    Side data:
      cpb: bitrate max/min/avg: 0/0/0 buffer size: 0 vbv_delay: -1
    Stream #0:1: Audio: mp3 (libmp3lame) (U[0][0][0] / 0x0055), 48000 Hz, stereo, s16p
    Metadata:
      encoder         : Lavc57.107.100 libmp3lame
frame=   14 fps=0.0 q=0.0 size=      10kB time=00:00:00.00 bitrate=N/A speed=   frame=   26 fps= 26 q=0.0 size=      10kB time=00:00:00.00 bitrate=N/A speed=   frame=   38 fps= 25 q=0.0 size=      10kB time=00:00:00.00 bitrate=N/A speed=   frame=   50 fps= 25 q=0.0 size=      10kB time=00:00:00.00 bitrate=N/A speed=   frame=   62 fps= 25 q=28.0 size=      10kB time=00:00:00.16 bitrate= 476.2kbits/frame=   74 fps= 24 q=28.0 size=      10kB time=00:00:00.67 bitrate= 118.1kbits/frame=   80 fps= 22 q=-1.0 Lsize=     516kB time=00:00:03.25 bitrate=1301.2kbits/s speed=0.906x    
video:487kB audio:16kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 2.520141%
[libx264 @ 0x56271f56c8c0] frame I:1     Avg QP:19.01  size:112157
[libx264 @ 0x56271f56c8c0] frame P:20    Avg QP:16.66  size: 18812
[libx264 @ 0x56271f56c8c0] frame B:59    Avg QP:21.03  size:   181
[libx264 @ 0x56271f56c8c0] consecutive B-frames:  1.2%  0.0%  3.8% 95.0%
[libx264 @ 0x56271f56c8c0] mb I  I16..4: 44.2%  0.0% 55.8%
[libx264 @ 0x56271f56c8c0] mb P  I16..4:  2.4%  0.0%  5.3%  P16..4:  2.4%  0.5%  0.4%  0.0%  0.0%    skip:89.0%
[libx264 @ 0x56271f56c8c0] mb B  I16..4:  0.0%  0.0%  0.0%  B16..8:  4.4%  0.0%  0.0%  direct: 0.0%  skip:95.5%  L0:39.8% L1:58.9% BI: 1.3%
[libx264 @ 0x56271f56c8c0] coded y,u,v intra: 48.6% 8.6% 8.0% inter: 0.2% 0.0% 0.0%
[libx264 @ 0x56271f56c8c0] i16 v,h,dc,p: 55% 41%  3%  1%
[libx264 @ 0x56271f56c8c0] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 33% 25% 17%  2%  5%  4%  5%  4%  4%
[libx264 @ 0x56271f56c8c0] Weighted P-Frames: Y:0.0% UV:0.0%
[libx264 @ 0x56271f56c8c0] ref P L0: 71.9% 13.0% 12.4%  2.6%
[libx264 @ 0x56271f56c8c0] ref B L0: 77.7% 21.7%  0.6%
[libx264 @ 0x56271f56c8c0] ref B L1: 96.0%  4.0%
[libx264 @ 0x56271f56c8c0] kb/s:1197.83
Exiting normally, received signal 2.

我也安装x264libx264-152打包了。

我使用 KDE Neon 5.19 (Ubuntu 18.04)。

提前致谢。

答案1

取决于您使用哪个应用程序来播放截屏视频。 VLC 根本就失败了,理由是“硬件加速器无法解码图片”。

当更改为“X11 视频输出 (XCB) 时,我可以看到该视频 - 由于 2 显示设置而产生偏移...帧被捕获,但编解码器似乎很奇怪:High 4:4:4 Predictive@L3。更改配置文件不起作用,所以看起来ffmeg 正在使用 XCB。 FFMPEG 文档

相关内容