id,summary,reporter,owner,description,type,status,priority,component,version,resolution,keywords,cc,blockedby,blocking,reproduced,analyzed
2083,'Invalid argument' or 'Assertion ost->source_index >= 0 failed at ffmpeg.c:2932' message on subtitle metadata,rtmi1,,"Summary of the bug:

Trying to copy streams plus a TTF font file to support hardware players that need an embedded font for subtitles.

* 1 video stream from MtStHel.mkv (This file only contains 1 video stream and was previously created with ffmpeg)
* 3 audio streams from MtStHel-eng-1-normalized.mp2, MtStHel-ger-2-normalized.mp2 and MtStHel-eng-3-normalized.mp2 (Each file only contains * 1 audio track and was also previously created with ffmpeg)
* 2 subtitle streams from MtStHel-en-subtitles.sub and MtStHel-de-subtitles.sub (Each file created with the 'mencoder -vobsubout ...' command)
* 1 attachment: a TrueType font file 'tahoma.ttf', 383804 bytes, tagged as 'mimetype=application/x-truetype-font' as described in 'http://ffmpeg.org/ffmpeg.html'.

ffmpeg quits with an ""Attachment stream 6 has no mimetype tag"" and finally an ""Invalid argument"" message.

No output is produced.

Changing the mimetype to ""application/octet-stream"" or ""application/x-font-ttf gives the same result.

Omitting the attachment gives a correct result, until it comes to the hardware player mentioned:
That player lists the 2 subtitle streams, but can not display them (no text on the screen).

Hardware: MSI Movie Station HD1000

