我想使用FFmpeg直播带字幕的HLS流。 我有媒体。媒体具有一个视频轨道,两个音频轨道,四个字幕。 但是,我尝试了以下命令:
ffmpeg -i input0.mkv \
-map 0:v:0 -c:v libx264 -strict -2 -s 426x240 -f hls -hls_time 10 -hls_list_size 6 -hls_wrap 10 -hls_segment_filename video/videoTrack240p_%d.ts video/videoTrack240p.m3u8 \
-map 0:v:0 -c:v libx264 -strict -2 -s 1280x720 -f hls -hls_time 10 -hls_list_size 6 -hls_wrap 10 -hls_segment_filename video/videoTrack720p_%d.ts video/videoTrack720p.m3u8 \
-map 0:v:0 -c:v libx264 -strict -2 -s 1920x1080 -f hls -hls_time 10 -hls_list_size 6 -hls_wrap 10 -hls_segment_filename video/videoTrack1080p_%d.ts video/videoTrack1080p.m3u8 \
-map 0:a:0 -c:a aac -f hls -hls_time 10 -hls_list_size 6 -hls_wrap 10 -hls_segment_filename audio/audioTrack1_%d.aac audio/audioTrack0.m3u8 \
-map 0:a:1 -c:a aac -f hls -hls_time 10 -hls_list_size 6 -hls_wrap 10 -hls_segment_filename audio/audioTrack0_%d.aac audio/audioTrack1.m3u8 \
-map 0:s:0 -c:s webvtt -f hls -hls_time 10 -hls_list_size 6 -hls_wrap 10 -hls_segment_filename subtitle/subtitleTrack0_%d.vtt subtitle/subtitleTrack0.m3u8 \
-map 0:s:1 -c:s webvtt -f hls -hls_time 10 -hls_list_size 6 -hls_wrap 10 -hls_segment_filename subtitle/subtitleTrack1_%d.vtt subtitle/subtitleTrack1.m3u8 \
-map 0:s:2 -c:s webvtt -f hls -hls_time 10 -hls_list_size 6 -hls_wrap 10 -hls_segment_filename subtitle/subtitleTrack2_%d.vtt subtitle/subtitleTrack2.m3u8 \
-map 0:s:3 -c:s webvtt -f hls -hls_time 10 -hls_list_size 6 -hls_wrap 10 -hls_segment_filename subtitle/subtitleTrack3_%d.vtt subtitle/subtitleTrack3.m3u8
它显示此错误:
ffmpeg version 3.4.4-0ubuntu0.18.04.1 Copyright (c) 2000-2018 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
WARNING: library configuration mismatch
avcodec 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 --enable-version3 --disable-doc --disable-programs --enable-libopencore_amrnb --enable-libopencore_amrwb --enable-libtesseract --enable-libvo_amrwbenc
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
[matroska,webm @ 0x5631128c1460] Could not find codec parameters for stream 5 (Subtitle: hdmv_pgs_subtitle (pgssub)): unspecified size
Consider increasing the value for the 'analyzeduration' and 'probesize' options
[matroska,webm @ 0x5631128c1460] Could not find codec parameters for stream 6 (Subtitle: hdmv_pgs_subtitle (pgssub)): unspecified size
Consider increasing the value for the 'analyzeduration' and 'probesize' options
Input #0, matroska,webm, from 'input0.mkv':
Metadata:
title : GRAVITY DAZE The Animation Ouverture
encoder : libebml v1.2.3 + libmatroska v1.3.0
creation_time : 2017-03-30T06:22:52.000000Z
Duration: 00:17:23.58, start: 0.000000, bitrate: 2155 kb/s
Stream #0:0(eng): Video: h264 (High), yuv420p(progressive), 1280x720 [SAR 1:1 DAR 16:9], 24 fps, 24 tbr, 1k tbn, 48 tbc (default)
Stream #0:1(jpn): Audio: aac (LC), 48000 Hz, stereo, fltp (default)
Stream #0:2(jpn): Audio: aac (LC), 48000 Hz, stereo, fltp
Stream #0:3(chi): Subtitle: ass (default)
Metadata:
title : CHT
Stream #0:4(chi): Subtitle: ass
Metadata:
title : CHS
Stream #0:5(jpn): Subtitle: hdmv_pgs_subtitle
Stream #0:6(eng): Subtitle: hdmv_pgs_subtitle
[hls @ 0x5631128fc840] Opening 'subtitle/subtitleTrack0_0.vtt' for writing
[hls @ 0x5631128fc840] Opening 'subtitle/subtitleTrack00.vtt' for writing
[mpegts @ 0x56311296bda0] No streams to mux were specified
Could not write header for output file #5 (incorrect codec parameters ?): Invalid argument
Stream mapping:
Stream #0:0 -> #0:0 (h264 (native) -> h264 (libx264))
Stream #0:0 -> #1:0 (h264 (native) -> h264 (libx264))
Stream #0:0 -> #2:0 (h264 (native) -> h264 (libx264))
Stream #0:1 -> #3:0 (aac (native) -> aac (native))
Stream #0:2 -> #4:0 (aac (native) -> aac (native))
Stream #0:3 -> #5:0 (ass (ssa) -> webvtt (native))
Stream #0:4 -> #6:0 (ass (ssa) -> webvtt (native))
Stream #0:5 -> #7:0 (hdmv_pgs_subtitle (pgssub) -> webvtt (native))
Stream #0:6 -> #8:0 (hdmv_pgs_subtitle (pgssub) -> webvtt (native))
Last message repeated 1 times
如果命令未添加字幕:
ffmpeg -i input0.mkv \
-map 0:v:0 -c:v libx264 -strict -2 -s 426x240 -f hls -hls_time 10 -hls_list_size 6 -hls_wrap 10 -hls_segment_filename video/videoTrack240p_%d.ts video/videoTrack240p.m3u8 \
-map 0:v:0 -c:v libx264 -strict -2 -s 1280x720 -f hls -hls_time 10 -hls_list_size 6 -hls_wrap 10 -hls_segment_filename video/videoTrack720p_%d.ts video/videoTrack720p.m3u8 \
-map 0:v:0 -c:v libx264 -strict -2 -s 1920x1080 -f hls -hls_time 10 -hls_list_size 6 -hls_wrap 10 -hls_segment_filename video/videoTrack1080p_%d.ts video/videoTrack1080p.m3u8 \
-map 0:a:0 -c:a aac -f hls -hls_time 10 -hls_list_size 6 -hls_wrap 10 -hls_segment_filename audio/audioTrack1_%d.aac audio/audioTrack0.m3u8 \
-map 0:a:1 -c:a aac -f hls -hls_time 10 -hls_list_size 6 -hls_wrap 10 -hls_segment_filename audio/audioTrack0_%d.aac audio/audioTrack1.m3u8
流媒体正常工作。 我长时间找不到带有字幕示例的FFmpeg流。