[FFmpeg-trac] #10502(undetermined:new): var_stream_map doesn't support optional entries

FFmpeg trac at avcodec.org
Wed Aug 2 21:19:48 EEST 2023


#10502: var_stream_map doesn't support optional entries
-------------------------------------+-------------------------------------
             Reporter:               |                     Type:  defect
  alexey.rodionov                    |
               Status:  new          |                 Priority:  normal
            Component:               |                  Version:  git-
  undetermined                       |  master
             Keywords:  hls          |               Blocked By:
             Blocking:               |  Reproduced by developer:  0
Analyzed by developer:  0            |
-------------------------------------+-------------------------------------
 I'm working on a service that takes a video file as input and generates
 HLS streams in various resolutions as output (like YouTube does).

 If the input file has no audio, running the following command:

 {{{
 ffmpeg -i input.mp4 -map 0:v:0 -map 0:v:0 -map 0:v:0 -map 0:v:0 -map 0:a:0
 -filter:v:0 scale=-2:360 -filter:v:1 scale=-2:480 -filter:v:2 scale=-2:720
 -filter:v:3 scale=-2:1080 -f hls -hls_playlist_type vod -hls_flags
 independent_segments -master_pl_name master.m3u8 -hls_segment_filename
 stream_%v/chunk_%08d.ts -strftime_mkdir 1 -var_stream_map
 "v:0,name:360p,agroup:audio v:1,name:480p,agroup:audio
 v:2,name:720p,agroup:audio v:3,name:1080p,agroup:audio
 a:0,name:audio,agroup:audio" stream_%v.m3u8
 }}}

 causes the following error:

 {{{
 Stream map '0:a:0' matches no streams.
 To ignore this, add a trailing '?' to the map.
 }}}

 This error can be fixed by changing `-map 0:a:0` to `-map 0:a:0?`, but
 then another error occurs:

 {{{
 [hls @ 000002928260f640] Unable to map stream at a:0
 [hls @ 000002928260f640] Variant stream info update failed with status
 ffffffea
 [out#0/hls @ 000002928260f440] Could not write header (incorrect codec
 parameters ?): Invalid argument
 }}}

 Changing `a:0,name:audio,agroup:audio` to `a:0,name:audio,agroup:audio?`
 inside `-var_stream_map` doesn't help.

 The problem is that I don't know if the input file the user can upload has
 audio or not.

 I've found other mentions of this problem, e.g.:

 https://stackoverflow.com/q/54008205/#comment94853363_54008205
 https://stackoverflow.com/a/59220868/#comment104669510_59220868
 https://stackoverflow.com/a/69623106

 Notes:

 The interesting thing is that there is another way to create an HLS
 streams using `dash` muxer with `-hls_playlist true` option instead of
 `hls` muxer:

 {{{
 ffmpeg -i input.mp4 -map 0:v:0 -map 0:v:0 -map 0:v:0 -map 0:v:0 -map 0:a:0
 -filter:v:0 scale=-2:360 -filter:v:1 scale=-2:480 -filter:v:2 scale=-2:720
 -filter:v:3 scale=-2:1080 -use_template 1 -use_timeline 1 -adaptation_sets
 "id=0,streams=v id=1,streams=a" -hls_playlist true -f dash manifest.mpd
 }}}

 In this case changing `-map 0:a:0` to `-map 0:a:0?` is enough.
-- 
Ticket URL: <https://trac.ffmpeg.org/ticket/10502>
FFmpeg <https://ffmpeg.org>
FFmpeg issue tracker


More information about the FFmpeg-trac mailing list