ffmpeg 화면 캡처 기능이 궁금해서 h264에서 간단한 실시간 캡처 테스트를 시작했습니다.
ffmpeg -f dshow -i video="screen-capture-recorder" -video_size 1920x1080 -framerate 30 -c:v libx264 -crf 0 -preset ultrafast capture.mkv
ffmpeg h264 문서에 설명 된 내용에 따라 -qp 0
또는 -crf 0
옵션 libx264가있는 손실없는 모드에서 작동해야합니다.
-qp 0 또는 -crf 0을 사용하여 무손실 출력을 인코딩 할 수 있습니다. 8 비트와 10 비트 x264는 무손실에 대해 서로 다른 -crf 값을 사용하므로 무손실에는 -qp를 사용하는 것이 좋습니다.
이 옵션은 실시간 캡처 섹션 도움말에서 반복되어 일부 크기를 저장하기 위해 느린 사전 설정으로 선택적 재 인코딩에 대해 이야기 할 때도 도움이됩니다.
초기 기록은 손실이없고 재 인코딩도 손실이 없으므로이 프로세스에서 어떠한 방식으로도 품질 손실이 발생하지 않습니다.
이를 바탕으로 가이드를 신뢰하고 -qp 0을 사용한다고 가정했습니다.
그러나 특정 상황에서 약간의 손실이 발생한다는 것을 알았습니다.
그래서이 코드로 huffyuv 코덱으로 다른 테스트를했습니다.
ffmpeg -f dshow -i video="screen-capture-recorder" -video_size 1920x1080 -framerate 30 -c:v huffyuv capture.mkv
결과 :
화면 1 : 무손실 모드의 H264
화면 2 : Huffyuv
화면을 기반으로 한 huffyuv
완벽한 무손실 코덱은 h264
여기에서 무언가를 압축 하는 반면 무손실 모드로 설정 해야하는 이유를 이해할 수 없습니다.
(huffyuv는 데스크톱의 비트 맵 스크린 샷과 동일합니다. h264와 동일합니다.)
누군가 나를 알아낼 수 있습니까?
편집 : 의견에 필요한대로 ffmpeg 덤프 추가;)
h264 실행 :
ffmpeg -f dshow -i video="screen-capture-recorder" -video_size 1920x1080 -framerate 30 -c:v libx264 -qp 0 -preset ultrafast capture.mkv
ffmpeg version N-73411-g5233f25 Copyright (c) 2000-2015 the FFmpeg developers
built with gcc 4.9.2 (GCC)
configuration: --arch=x86_64 --target-os=mingw32 --cross-prefix=/home/user/san
dbox/mingw-w64-x86_64/bin/x86_64-w64-mingw32- --pkg-config=pkg-config --enable-g
pl --enable-libsoxr --enable-fontconfig --enable-libass --enable-libutvideo --en
able-libbluray --enable-iconv --enable-libtwolame --extra-cflags=-DLIBTWOLAME_ST
ATIC --enable-libzvbi --enable-libcaca --enable-libmodplug --extra-libs=-lstdc++
--extra-libs=-lpng --enable-libvidstab --enable-libx265 --enable-decklink --ext
ra-libs=-loleaut32 --enable-libx264 --enable-libxvid --enable-libmp3lame --enabl
e-version3 --enable-zlib --enable-librtmp --enable-libvorbis --enable-libtheora
--enable-libspeex --enable-libopenjpeg --enable-gnutls --enable-libgsm --enable-
libfreetype --enable-libopus --disable-w32threads --enable-frei0r --enable-filte
r=frei0r --enable-libvo-aacenc --enable-bzlib --enable-libxavs --enable-libopenc
ore-amrnb --enable-libopencore-amrwb --enable-libvo-amrwbenc --enable-libschroed
inger --enable-libvpx --enable-libilbc --enable-libwavpack --enable-libwebp --en
able-libgme --enable-dxva2 --enable-libdcadec --enable-avisynth --enable-static
--disable-shared --extra-cflags= --prefix=/home/user/sandbox/mingw-w64-x86_64/x8
6_64-w64-mingw32 --extra-libs=-lpsapi --enable-nonfree --enable-libfdk-aac --dis
able-libfaac --enable-nvenc --enable-runtime-cpudetect
libavutil 54. 28.100 / 54. 28.100
libavcodec 56. 46.101 / 56. 46.101
libavformat 56. 40.100 / 56. 40.100
libavdevice 56. 4.100 / 56. 4.100
libavfilter 5. 20.100 / 5. 20.100
libswscale 3. 1.101 / 3. 1.101
libswresample 1. 2.100 / 1. 2.100
libpostproc 53. 3.100 / 53. 3.100
leaving aero onInput #0, dshow, from 'video=screen-capture-recorder':
Duration: N/A, start: 362931.503000, bitrate: N/A
Stream #0:0: Video: rawvideo, bgr0, 1920x1080, 30 tbr, 10000k tbn, 30 tbc
No pixel format specified, yuv444p for H.264 encoding chosen.
Use -pix_fmt yuv420p for compatibility with outdated media players.
[libx264 @ 00000000004c7e00] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2
AVX FMA3 AVX2 LZCNT BMI2
[libx264 @ 00000000004c7e00] profile High 4:4:4 Predictive, level 4.0, 4:4:4 8-b
it
[libx264 @ 00000000004c7e00] 264 - core 144 r2533 c8a773e - H.264/MPEG-4 AVC cod
ec - Copyleft 2003-2015 - http://www.videolan.org/x264.html - options: cabac=0 r
ef=1 deblock=0:0:0 analyse=0:0 me=dia subme=0 psy=0 mixed_ref=0 me_range=16 chro
ma_me=1 trellis=0 8x8dct=0 cqm=0 deadzone=21,11 fast_pskip=0 chroma_qp_offset=0
threads=6 lookahead_threads=1 sliced_threads=0 nr=0 decimate=1 interlaced=0 blur
ay_compat=0 constrained_intra=0 bframes=0 weightp=0 keyint=250 keyint_min=25 sce
necut=0 intra_refresh=0 rc=cqp mbtree=0 qp=0
Output #0, matroska, to 'capture.mkv':
Metadata:
encoder : Lavf56.40.100
Stream #0:0: Video: h264 (libx264) (H264 / 0x34363248), yuv444p, 1920x1080,
q=-1--1, 30 fps, 1k tbn, 30 tbc
Metadata:
encoder : Lavc56.46.101 libx264
Stream mapping:
Stream #0:0 -> #0:0 (rawvideo (native) -> h264 (libx264))
Press [q] to stop, [?] for help
frame= 11 fps=0.0 q=0.0 size= 2421kB time=00:00:00.20 bitrate=99163.6kbits/
frame= 22 fps= 22 q=0.0 size= 2538kB time=00:00:00.73 bitrate=28368.6kbits/
frame= 33 fps= 22 q=0.0 size= 2647kB time=00:00:01.26 bitrate=17116.4kbits/
frame= 46 fps= 23 q=0.0 size= 2770kB time=00:00:01.80 bitrate=12608.4kbits/
frame= 58 fps= 23 q=0.0 size= 2842kB time=00:00:02.23 bitrate=10427.1kbits/
frame= 71 fps= 23 q=0.0 size= 2908kB time=00:00:02.80 bitrate=8508.6kbits/s
frame= 83 fps= 23 q=0.0 size= 2977kB time=00:00:03.26 bitrate=7467.0kbits/s
frame= 96 fps= 24 q=0.0 size= 3085kB time=00:00:03.80 bitrate=6649.8kbits/s
frame= 108 fps= 24 q=0.0 size= 3195kB time=00:00:04.30 bitrate=6084.5kbits/s
frame= 120 fps= 24 q=0.0 size= 3309kB time=00:00:04.80 bitrate=5645.8kbits/s
frame= 133 fps= 24 q=0.0 size= 3398kB time=00:00:05.33 bitrate=5219.0kbits/s
frame= 147 fps= 24 q=0.0 size= 3492kB time=00:00:05.86 bitrate=4876.1kbits/s
frame= 160 fps= 24 q=0.0 size= 3568kB time=00:00:06.36 bitrate=4591.4kbits/s
frame= 173 fps= 24 q=0.0 size= 3660kB time=00:00:06.86 bitrate=4366.2kbits/s
frame= 186 fps= 25 q=0.0 size= 3720kB time=00:00:07.36 bitrate=4136.5kbits/s
frame= 187 fps= 24 q=-1.0 Lsize= 3737kB time=00:00:07.63 bitrate=4010.9kbits
/s
video:3735kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing
overhead: 0.052628%
[libx264 @ 00000000004c7e00] frame I:1 Avg QP: 0.00 size:1345491
[libx264 @ 00000000004c7e00] frame P:186 Avg QP: 0.00 size: 13327
[libx264 @ 00000000004c7e00] mb I I16..4: 100.0% 0.0% 0.0%
[libx264 @ 00000000004c7e00] mb P I16..4: 16.5% 0.0% 0.0% P16..4: 0.3% 0.0
% 0.0% 0.0% 0.0% skip:83.3%
[libx264 @ 00000000004c7e00] coded y,u,v intra: 6.1% 3.8% 3.9% inter: 0.2% 0.1%
0.1%
[libx264 @ 00000000004c7e00] i16 v,h,dc,p: 96% 4% 0% 0%
[libx264 @ 00000000004c7e00] kb/s:4008.11
[dshow @ 00000000004bf760] real-time buffer [screen-capture-recorder] [video inp
ut] too full or near too full (545% of size: 3041280 [rtbufsize parameter])! fra
me dropped!
Exiting normally, received signal 2.
Terminate batch job (Y/N)?
huuffyuv 실행 :
ffmpeg -f dshow -i video="screen-capture-recorder" -video_size 1920x1080 -framerate 30 -c:v huffyuv capture.mkv
ffmpeg version N-73411-g5233f25 Copyright (c) 2000-2015 the FFmpeg developers
built with gcc 4.9.2 (GCC)
configuration: --arch=x86_64 --target-os=mingw32 --cross-prefix=/home/user/san
dbox/mingw-w64-x86_64/bin/x86_64-w64-mingw32- --pkg-config=pkg-config --enable-g
pl --enable-libsoxr --enable-fontconfig --enable-libass --enable-libutvideo --en
able-libbluray --enable-iconv --enable-libtwolame --extra-cflags=-DLIBTWOLAME_ST
ATIC --enable-libzvbi --enable-libcaca --enable-libmodplug --extra-libs=-lstdc++
--extra-libs=-lpng --enable-libvidstab --enable-libx265 --enable-decklink --ext
ra-libs=-loleaut32 --enable-libx264 --enable-libxvid --enable-libmp3lame --enabl
e-version3 --enable-zlib --enable-librtmp --enable-libvorbis --enable-libtheora
--enable-libspeex --enable-libopenjpeg --enable-gnutls --enable-libgsm --enable-
libfreetype --enable-libopus --disable-w32threads --enable-frei0r --enable-filte
r=frei0r --enable-libvo-aacenc --enable-bzlib --enable-libxavs --enable-libopenc
ore-amrnb --enable-libopencore-amrwb --enable-libvo-amrwbenc --enable-libschroed
inger --enable-libvpx --enable-libilbc --enable-libwavpack --enable-libwebp --en
able-libgme --enable-dxva2 --enable-libdcadec --enable-avisynth --enable-static
--disable-shared --extra-cflags= --prefix=/home/user/sandbox/mingw-w64-x86_64/x8
6_64-w64-mingw32 --extra-libs=-lpsapi --enable-nonfree --enable-libfdk-aac --dis
able-libfaac --enable-nvenc --enable-runtime-cpudetect
libavutil 54. 28.100 / 54. 28.100
libavcodec 56. 46.101 / 56. 46.101
libavformat 56. 40.100 / 56. 40.100
libavdevice 56. 4.100 / 56. 4.100
libavfilter 5. 20.100 / 5. 20.100
libswscale 3. 1.101 / 3. 1.101
libswresample 1. 2.100 / 1. 2.100
libpostproc 53. 3.100 / 53. 3.100
leaving aero onInput #0, dshow, from 'video=screen-capture-recorder':
Duration: N/A, start: 362514.497000, bitrate: N/A
Stream #0:0: Video: rawvideo, bgr0, 1920x1080, 30 tbr, 10000k tbn, 30 tbc
[huffyuv @ 0000000000380ae0] using huffyuv 2.2.0 or newer interlacing flag
[huffyuv @ 0000000000377280] using huffyuv 2.2.0 or newer interlacing flag
[huffyuv @ 00000000003b0fc0] using huffyuv 2.2.0 or newer interlacing flag
[huffyuv @ 00000000003b1700] using huffyuv 2.2.0 or newer interlacing flag
[huffyuv @ 0000000000357a00] using huffyuv 2.2.0 or newer interlacing flag
Output #0, matroska, to 'capture.mkv':
Metadata:
encoder : Lavf56.40.100
Stream #0:0: Video: huffyuv (HFYU / 0x55594648), rgb24, 1920x1080, q=2-31, 2
00 kb/s, 30 fps, 1k tbn, 30 tbc
Metadata:
encoder : Lavc56.46.101 huffyuv
Stream mapping:
Stream #0:0 -> #0:0 (rawvideo (native) -> huffyuv (native))
Press [q] to stop, [?] for help
frame= 12 fps=0.0 q=0.0 size= 23668kB time=00:00:00.50 bitrate=386999.4kbits
frame= 22 fps= 22 q=0.0 size= 44696kB time=00:00:00.96 bitrate=379033.1kbits
frame= 35 fps= 23 q=0.0 size= 72074kB time=00:00:01.46 bitrate=402750.2kbits
frame= 49 fps= 24 q=0.0 size= 101620kB time=00:00:02.00 bitrate=416236.4kbits
frame= 63 fps= 25 q=0.0 size= 131190kB time=00:00:02.50 bitrate=429712.0kbits
frame= 78 fps= 26 q=0.0 size= 162896kB time=00:00:03.03 bitrate=439829.0kbits
frame= 83 fps= 26 q=0.0 Lsize= 175587kB time=00:00:03.23 bitrate=444776.1kbit
s/s
video:175582kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxin
g overhead: 0.002479%
[dshow @ 000000000034f420] real-time buffer [screen-capture-recorder] [video inp
ut] too full or near too full (545% of size: 3041280 [rtbufsize parameter])! fra
me dropped!
Exiting normally, received signal 2.
Terminate batch job (Y/N)?
참고 : 일반적인 목적으로 답변을 수락하더라도 @ paul-b-mahol에서 제공하는 단독 흡입을 libx264rgb 인코더 와 함께 사용하는 경향이 있습니다 .
ffmpeg
명령 에서 완전한 콘솔 출력을 표시해야합니다 .