我已经尝试了所有方法,但还是无法让它工作:我试图将 .mkv AVC 视频转换为带有 HEVC 编解码器的 HLS,同时创建两个 1080p 和 720p 质量的流,我给出的命令如下:
ffmpeg -i input.mkv \
-filter_complex "[0:v]split=2[v1][v2]; [v1]crop=1920:960:0:60[v1out]; [v2]scale=w=1280:h=720, crop=1280:640:0:40[v2out]" \
-map "[v1out]" -c:v:0 libx265 -tag:v:0 hvc1 -pix_fmt yuv420p -b:v:0 6M -maxrate:v:0 6M -minrate:v:0 6M -bufsize:v:0 6M -preset slow -g 48 -keyint_min 48 \
-map "[v2out]" -c:v:1 libx265 -tag:v:1 hvc1 -pix_fmt yuv420p -b:v:1 512k -maxrate:v:1 512k -minrate:v:1 512k -bufsize:v:1 512k -preset slow -g 48 -keyint_min 48 \
-map a:0 -c:a:0 aac -b:a:0 512k -ac 2 \
-map a:0 -c:a:1 aac -b:a:1 192k -ac 2 \
-f hls -hls_time 2 -hls_playlist_type vod -hls_flags independent_segments -hls_segment_type fmp4 -hls_segment_filename stream_%v/data%02d.m4s \
-master_pl_name master.m3u8 -var_stream_map "v:0,a:0 v:1,a:1" stream_%v/playlist.m3u8
VLC 可以正常播放 master.m3u8,但 Safari(版本 17.2.1)和 Google Chrome(版本 120.0.6099.199)却不行:我使用 JWPlayer Stream Tester 时出现错误 232632,Safari 只显示一个空白错误页面。我不知道为什么,也不知道还能做什么……这是 master.m3u8 的内容:
#EXTM3U
#EXT-X-VERSION:7
#EXT-X-STREAM-INF:BANDWIDTH=7163200,RESOLUTION=1920x960,CODECS="hvc1.1.4.L120.B01,mp4a.40.2"
stream_0/playlist.m3u8
#EXT-X-STREAM-INF:BANDWIDTH=774400,RESOLUTION=1280x640,CODECS="hvc1.1.4.L93.B01,mp4a.40.2"
stream_1/playlist.m3u8
我还尝试将输出设置为单个 .mp4 文件(保留除 hls 部分之外的所有设置),并且两个浏览器都可以正常播放它,结果如下。
这些是我从 MediaInfo 获得的有关此 mp4 文件的信息:
Generale
Nome completo : C:\Users\itzam\Videos\CONVERSIONI_HLS_final\test\output2.mp4
Formato : MPEG-4
Profilo formato : Base Media
ID codec : isom (isom/iso2/mp41)
Dimensione file : 22,8 MiB
Durata : 27s 609ms
Modo bitrate generale : Variabile
Bitrate totale : 6.933 kb/s
Frequenza fotogrammi : 29,970 fps
Creato con : Lavf60.16.100
Video #1
ID : 1
Formato : HEVC
Formato/Informazioni : High Efficiency Video Coding
Profilo formato : Main@L4@Main
ID codec : hvc1
ID codec/Informazioni : High Efficiency Video Coding
Durata : 27s 561ms
Bitrate : 6.000 kb/s
Larghezza : 1.920 pixel
Altezza : 960 pixel
Rapporto aspetto visualizzazione : 2,000
Modalità frame rate : Costante
Frequenza fotogrammi : 29,970 (30000/1001) fps
Spazio colore : YUV
Sottocampionamento croma : 4:2:0 (Type 0)
Profondità bit : 8 bit
Tipo scansione : Progressivo
Bit/(pixel*frame) : 0.109
Dimensione traccia : 19,7 MiB (86%)
Compressore : x265 3.5+113-8787af124:[Windows][GCC 13.2.0][64 bit] 8bit+10bit+12bit
Impostazioni compressione : cpuid=1111039 / frame-threads=4 / numa-pools=16 / wpp / no-pmode / no-pme / no-psnr / no-ssim / log-level=2 / input-csp=1 / input-res=1920x960 / interlace=0 / total-frames=0 / level-idc=0 / high-tier=1 / uhd-bd=0 / ref=4 / no-allow-non-conformance / no-repeat-headers / annexb / no-aud / no-eob / no-eos / no-hrd / info / hash=0 / temporal-layers=0 / open-gop / min-keyint=48 / keyint=48 / gop-lookahead=0 / bframes=4 / b-adapt=2 / b-pyramid / bframe-bias=0 / rc-lookahead=25 / lookahead-slices=4 / scenecut=40 / no-hist-scenecut / radl=0 / no-splice / no-intra-refresh / ctu=64 / min-cu-size=8 / rect / no-amp / max-tu-size=32 / tu-inter-depth=1 / tu-intra-depth=1 / limit-tu=0 / rdoq-level=2 / dynamic-rd=0.00 / no-ssim-rd / signhide / no-tskip / nr-intra=0 / nr-inter=0 / no-constrained-intra / strong-intra-smoothing / max-merge=3 / limit-refs=3 / limit-modes / me=3 / subme=3 / merange=57 / temporal-mvp / no-frame-dup / no-hme / weightp / no-weightb / no-analyze-src-pics / deblock=0:0 / sao / no-sao-non-deblock / rd=4 / selective-sao=4 / no-early-skip / rskip / no-fast-intra / no-tskip-fast / no-cu-lossless / no-b-intra / no-splitrd-skip / rdpenalty=0 / psy-rd=2.00 / psy-rdoq=1.00 / no-rd-refine / no-lossless / cbqpoffs=0 / crqpoffs=0 / rc=cbr / bitrate=6000 / qcomp=0.60 / qpstep=4 / stats-write=0 / stats-read=0 / vbv-maxrate=6000 / vbv-bufsize=6000 / vbv-init=0.8 / min-vbv-fullness=50.0 / max-vbv-fullness=80.0 / ipratio=1.40 / pbratio=1.30 / aq-mode=2 / aq-strength=1.00 / cutree / zone-count=0 / no-strict-cbr / qg-size=32 / no-rc-grain / qpmax=69 / qpmin=0 / no-const-vbv / sar=1 / overscan=0 / videoformat=5 / range=0 / colorprim=2 / transfer=2 / colormatrix=2 / chromaloc=1 / chromaloc-top=0 / chromaloc-bottom=0 / display-window=0 / cll=0,0 / min-luma=0 / max-luma=255 / log2-max-poc-lsb=8 / vui-timing-info / vui-hrd-info / slices=1 / no-opt-qp-pps / no-opt-ref-list-length-pps / no-multi-pass-opt-rps / scenecut-bias=0.05 / no-opt-cu-delta-qp / no-aq-motion / no-hdr10 / no-hdr10-opt / no-dhdr10-opt / no-idr-recovery-sei / analysis-reuse-level=0 / analysis-save-reuse-level=0 / analysis-load-reuse-level=0 / scale-factor=0 / refine-intra=0 / refine-inter=0 / refine-mv=1 / refine-ctu-distortion=0 / no-limit-sao / ctu-info=0 / no-lowpass-dct / refine-analysis-type=0 / copy-pic=1 / max-ausize-factor=1.0 / no-dynamic-refine / no-single-sei / no-hevc-aq / no-svt / no-field / qp-adaptation-range=1.00 / scenecut-aware-qp=0conformance-window-offsets / right=0 / bottom=0 / decoder-max-rate=0 / no-vbv-live-multi-pass / no-mcstf / no-sbrc
Intervallo colore : Limited
Casella configurazione codec : hvcC
Video #2
ID : 2
Formato : HEVC
Formato/Informazioni : High Efficiency Video Coding
Profilo formato : [email protected]@Main
ID codec : hvc1
ID codec/Informazioni : High Efficiency Video Coding
Durata : 27s 561ms
Bitrate : 512 kb/s
Larghezza : 1.280 pixel
Altezza : 640 pixel
Rapporto aspetto visualizzazione : 2,000
Modalità frame rate : Costante
Frequenza fotogrammi : 29,970 (30000/1001) fps
Spazio colore : YUV
Sottocampionamento croma : 4:2:0 (Type 0)
Profondità bit : 8 bit
Tipo scansione : Progressivo
Bit/(pixel*frame) : 0.021
Dimensione traccia : 1,68 MiB (7%)
Compressore : x265 3.5+113-8787af124:[Windows][GCC 13.2.0][64 bit] 8bit+10bit+12bit
Impostazioni compressione : cpuid=1111039 / frame-threads=4 / numa-pools=16 / wpp / no-pmode / no-pme / no-psnr / no-ssim / log-level=2 / input-csp=1 / input-res=1280x640 / interlace=0 / total-frames=0 / level-idc=0 / high-tier=1 / uhd-bd=0 / ref=4 / no-allow-non-conformance / no-repeat-headers / annexb / no-aud / no-eob / no-eos / no-hrd / info / hash=0 / temporal-layers=0 / open-gop / min-keyint=48 / keyint=48 / gop-lookahead=0 / bframes=4 / b-adapt=2 / b-pyramid / bframe-bias=0 / rc-lookahead=25 / lookahead-slices=0 / scenecut=40 / no-hist-scenecut / radl=0 / no-splice / no-intra-refresh / ctu=64 / min-cu-size=8 / rect / no-amp / max-tu-size=32 / tu-inter-depth=1 / tu-intra-depth=1 / limit-tu=0 / rdoq-level=2 / dynamic-rd=0.00 / no-ssim-rd / signhide / no-tskip / nr-intra=0 / nr-inter=0 / no-constrained-intra / strong-intra-smoothing / max-merge=3 / limit-refs=3 / limit-modes / me=3 / subme=3 / merange=57 / temporal-mvp / no-frame-dup / no-hme / weightp / no-weightb / no-analyze-src-pics / deblock=0:0 / sao / no-sao-non-deblock / rd=4 / selective-sao=4 / no-early-skip / rskip / no-fast-intra / no-tskip-fast / no-cu-lossless / no-b-intra / no-splitrd-skip / rdpenalty=0 / psy-rd=2.00 / psy-rdoq=1.00 / no-rd-refine / no-lossless / cbqpoffs=0 / crqpoffs=0 / rc=cbr / bitrate=512 / qcomp=0.60 / qpstep=4 / stats-write=0 / stats-read=0 / vbv-maxrate=512 / vbv-bufsize=512 / vbv-init=0.8 / min-vbv-fullness=50.0 / max-vbv-fullness=80.0 / ipratio=1.40 / pbratio=1.30 / aq-mode=2 / aq-strength=1.00 / cutree / zone-count=0 / no-strict-cbr / qg-size=32 / no-rc-grain / qpmax=69 / qpmin=0 / no-const-vbv / sar=1 / overscan=0 / videoformat=5 / range=0 / colorprim=2 / transfer=2 / colormatrix=2 / chromaloc=1 / chromaloc-top=0 / chromaloc-bottom=0 / display-window=0 / cll=0,0 / min-luma=0 / max-luma=255 / log2-max-poc-lsb=8 / vui-timing-info / vui-hrd-info / slices=1 / no-opt-qp-pps / no-opt-ref-list-length-pps / no-multi-pass-opt-rps / scenecut-bias=0.05 / no-opt-cu-delta-qp / no-aq-motion / no-hdr10 / no-hdr10-opt / no-dhdr10-opt / no-idr-recovery-sei / analysis-reuse-level=0 / analysis-save-reuse-level=0 / analysis-load-reuse-level=0 / scale-factor=0 / refine-intra=0 / refine-inter=0 / refine-mv=1 / refine-ctu-distortion=0 / no-limit-sao / ctu-info=0 / no-lowpass-dct / refine-analysis-type=0 / copy-pic=1 / max-ausize-factor=1.0 / no-dynamic-refine / no-single-sei / no-hevc-aq / no-svt / no-field / qp-adaptation-range=1.00 / scenecut-aware-qp=0conformance-window-offsets / right=0 / bottom=0 / decoder-max-rate=0 / no-vbv-live-multi-pass / no-mcstf / no-sbrc
Predefinito : No
Gruppo alternativo : 1
Intervallo colore : Limited
Casella configurazione codec : hvcC
Audio #1
ID : 3
Formato : AAC LC
Formato/Informazioni : Advanced Audio Codec Low Complexity
ID codec : mp4a-40-2
Durata : 27s 609ms
Durata sorgente : 27s 632ms
Modalità bitrate : Variabile
Bitrate : 234 kb/s
Bitrate massimo : 512 kb/s
Canali : 2 canali
Layout canale : L R
Frequenza campionamento : 44,1 KHz
Frequenza fotogrammi : 43,066 fps (1024 SPF)
Modo compressione : Con perdita
Dimensione traccia : 788 KiB (3%)
Dim. flusso sorgente : 788 KiB (3%)
Predefinito : Si
Gruppo alternativo : 2
Audio #2
ID : 4
Formato : AAC LC
Formato/Informazioni : Advanced Audio Codec Low Complexity
ID codec : mp4a-40-2
Durata : 27s 609ms
Durata sorgente : 27s 632ms
Modalità bitrate : Costante
Bitrate : 192 kb/s
Canali : 2 canali
Layout canale : L R
Frequenza campionamento : 44,1 KHz
Frequenza fotogrammi : 43,066 fps (1024 SPF)
Modo compressione : Con perdita
Dimensione traccia : 646 KiB (3%)
Dim. flusso sorgente : 646 KiB (3%)
Predefinito : Si
Gruppo alternativo : 3
有人能帮助我了解哪里出了问题吗?