libx265 & ffmpeg : 더 나은 압축, 더 큰 파일?


0

마지막 비트를 쥐어 짜려고 노력하면서 파일이 커지거나 작아지는 것을 발견했습니다. 불행히도 일부 매개 변수를 잘못 해석해야합니다.

어쩌면 당신이 나를 도울 수 있습니다.

참조는 -preset placebo다음과 같습니다

ffmpeg -y -hide_banner -i <input.mp4> \
       [... audio ...] \
       -pix_fmt yuv420p \
       -preset placebo \
       -crf 30 \
       -codec:v libx265 \
       -f mp4 \
       -movflags +faststart+disable_chpl \
       <output.mp4>

결과 파일 크기는 130.780.586 바이트입니다.

그런 다음 설명서를 읽고 매개 변수의 의미를 이해하려고했습니다.

나중에 나는 사용했다

ffmpeg -y -hide_banner -i <input.mp4>  \
       [... audio ...] \
       -pix_fmt yuv420p \
       -preset placebo \
       -crf 30 \
       -x265-params "ssim=0:psnr=0:frame-threads=1:pools=*:wpp=0:pmode=0:pme=0:slices=1:copy-pic=1:level-idc=0:high-tier=1:ref=6:allow-non-conformance=0:uhd-bd=0:rd=6:ctu=64:min-cu-size=8:limit-refs=0:limit-modes=0:rect=0:amp=0:early-skip=0:rskip=0:splitrd-skip=0:fast-intra=0:b-intra=1:cu-lossless=1:tskip-fast=0:rd-refine=1:rdoq-level=1:tu-intra-depth=4:tu-inter-depth=4:limit-tu=0:nr-intra=0:tskip=0:rdpenalty=0:max-tu-size=32:dynamic-rd=0:ssim-rd=1:max-merge=5:me=full:subme=7:merange=32767:temporal-mvp=1:weightp=1:weightb=1:analyze-src-pics=1:strong-intra-smoothing=1:constrained-intra=0:psy-rd=2.0:psy-rdoq=1.0:open-gop=1:keyint=15000:min-keyint=2:scenecut=40:scenecut-bias=5:ctu-info=0:intra-refresh=0:rc-lookahead=250:lookahead-slices=0:lookahead-threads=0:b-adapt=2:bframes=16:bframe-bias=0:b-pyramid=1:force-flush=0:crf-max=51.0:crf-min=0.0:vbv-bufsize=0:vbv-maxrate=0:vbv-init=0.0:vbv-end=0.0:vbv-end-fr-adj=0:lossless=0:aq-mode=3:aq-strength=1.0:aq-motion=1:qg-size=8:cutree=1:strict-cbr=0:signhide=1:sao=1:sao-non-deblock=0:limit-sao=0:opt-qp-pps=1:opt-ref-list-length-pps=1:opt-cu-delta-qp=1" \
       -codec:v libx265 \
       -f mp4 \
       -movflags +faststart+disable_chpl \
       <output.mp4>

결과 파일 크기는 300.468.224 바이트입니다.

분명히 시각적 품질이 더 좋습니다. 그러나 나는 그것이 일정해야한다고 생각했습니다 -crf 30. 증가하여 가변 비트 전송률을 줄여야 -crf합니까?

가독성을 높이기 위해 매개 변수를 다시 :

