Opened 21 months ago

Last modified 21 months ago

#9867 open defect

Cannot remove "default" disposition of mov_text subtitle in mp4

Reported by: liancea Owned by:
Priority: normal Component: avformat
Version: git-master Keywords:
Cc: Blocked By:
Blocking: Reproduced by developer: no
Analyzed by developer: no

Description

Summary of the bug:
When trying to remove the default disposition of a mov_text subtitle inside mp4 with either -disposition:s:0 0 or -disposition:s:0 -default, the output file still has the default disposition enabled.
Setting -default_mode to infer_no_subs or passthrough doesn't change the outcome. (This may only have worked for mkv in the first place, but I wasn't sure.)

I included instructions for a minimal file for reproducing the issue, but I could also upload a real world example with audio and video in it, if desired. The behavior was identical for me.

How to reproduce:

# Create sample file (linux/mac shell)
% echo -e '1\n00:00:00,000 --> 00:01:00,000\nTest' > subtest.srt
% ffmpeg -i subtest.srt -map 0 -c mov_text subtest.mp4


# Check if sample file has a default subtitle
% ffmpeg -hide_banner -i subtest.mp4
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'subtest.mp4':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2mp41
    encoder         : Lavf59.30.100
  Duration: 00:01:00.00, start: 0.000000, bitrate: 0 kb/s
  Stream #0:0[0x1](und): Subtitle: mov_text (tx3g / 0x67337874), 0 kb/s (default)
    Metadata:
      handler_name    : SubtitleHandler
At least one output file must be specified


# Try to remove default disposition
% ffmpeg -i subtest.mp4 -map 0 -c copy -disposition:s:0 0 subtest-after.mp4
# or ...
% ffmpeg -i subtest.mp4 -map 0 -c copy -disposition:s:0 -default subtest-after.mp4
ffmpeg version N-107731-g5cdf4c0bed Copyright (c) 2000-2022 the FFmpeg developers
  built with gcc 11 (Ubuntu 11.2.0-19ubuntu1)
  configuration: --prefix=/home/pauling/ffmpeg_build --pkg-config-flags=--static --extra-cflags=-I/home/pauling/ffmpeg_build/include --extra-ldflags=-L/home/pauling/ffmpeg_build/lib --extra-libs='-lpthread -lm' --ld=g++ --bindir=/home/pauling/bin --enable-gpl --enable-gnutls --enable-libaom --enable-libass --enable-libfdk-aac --enable-libfreetype --enable-libmp3lame --enable-libopus --enable-libsvtav1 --enable-libdav1d --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libx265 --enable-nonfree
  libavutil      57. 32.101 / 57. 32.101
  libavcodec     59. 42.100 / 59. 42.100
  libavformat    59. 30.100 / 59. 30.100
  libavdevice    59.  8.101 / 59.  8.101
  libavfilter     8. 46.101 /  8. 46.101
  libswscale      6.  8.102 /  6.  8.102
  libswresample   4.  8.100 /  4.  8.100
  libpostproc    56.  7.100 / 56.  7.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'subtest.mp4':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2mp41
    encoder         : Lavf59.30.100
  Duration: 00:01:00.00, start: 0.000000, bitrate: 0 kb/s
  Stream #0:0[0x1](und): Subtitle: mov_text (tx3g / 0x67337874), 0 kb/s (default)
    Metadata:
      handler_name    : SubtitleHandler
Output #0, mp4, to 'subtest-after.mp4':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2mp41
    encoder         : Lavf59.30.100
  Stream #0:0(und): Subtitle: mov_text (tx3g / 0x67337874), 0 kb/s
    Metadata:
      handler_name    : SubtitleHandler
Stream mapping:
  Stream #0:0 -> #0:0 (copy)
Press [q] to stop, [?] for help
size=       1kB time=00:00:00.00 bitrate=N/A speed=   0x    
video:0kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 12933.333008%


# Confirm whether default disposition is gone
% ffmpeg -hide_banner -i subtest-after.mp4
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'subtest-after.mp4':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2mp41
    encoder         : Lavf59.30.100
  Duration: 00:01:00.00, start: 0.000000, bitrate: 0 kb/s
  Stream #0:0[0x1](und): Subtitle: mov_text (tx3g / 0x67337874), 0 kb/s (default)
    Metadata:
      handler_name    : SubtitleHandler
At least one output file must be specified

Change History (1)

comment:1 by mkver, 21 months ago

Component: undeterminedavformat
Status: newopen

I can confirm that default_mode is an mkv-muxer option that will definitely be ignored by the mp4 muxer.

The mov muxer always sets one stream of each type to default; this is done in enable_tracks() (mainly the last loop in it, lines 6704-6715 in libavformat/movenc.c as of this writing). One would have to add an option similar to the mkv muxer's default_mode to do as you want (or one would have to directly map the AV_DISPOSITION_DEFAULT to MOV_TRACK_ENABLED).

Note: See TracTickets for help on using tickets.