title: How to use FFmpeg to live HLS stream with subtitle?
body: <p>I want to use FFmpeg to live HLS stream with subtitle.
  I have a Media. The Media have one video track, two audio track, four subtitle.
  But, I tryed this command:</p>
  
  <pre><code>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
  </code></pre>
  
  <p>It show this Error:</p>
  
  <pre><code>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 -&gt; #0:0 (h264 (native) -&gt; h264 (libx264))
    Stream #0:0 -&gt; #1:0 (h264 (native) -&gt; h264 (libx264))
    Stream #0:0 -&gt; #2:0 (h264 (native) -&gt; h264 (libx264))
    Stream #0:1 -&gt; #3:0 (aac (native) -&gt; aac (native))
    Stream #0:2 -&gt; #4:0 (aac (native) -&gt; aac (native))
    Stream #0:3 -&gt; #5:0 (ass (ssa) -&gt; webvtt (native))
    Stream #0:4 -&gt; #6:0 (ass (ssa) -&gt; webvtt (native))
    Stream #0:5 -&gt; #7:0 (hdmv_pgs_subtitle (pgssub) -&gt; webvtt (native))
    Stream #0:6 -&gt; #8:0 (hdmv_pgs_subtitle (pgssub) -&gt; webvtt (native))
      Last message repeated 1 times
  </code></pre>
  
  <p>If the command not add subtitle:</p>
  
  <pre><code>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
  </code></pre>
  
  <p>The streaming is work without error.
  I cannot find FFmpeg streaming with subtitle example on long time.</p>