How to reproduce:
{{{
martin@pc003:/media/Work> ffmpeg -copyts -i MtStHel.mkv -i MtStHel-eng-1-normalized.mp2 -i MtStHel-ger-2-normalized.mp2 -i MtStHel-eng-3-normalized.mp2 -i MtStHel-en-subtitles.sub -i MtStHel-de-subtitles.sub -map 0:0 -c:v copy -map 1:0 -c:a copy -metadata:s:a:0 language=eng -map 2:0 -c:a copy -metadata:s:a:1 language=ger -map 3:0 -c:a copy -metadata:s:a:2 language=eng -map 4:0 -c:s copy -metadata:s:s:0 language=eng -map 5:0 -c:s copy -metadata:s:s:1 language=ger -attach tahoma.ttf -metadata:s:0 mimetype=application/x-truetype-font -f matroska MtStHel-ffmpeg.mkv
ffmpeg version 1.0.1 Copyright (c) 2000-2012 the FFmpeg developers
  built on Dec 11 2012 22:10:12 with gcc 4.6 (SUSE Linux)
  configuration: --shlibdir=/usr/lib --prefix=/usr --mandir=/usr/share/man --libdir=/usr/lib --enable-shared --disable-static --enable-debug --disable-stripping --extra-cflags='-fomit-frame-pointer -fmessage-length=0 -O2 -Wall -D_FORTIFY_SOURCE=2 -fstack-protector -funwind-tables -fasynchronous-unwind-tables -g -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -I/usr/include/gsm' --enable-gpl --enable-x11grab --enable-version3 --enable-pthreads --enable-avfilter --enable-libpulse --enable-libvpx --enable-libopus --enable-libmp3lame --enable-libvorbis --enable-libtheora --enable-libspeex --enable-libxvid --enable-libx264 --enable-libschroedinger --enable-libgsm --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-postproc --enable-libdc1394 --enable-librtmp --enable-libfreetype --enable-avresample
  libavutil      51. 73.101 / 51. 73.101
  libavcodec     54. 59.100 / 54. 59.100
  libavformat    54. 29.104 / 54. 29.104
  libavdevice    54.  2.101 / 54.  2.101
  libavfilter     3. 17.100 /  3. 17.100
  libswscale      2.  1.101 /  2.  1.101
  libswresample   0. 15.100 /  0. 15.100
  libpostproc    52.  0.100 / 52.  0.100
Input #0, matroska,webm, from 'MtStHel.mkv':
  Metadata:
    ENCODER         : Lavf54.29.104
  Duration: 01:48:34.64, start: 0.000000, bitrate: 1225 kb/s
    Stream #0:0: Video: h264 (High), yuv420p, 716x422 [SAR 64:45 DAR 22912:9495], SAR 209:147 DAR 74822:31017, 25 fps, 25 tbr, 1k tbn, 50 tbc (default)
[mp3 @ 0x8082540] max_analyze_duration 5000000 reached at 5016000
[mp3 @ 0x8082540] Estimating duration from bitrate, this may be inaccurate                                                                  
Input #1, mp3, from 'MtStHel-eng-1-normalized.mp2':                                                                                       
  Duration: 01:48:34.60, start: 0.000000, bitrate: 192 kb/s
    Stream #1:0: Audio: mp2, 48000 Hz, stereo, s16, 192 kb/s
[mp3 @ 0x813da40] max_analyze_duration 5000000 reached at 5016000
[mp3 @ 0x813da40] Estimating duration from bitrate, this may be inaccurate                                                                  
Input #2, mp3, from 'MtStHel-ger-2-normalized.mp2':                                                                                       
  Duration: 01:48:34.60, start: 0.000000, bitrate: 192 kb/s
    Stream #2:0: Audio: mp2, 48000 Hz, stereo, s16, 192 kb/s
[mp3 @ 0x8078d60] max_analyze_duration 5000000 reached at 5016000
[mp3 @ 0x8078d60] Estimating duration from bitrate, this may be inaccurate                                                                  
Input #3, mp3, from 'MtStHel-eng-3-normalized.mp2':                                                                                       
  Duration: 01:48:34.60, start: 0.000000, bitrate: 192 kb/s
    Stream #3:0: Audio: mp2, 48000 Hz, stereo, s16, 192 kb/s
Input #4, mpeg, from 'MtStHel-en-subtitles.sub':
  Duration: 01:42:48.00, start: 50.760000, bitrate: 8 kb/s
    Stream #4:0[0x20]: Subtitle: dvd_subtitle
Input #5, mpeg, from 'MtStHel-de-subtitles.sub':
  Duration: 01:47:40.68, start: 50.760000, bitrate: 8 kb/s
    Stream #5:0[0x21]: Subtitle: dvd_subtitle
File 'MtStHel-ffmpeg.mkv' already exists. Overwrite ? [y/N] y
Attachment stream 6 has no mimetype tag and it cannot be deduced from the codec id.
Output #0, matroska, to 'MtStHel-ffmpeg.mkv':                                                                                                           
  Metadata:
    encoder         : Lavf54.29.104
    Stream #0:0: Video: h264, yuv420p, 716x422 [SAR 209:147 DAR 74822:31017], q=2-31, 25 fps, 1k tbn, 1k tbc (default)
    Metadata:
      mimetype        : application/x-truetype-font
    Stream #0:1(eng): Audio: mp2, 48000 Hz, stereo, 192 kb/s
    Stream #0:2(ger): Audio: mp2, 48000 Hz, stereo, 192 kb/s
    Stream #0:3(eng): Audio: mp2, 48000 Hz, stereo, 192 kb/s
    Stream #0:4(eng): Subtitle: dvd_subtitle
    Stream #0:5(ger): Subtitle: dvd_subtitle
    Stream #0:6: Attachment: none
    Metadata:
      filename        : tahoma.ttf
Stream mapping:
  Stream #0:0 -> #0:0 (copy)
  Stream #1:0 -> #0:1 (copy)
  Stream #2:0 -> #0:2 (copy)
  Stream #3:0 -> #0:3 (copy)
  Stream #4:0 -> #0:4 (copy)
  Stream #5:0 -> #0:5 (copy)
  File tahoma.ttf -> Stream #0:6
Could not write header for output file #0 (incorrect codec parameters ?): Invalid argument
martin@pc003:/media/Work>
}}}
[[br]]
[[br]]
When I use '-metadata:s:t:0' instead of '-metadata:s:0' to specify that only the attachment is to be tagged, then ffmpeg issues a different error:
{{{
martin@pc003:/media/Work> ffmpeg -copyts -i MtStHel.mkv -i MtStHel-eng-1-normalized.mp2 -i MtStHel-ger-2-normalized.mp2 -i MtStHel-eng-3-normalized.mp2 -i MtStHel-en-subtitles.sub -i MtStHel-de-subtitles.sub -map 0:0 -c:v copy -map 1:0 -c:a copy -metadata:s:a:0 language=eng -map 2:0 -c:a copy -metadata:s:a:1 language=ger -map 3:0 -c:a copy -metadata:s:a:2 language=eng -map 4:0 -c:s copy -metadata:s:s:0 language=eng -map 5:0 -c:s copy -metadata:s:s:1 language=ger -attach tahoma.ttf -metadata:s:t:0 mimetype=application/x-truetype-font -f matroska MtStHel-ffmpeg.mkv
ffmpeg version 1.0.1 Copyright (c) 2000-2012 the FFmpeg developers
  built on Dec 11 2012 22:10:12 with gcc 4.6 (SUSE Linux)
  configuration: --shlibdir=/usr/lib --prefix=/usr --mandir=/usr/share/man --libdir=/usr/lib --enable-shared --disable-static --enable-debug --disable-stripping --extra-cflags='-fomit-frame-pointer -fmessage-length=0 -O2 -Wall -D_FORTIFY_SOURCE=2 -fstack-protector -funwind-tables -fasynchronous-unwind-tables -g -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -I/usr/include/gsm' --enable-gpl --enable-x11grab --enable-version3 --enable-pthreads --enable-avfilter --enable-libpulse --enable-libvpx --enable-libopus --enable-libmp3lame --enable-libvorbis --enable-libtheora --enable-libspeex --enable-libxvid --enable-libx264 --enable-libschroedinger --enable-libgsm --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-postproc --enable-libdc1394 --enable-librtmp --enable-libfreetype --enable-avresample
  libavutil      51. 73.101 / 51. 73.101
  libavcodec     54. 59.100 / 54. 59.100
  libavformat    54. 29.104 / 54. 29.104
  libavdevice    54.  2.101 / 54.  2.101
  libavfilter     3. 17.100 /  3. 17.100
  libswscale      2.  1.101 /  2.  1.101
  libswresample   0. 15.100 /  0. 15.100
  libpostproc    52.  0.100 / 52.  0.100
Input #0, matroska,webm, from 'MtStHel.mkv':
  Metadata:
    ENCODER         : Lavf54.29.104
  Duration: 01:48:34.64, start: 0.000000, bitrate: 1225 kb/s
    Stream #0:0: Video: h264 (High), yuv420p, 716x422 [SAR 64:45 DAR 22912:9495], SAR 209:147 DAR 74822:31017, 25 fps, 25 tbr, 1k tbn, 50 tbc (default)
[mp3 @ 0x8082540] max_analyze_duration 5000000 reached at 5016000
[mp3 @ 0x8082540] Estimating duration from bitrate, this may be inaccurate                                                                  
Input #1, mp3, from 'MtStHel-eng-1-normalized.mp2':                                                                                       
  Duration: 01:48:34.60, start: 0.000000, bitrate: 192 kb/s
    Stream #1:0: Audio: mp2, 48000 Hz, stereo, s16, 192 kb/s
[mp3 @ 0x813da40] max_analyze_duration 5000000 reached at 5016000
[mp3 @ 0x813da40] Estimating duration from bitrate, this may be inaccurate                                                                  
Input #2, mp3, from 'MtStHel-ger-2-normalized.mp2':                                                                                       
  Duration: 01:48:34.60, start: 0.000000, bitrate: 192 kb/s
    Stream #2:0: Audio: mp2, 48000 Hz, stereo, s16, 192 kb/s
[mp3 @ 0x8078d60] max_analyze_duration 5000000 reached at 5016000
[mp3 @ 0x8078d60] Estimating duration from bitrate, this may be inaccurate                                                                  
Input #3, mp3, from 'MtStHel-eng-3-normalized.mp2':                                                                                       
  Duration: 01:48:34.60, start: 0.000000, bitrate: 192 kb/s
    Stream #3:0: Audio: mp2, 48000 Hz, stereo, s16, 192 kb/s
Input #4, mpeg, from 'MtStHel-en-subtitles.sub':
  Duration: 01:42:48.00, start: 50.760000, bitrate: 8 kb/s
    Stream #4:0[0x20]: Subtitle: dvd_subtitle
Input #5, mpeg, from 'MtStHel-de-subtitles.sub':
  Duration: 01:47:40.68, start: 50.760000, bitrate: 8 kb/s
    Stream #5:0[0x21]: Subtitle: dvd_subtitle
File 'MtStHel-ffmpeg.mkv' already exists. Overwrite ? [y/N] y
Output #0, matroska, to 'MtStHel-ffmpeg.mkv':
  Metadata:
    encoder         : Lavf54.29.104
    Stream #0:0: Video: h264, yuv420p, 716x422 [SAR 209:147 DAR 74822:31017], q=2-31, 25 fps, 1k tbn, 1k tbc (default)
    Stream #0:1(eng): Audio: mp2, 48000 Hz, stereo, 192 kb/s
    Stream #0:2(ger): Audio: mp2, 48000 Hz, stereo, 192 kb/s
    Stream #0:3(eng): Audio: mp2, 48000 Hz, stereo, 192 kb/s
    Stream #0:4(eng): Subtitle: dvd_subtitle
    Stream #0:5(ger): Subtitle: dvd_subtitle
    Stream #0:6: Attachment: none
    Metadata:
      filename        : tahoma.ttf
      mimetype        : application/x-truetype-font
Stream mapping:
  Stream #0:0 -> #0:0 (copy)
  Stream #1:0 -> #0:1 (copy)
  Stream #2:0 -> #0:2 (copy)
  Stream #3:0 -> #0:3 (copy)
  Stream #4:0 -> #0:4 (copy)
  Stream #5:0 -> #0:5 (copy)
  File tahoma.ttf -> Stream #0:6
Press [q] to stop, [?] for help
Assertion ost->source_index >= 0 failed at ffmpeg.c:2932
Aborted
martin@pc003:/media/Work>
}}}
",defect,closed,important,FFmpeg,git-master,fixed,crash abort regression,,,,1,0