-x265-params "
  ssim=0:
  psnr=0:
  frame-threads=1:
  pools=*:
  wpp=0:
  pmode=0:
  pme=0:
  slices=1:
  copy-pic=1:
  level-idc=0:
  high-tier=1:
  ref=6:
  allow-non-conformance=0:
  uhd-bd=0:
  rd=6:
  ctu=64:
  min-cu-size=8:
  limit-refs=0:
  limit-modes=0:
  rect=0:amp=0:
  early-skip=0:
  rskip=0:
  splitrd-skip=0:
  fast-intra=0:
  b-intra=1:
  cu-lossless=1:
  tskip-fast=0:
  rd-refine=1:
  rdoq-level=1:
  tu-intra-depth=4:
  tu-inter-depth=4:
  limit-tu=0:
  nr-intra=0:
  tskip=0:
  rdpenalty=0:
  max-tu-size=32:
  dynamic-rd=0:
  ssim-rd=1:
  max-merge=5:
  me=full:
  subme=7:
  merange=32767:
  temporal-mvp=1:
  weightp=1:
  weightb=1:
  analyze-src-pics=1:
  strong-intra-smoothing=1:
  constrained-intra=0:
  psy-rd=2.0:
  psy-rdoq=1.0:
  open-gop=1:
  keyint=15000:
  min-keyint=2:
  scenecut=40:
  scenecut-bias=5:
  ctu-info=0:
  intra-refresh=0:
  rc-lookahead=250:
  lookahead-slices=0:
  lookahead-threads=0:
  b-adapt=2:
  bframes=16:
  bframe-bias=0:
  b-pyramid=1:
  force-flush=0:
  crf-max=51.0:
  crf-min=0.0:
  vbv-bufsize=0:
  vbv-maxrate=0:
  vbv-init=0.0:
  vbv-end=0.0:
  vbv-end-fr-adj=0:
  lossless=0:
  aq-mode=3:
  aq-strength=1.0:
  aq-motion=1:
  qg-size=8:
  cutree=1:
  strict-cbr=0:
  signhide=1:
  sao=1:
  sao-non-deblock=0:
  limit-sao=0:
  opt-qp-pps=1:
  opt-ref-list-length-pps=1:
  opt-cu-delta-qp=1"

의 출력 placebo실행 :

Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '<input.mp4>':
  Metadata:
    major_brand     : mp42
    minor_version   : 0
    compatible_brands: mp42mp41
    creation_time   : 2018-03-25T07:58:52.000000Z
  Duration: 00:07:03.46, start: 0.000000, bitrate: 207200 kb/s
    Stream #0:0(eng): Video: h264 (High) (avc1 / 0x31637661), yuv420p(tv, bt709), 1920x1080 [SAR 1:1 DAR 16:9], 207062 kb/s, 24 fps, 24 tbr, 24k tbn, 48 tbc (default)
    Metadata:
      creation_time   : 2018-03-25T07:58:52.000000Z
      handler_name    : ?Mainconcept Video Media Handler
      encoder         : AVC Coding
    Stream #0:1(eng): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, mono, fltp, 157 kb/s (default)
    Metadata:
      creation_time   : 2018-03-25T07:58:52.000000Z
      handler_name    : #Mainconcept MP4 Sound Media Handler
Stream mapping:
  Stream #0:0 -> #0:0 (h264 (native) -> hevc (libx265))
  Stream #0:1 -> #0:1 (aac (native) -> aac (native))
Press [q] to stop, [?] for help
x265 [info]: HEVC encoder version 2.6
x265 [info]: build info [Linux][GCC 7.2.0][64 bit] 8bit+10bit+12bit
x265 [info]: using cpu capabilities: MMX2 SSE2Fast LZCNT SSSE3 SSE4.2 AVX FMA3 BMI2 AVX2
x265 [info]: Main profile, Level-4 (Main tier)
x265 [info]: Thread pool created using 8 threads
x265 [info]: Slices                              : 1
x265 [info]: frame threads / pool features       : 3 / wpp(17 rows)
x265 [info]: Coding QT: max CU size, min CU size : 64 / 8
x265 [info]: Residual QT: max TU size, max depth : 32 / 4 inter / 4 intra
x265 [info]: ME / range / subpel / merge         : star / 92 / 5 / 5
x265 [info]: Keyframe min / max / scenecut / bias: 24 / 250 / 40 / 5.00
x265 [info]: Lookahead / bframes / badapt        : 60 / 8 / 2
x265 [info]: b-pyramid / weightp / weightb       : 1 / 1 / 1
x265 [info]: References / ref-limit  cu / depth  : 5 / off / off
x265 [info]: AQ: mode / str / qg-size / cu-tree  : 1 / 1.0 / 32 / 1
x265 [info]: Rate Control / qCompress            : CRF-30.0 / 0.60
x265 [info]: tools: rect amp rd=6 psy-rd=2.00 rdoq=2 psy-rdoq=1.00 tskip
x265 [info]: tools: signhide tmvp b-intra strong-intra-smoothing deblock sao
Output #0, mp4, to '<output.mp4>':
  Metadata:
    major_brand     : mp42
    minor_version   : 0
    compatible_brands: mp42mp41
    encoder         : Lavf57.83.100
    Stream #0:0(eng): Video: hevc (libx265) (hev1 / 0x31766568), yuv420p(progressive), 1506x1080 [SAR 1:1 DAR 251:180], q=2-31, 24 fps, 12288 tbn, 24 tbc (default)
    Metadata:
      creation_time   : 2018-03-25T07:58:52.000000Z
      handler_name    : ?Mainconcept Video Media Handler
      encoder         : Lavc57.107.100 libx265
    Stream #0:1(eng): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, mono, fltp, 48 kb/s (default)
    Metadata:
      creation_time   : 2018-03-25T07:58:52.000000Z
      handler_name    : #Mainconcept MP4 Sound Media Handler
      encoder         : Lavc57.107.100 aac
