Opened 22 months ago

Closed 21 months ago

Last modified 21 months ago

#11248 closed defect (fixed)

mapping of optional streams selected by language broken

Reported by: Jakob Owned by: elenril
Priority: normal Component: ffmpeg
Version: git-master Keywords: map
Cc: Jakob Blocked By:
Blocking: Reproduced by developer: no
Analyzed by developer: yes

Description

Summary of the bug:

I used to use -map 0:s:m:language:eng? to map only english subtitles into the output, but don't fail if there is no such subtitle. This worked fine until I updated ffmpeg to the latest version (#9601 also suggests that this used to work).

Using either -map 0:s:0? or -map 0:s:m:language:eng, i.e. optional map by number or mandatory map by language, works as expected.

How to reproduce:

% ffmpeg -i 0.mkv -c copy -map '0:s:m:language:eng?' out.srt
ffmpeg version N-117538-g9ce63e65d6-20241015 Copyright (c) 2000-2024 the FFmpeg developers
  built with gcc 14.2.0 (crosstool-NG 1.26.0.120_4d36f27)
  configuration: --prefix=/ffbuild/prefix --pkg-config-flags=--static --pkg-config=pkg-config --cross-prefix=x86_64-ffbuild-linux-gnu- --arch=x86_64 --target-os=linux --enable-gpl --enable-version3 --disable-debug --enable-iconv --enable-zlib --enable-libfreetype --enable-libfribidi --enable-gmp --enable-libxml2 --enable-openssl --enable-lzma --enable-fontconfig --enable-libharfbuzz --enable-libvorbis --enable-opencl --enable-libpulse --enable-libvmaf --enable-libxcb --enable-xlib --enable-amf --enable-libaom --enable-libaribb24 --enable-avisynth --enable-chromaprint --enable-libdav1d --enable-libdavs2 --enable-libdvdread --enable-libdvdnav --disable-libfdk-aac --enable-ffnvcodec --enable-cuda-llvm --enable-frei0r --enable-libgme --enable-libkvazaar --enable-libaribcaption --enable-libass --enable-libbluray --enable-libjxl --enable-libmp3lame --enable-libopus --enable-librist --enable-libssh --enable-libtheora --enable-libvpx --enable-libwebp --enable-libzmq --enable-lv2 --enable-libvpl --enable-openal --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenh264 --enable-libopenjpeg --enable-libopenmpt --enable-librav1e --enable-librubberband --disable-schannel --enable-sdl2 --enable-libsoxr --enable-libsrt --enable-libsvtav1 --enable-libtwolame --enable-libuavs3d --enable-libdrm --enable-vaapi --enable-libvidstab --enable-vulkan --enable-libshaderc --enable-libplacebo --enable-libvvenc --enable-libx264 --enable-libx265 --enable-libxavs2 --enable-libxvid --enable-libzimg --enable-libzvbi --extra-cflags=-DLIBTWOLAME_STATIC --extra-cxxflags= --extra-libs='-ldl -lgomp' --extra-ldflags=-pthread --extra-ldexeflags=-pie --cc=x86_64-ffbuild-linux-gnu-gcc --cxx=x86_64-ffbuild-linux-gnu-g++ --ar=x86_64-ffbuild-linux-gnu-gcc-ar --ranlib=x86_64-ffbuild-linux-gnu-gcc-ranlib --nm=x86_64-ffbuild-linux-gnu-gcc-nm --extra-version=20241015
  libavutil      59. 43.100 / 59. 43.100
  libavcodec     61. 22.100 / 61. 22.100
  libavformat    61.  9.100 / 61.  9.100
  libavdevice    61.  4.100 / 61.  4.100
  libavfilter    10.  6.100 / 10.  6.100
  libswscale      8.  6.100 /  8.  6.100
  libswresample   5.  4.100 /  5.  4.100
  libpostproc    58.  4.100 / 58.  4.100
Input #0, matroska,webm, from '0.mkv':
[... listing of all input streams ...]
Stream map '' matches no streams.
To ignore this, add a trailing '?' to the map.
Failed to set value '0:a:m:language:eng?' for option 'map': Invalid argument
Error parsing options for output file out.mkv.
Error opening output files: Invalid argument

Change History (6)

comment:1 by Jakob, 22 months ago

addition: I fiddled a little more and found that it seems to work when inserting a : seperator between the language and the optional modifier ?, i.e. `-map '0:s:m:language:eng:?'. Maybe it was always intended to only work this way, but I couldn't find something about that in the docs.

comment:2 by elenril, 22 months ago

Analyzed by developer: set
Owner: set to elenril
Status: newopen

This was a semi-intentional recent change in stream specifier handling (semi- because I forgot to document this aspect of it) that was necessary because previous syntax was ambiguous - there was no way to tell whether the '?' is a part of the metadata value or the optional-map marker.

Leaving the bug open until the documentation is fixed.

comment:3 by Jakob, 22 months ago

Ok, thanks for the confirmation. I understand the rationale, sounds sensible to me.

comment:4 by elenril, 21 months ago

Resolution: fixed
Status: openclosed

Fixed in 9e68b26765ca8396050f4b58d4b4fdc53943d35f and backported to 7.1

comment:5 by Anton Khirnov <anton@khirnov.net>, 21 months ago

In 9e68b267/ffmpeg:

Document stream specifier syntax change from 46cbe4ab5c

Fixes #11248.

comment:6 by Anton Khirnov <anton@khirnov.net>, 21 months ago

In 9e68b267/ffmpeg:

Document stream specifier syntax change from 46cbe4ab5c

Fixes #11248.

Note: See TracTickets for help on using tickets.