xlmnxp / blue-recorder

Simple Screen Recorder written in Rust based on Green Recorder
Other
498 stars 27 forks source link

Output file size #61

Open kwyxz opened 5 months ago

kwyxz commented 5 months ago

Greetings,

First of all thank you for the amazing tool that is Blue Recorder, very nice and easy to use.

I have noticed that the captured files end up being on the bigger side. Someone mentions in https://github.com/xlmnxp/blue-recorder/issues/32 that GIF for example are much larger than when using Peek.

But I have also noticed that MP4 files are several times bigger than they could. A sample capture, when run into ffmpeg just once with zero specific option, is shrunk by almost 4 times with no visible difference in quality. It seems to be a bitrate issue. Sample capture is called myvideo.mp4 :

$ ffmpeg -i myvideo.mp4 myvideo-small.mp4
ffmpeg version 5.1.2 Copyright (c) 2000-2022 the FFmpeg developers
  built with gcc 11 (GCC)
  configuration: --prefix=/usr --bindir=/usr/bin --datadir=/usr/share/ffmpeg --docdir=/usr/share/doc/ffmpeg --incdir=/usr/include/ffmpeg --libdir=/usr/lib64 --mandir=/usr/share/man --arch=x86_64 --optflags='-O2 -flto=auto -ffat-lto-objects -fexceptions -g -grecord-gcc-switches -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -fstack-protector-strong -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -m64 -march=x86-64-v2 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection' --extra-ldflags='-Wl,-z,relro -Wl,--as-needed -Wl,-z,now -specs=/usr/lib/rpm/redhat/redhat-hardened-ld -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 ' --extra-cflags=' -I/usr/include/rav1e' --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libvo-amrwbenc --enable-version3 --enable-bzlib --enable-chromaprint --disable-crystalhd --enable-fontconfig --enable-frei0r --enable-gcrypt --enable-gnutls --enable-ladspa --enable-libaom --enable-libdav1d --enable-libass --enable-libbluray --enable-libbs2b --enable-libcdio --enable-libdrm --enable-libjack --enable-libjxl --enable-libfreetype --enable-libfribidi --enable-libgsm --enable-libilbc --enable-libmp3lame --enable-libmysofa --enable-nvenc --enable-openal --enable-opencl --enable-opengl --enable-libopenjpeg --enable-libopenmpt --enable-libopus --enable-libpulse --enable-librsvg --enable-librav1e --enable-librubberband --enable-libsmbclient --enable-version3 --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libsrt --enable-libssh --enable-libsvtav1 --enable-libtesseract --enable-libtheora --enable-libtwolame --enable-libvorbis --enable-libv4l2 --enable-libvidstab --enable-libvmaf --enable-version3 --enable-vapoursynth --enable-libvpx --enable-vulkan --enable-libshaderc --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxvid --enable-libxml2 --enable-libzimg --enable-libzmq --enable-libzvbi --enable-lv2 --enable-avfilter --enable-libmodplug --enable-postproc --enable-pthreads --disable-static --enable-shared --enable-gpl --disable-debug --disable-stripping --shlibdir=/usr/lib64 --enable-lto --enable-libmfx --enable-runtime-cpudetect
  libavutil      57. 28.100 / 57. 28.100
  libavcodec     59. 37.100 / 59. 37.100
  libavformat    59. 27.100 / 59. 27.100
  libavdevice    59.  7.100 / 59.  7.100
  libavfilter     8. 44.100 /  8. 44.100
  libswscale      6.  7.100 /  6.  7.100
  libswresample   4.  7.100 /  4.  7.100
  libpostproc    56.  6.100 / 56.  6.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'myvideo.mp4':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2avc1mp41
    encoder         : Lavf60.3.100
  Duration: 00:00:07.50, start: 0.000000, bitrate: 2276 kb/s
  Stream #0:0[0x1](und): Video: h264 (High 4:4:4 Predictive) (avc1 / 0x31637661), yuv444p(progressive), 3840x1200, 2274 kb/s, 10 fps, 10 tbr, 10240 tbn (default)
    Metadata:
      handler_name    : VideoHandler
      vendor_id       : [0][0][0][0]
      encoder         : Lavc60.3.100 libx264
Stream mapping:
  Stream #0:0 -> #0:0 (h264 (native) -> h264 (libx264))