[mp4 @ 0x558418671660] Starting second pass: moving the moov atom to the beginning of the file
frame=10162 fps=0.1 q=-0.0 Lsize=  127715kB time=00:07:03.43 bitrate=2470.8kbits/s speed=0.00405x    
video:124915kB audio:2502kB subtitle:0kB other streams:0kB global headers:2kB muxing overhead: 0.233744%
x265 [info]: frame I:     58, Avg QP:32.08  kb/s: 3827.66 
x265 [info]: frame P:   1838, Avg QP:33.65  kb/s: 3792.41 
x265 [info]: frame B:   8266, Avg QP:36.26  kb/s: 2100.06 
x265 [info]: Weighted P-Frames: Y:7.0% UV:7.0%
x265 [info]: Weighted B-Frames: Y:18.1% UV:17.6%
x265 [info]: consecutive B-frames: 4.7% 3.3% 11.0% 20.1% 16.9% 12.9% 10.2% 9.7% 11.2% 

encoded 10162 frames in 104535.21s (0.10 fps), 2416.02 kb/s, Avg QP:35.76
[aac @ 0x5584186c0220] Qavg: 156.304

과장된 결과는 다음과 같습니다.

Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '<input.mp4>':
  Metadata:
    major_brand     : mp42
    minor_version   : 0
    compatible_brands: mp42mp41
    creation_time   : 2018-03-25T07:58:52.000000Z
  Duration: 00:07:03.46, start: 0.000000, bitrate: 207200 kb/s
    Stream #0:0(eng): Video: h264 (High) (avc1 / 0x31637661), yuv420p(tv, bt709), 1920x1080 [SAR 1:1 DAR 16:9], 207062 kb/s, 24 fps, 24 tbr, 24k tbn, 48 tbc (default)
    Metadata:
      creation_time   : 2018-03-25T07:58:52.000000Z
      handler_name    : ?Mainconcept Video Media Handler
      encoder         : AVC Coding
    Stream #0:1(eng): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, mono, fltp, 157 kb/s (default)
    Metadata:
      creation_time   : 2018-03-25T07:58:52.000000Z
      handler_name    : #Mainconcept MP4 Sound Media Handler
Stream mapping:
  Stream #0:0 -> #0:0 (h264 (native) -> hevc (libx265))
  Stream #0:1 -> #0:1 (aac (native) -> aac (native))
Press [q] to stop, [?] for help
x265 [info]: HEVC encoder version 2.6
x265 [info]: build info [Linux][GCC 7.2.0][64 bit] 8bit+10bit+12bit
x265 [info]: using cpu capabilities: MMX2 SSE2Fast LZCNT SSSE3 SSE4.2 AVX FMA3 BMI2 AVX2
x265 [info]: Main profile, Level-4 (Main tier)
x265 [info]: Slices                              : 1
x265 [info]: frame threads / pool features       : 1 / none
x265 [info]: Coding QT: max CU size, min CU size : 64 / 8
x265 [info]: Residual QT: max TU size, max depth : 32 / 4 inter / 4 intra
x265 [info]: ME / range / subpel / merge         : full / 32767 / 7 / 5
x265 [info]: Keyframe min / max / scenecut / bias: 2 / 15000 / 40 / 5.00
x265 [info]: Lookahead / bframes / badapt        : 250 / 16 / 2
x265 [info]: b-pyramid / weightp / weightb       : 1 / 1 / 1
x265 [info]: References / ref-limit  cu / depth  : 6 / off / off
x265 [info]: AQ: mode / str / qg-size / cu-tree  : 3 / 1.0 / 8 / 1
x265 [info]: Rate Control / qCompress            : CRF-30.0 / 0.60
x265 [info]: tools: rd=6 ssim-rd psy-rd=2.00 rdoq=1 psy-rdoq=1.00 rd-refine
x265 [info]: tools: cu-lossless signhide tmvp b-intra strong-intra-smoothing
x265 [info]: tools: deblock sao
Output #0, mp4, to '<output.mp4>':
  Metadata:
    major_brand     : mp42
    minor_version   : 0
    compatible_brands: mp42mp41
    encoder         : Lavf57.83.100
    Stream #0:0(eng): Video: hevc (libx265) (hev1 / 0x31766568), yuv420p(progressive), 1506x1080 [SAR 1:1 DAR 251:180], q=2-31, 24 fps, 12288 tbn, 24 tbc (default)
    Metadata:
      creation_time   : 2018-03-25T07:58:52.000000Z
      handler_name    : ?Mainconcept Video Media Handler
      encoder         : Lavc57.107.100 libx265
    Stream #0:1(eng): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, mono, fltp, 48 kb/s (default)
    Metadata:
      creation_time   : 2018-03-25T07:58:52.000000Z
      handler_name    : #Mainconcept MP4 Sound Media Handler
      encoder         : Lavc57.107.100 aac
[mp4 @ 0x564f7705a760] Starting second pass: moving the moov atom to the beginning of the file
frame=10162 fps=0.1 q=-0.0 Lsize=  293426kB time=00:07:03.43 bitrate=5676.7kbits/s speed=0.00402x    
video:290747kB audio:2502kB subtitle:0kB other streams:0kB global headers:2kB muxing overhead: 0.060220%
x265 [info]: frame I:     34, Avg QP:28.44  kb/s: 8462.33 
x265 [info]: frame P:   1710, Avg QP:31.95  kb/s: 6614.87 
x265 [info]: frame B:   8418, Avg QP:32.51  kb/s: 5411.77 
x265 [info]: Weighted P-Frames: Y:7.0% UV:6.8%
x265 [info]: Weighted B-Frames: Y:18.4% UV:17.2%
x265 [info]: consecutive B-frames: 5.6% 3.6% 11.8% 22.0% 17.3% 11.6% 7.3% 5.3% 2.9% 1.9% 1.5% 2.2% 0.8% 0.9% 0.7% 1.5% 2.9% 

encoded 10162 frames in 105460.05s (0.10 fps), 5624.43 kb/s, Avg QP:32.40
[aac @ 0x564f770d19e0] Qavg: 156.304

읽어 주셔서 감사합니다!

답변:


1

일반 사전 설정을 고수하는 것이 좋습니다.

모든 맞춤 매개 변수를 확인하지는 않았지만 확인했습니다 cu-lossless=1. 이것은 x265에게 CU 수준에서 옵션으로 무손실 인코딩을 평가하도록 지시합니다. 이렇게 인코딩 된 CU는 변환 / 양자화가 적용되지 않으며 엔트로피 코딩은 또한 결과적인 잔차에서 더 어려울 것이다.

또한 x265 문서는 다음과 같이 말합니다.

--psy-rd는 비트 비용보다 에너지 (세부 사항) 보존을 선호하는 RDO 결정에 영향을 미치며 더 많은 블록이 무손실로 코딩됩니다.

그리고 당신은 설정 psy-rd=2.0


주석을 염두에두고 다시 시도하겠습니다. 하지만 시간이 좀 걸릴 것입니다 ... ;-)
Thomas R.

완료 :-268.718.453 바이트-훨씬 빠름-화질이 떨어짐 (파일 크기가 더 작을 수 있음 (?))
Thomas R.
당사 사이트를 사용함과 동시에 당사의 쿠키 정책개인정보 보호정책을 읽고 이해하였음을 인정하는 것으로 간주합니다.
Licensed under cc by-sa 3.0 with attribution required.