Press [q] to stop, [?] for help
[libx264 @ 0x561a2a26b2c0] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX FMA3 BMI2 AVX2 AVX512
[libx264 @ 0x561a2a26b2c0] profile High 4:4:4 Predictive, level 5.0, 4:4:4, 8-bit
[libx264 @ 0x561a2a26b2c0] 264 - core 163 r3060 5db6aa6 - H.264/MPEG-4 AVC codec - Copyleft 2003-2021 - http://www.videolan.org/x264.html - options: cabac=1 ref=3 deblock=1:0:0 analyse=0x3:0x113 me=hex subme=7 psy=1 psy_rd=1.00:0.00 mixed_ref=1 me_range=16 chroma_me=1 trellis=1 8x8dct=1 cqm=0 deadzone=21,11 fast_pskip=1 chroma_qp_offset=4 threads=37 lookahead_threads=6 sliced_threads=0 nr=0 decimate=1 interlaced=0 bluray_compat=0 constrained_intra=0 bframes=3 b_pyramid=2 b_adapt=1 b_bias=0 direct=1 weightb=1 open_gop=0 weightp=2 keyint=250 keyint_min=10 scenecut=40 intra_refresh=0 rc_lookahead=40 rc=crf mbtree=1 crf=23.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 ip_ratio=1.40 aq=1:1.00
Output #0, mp4, to 'myvideo-small.mp4':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2avc1mp41
    encoder         : Lavf59.27.100
  Stream #0:0(und): Video: h264 (avc1 / 0x31637661), yuv444p(progressive), 3840x1200, q=2-31, 10 fps, 10240 tbn (default)
    Metadata:
      handler_name    : VideoHandler
      vendor_id       : [0][0][0][0]
      encoder         : Lavc59.37.100 libx264
    Side data:
      cpb: bitrate max/min/avg: 0/0/0 buffer size: 0 vbv_delay: N/A
frame=   75 fps= 50 q=-1.0 Lsize=     688kB time=00:00:07.20 bitrate= 783.3kbits/s speed=4.81x    
video:687kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.250418%
[libx264 @ 0x561a2a26b2c0] frame I:1     Avg QP:14.02  size:472311
[libx264 @ 0x561a2a26b2c0] frame P:19    Avg QP:13.43  size: 10780
[libx264 @ 0x561a2a26b2c0] frame B:55    Avg QP:24.68  size:   462
[libx264 @ 0x561a2a26b2c0] consecutive B-frames:  1.3%  2.7%  0.0% 96.0%
[libx264 @ 0x561a2a26b2c0] mb I  I16..4: 25.9% 42.7% 31.4%
[libx264 @ 0x561a2a26b2c0] mb P  I16..4:  1.0%  0.4%  0.7%  P16..4:  3.2%  0.3%  0.2%  0.0%  0.0%    skip:94.2%
[libx264 @ 0x561a2a26b2c0] mb B  I16..4:  0.1%  0.1%  0.0%  B16..8:  1.6%  0.0%  0.0%  direct: 0.0%  skip:98.2%  L0:43.3% L1:56.4% BI: 0.2%
[libx264 @ 0x561a2a26b2c0] 8x8 transform intra:36.2% inter:81.5%
[libx264 @ 0x561a2a26b2c0] coded y,u,v intra: 33.6% 13.3% 15.9% inter: 0.2% 0.1% 0.2%
[libx264 @ 0x561a2a26b2c0] i16 v,h,dc,p: 36% 62%  1%  1%
[libx264 @ 0x561a2a26b2c0] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 47% 15% 24%  2%  3%  2%  3%  2%  3%
[libx264 @ 0x561a2a26b2c0] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 35% 28% 13%  3%  4%  4%  5%  3%  4%
[libx264 @ 0x561a2a26b2c0] Weighted P-Frames: Y:0.0% UV:0.0%
[libx264 @ 0x561a2a26b2c0] ref P L0: 74.9%  1.8% 20.3%  3.0%
[libx264 @ 0x561a2a26b2c0] ref B L0: 65.3% 32.2%  2.5%
[libx264 @ 0x561a2a26b2c0] ref B L1: 94.8%  5.2%
[libx264 @ 0x561a2a26b2c0] kb/s:749.37

$ ls -lh myvideo*
-rw-r--r-- 1 kwyxz kwyxz 2.1M Feb  9 14:45 myvideo.mp4
-rw-r--r-- 1 kwyxz kwyxz 689K Feb  9 15:43 myvideo-small.mp4

The original video has a 2274 kb/s bitrate, which is quite a lot for a screen capture. The recompressed one has a 750 kb/s bitrate.

Is there anything that can be done within Blue Recorder to deal with these big file sizes? Maybe allowing the user to select between various bitrates, as suggested in https://github.com/xlmnxp/blue-recorder/issues/55?

Thank you very much for your assistance, Cheers