Opened 11 years ago

Closed 11 years ago

#2083 closed defect (fixed)

'Invalid argument' or 'Assertion ost->source_index >= 0 failed at ffmpeg.c:2932' message on subtitle metadata

Reported by: rtmi1 Owned by:
Priority: important Component: ffmpeg
Version: git-master Keywords: crash abort regression
Cc: Blocked By:
Blocking: Reproduced by developer: yes
Analyzed by developer: no

Description

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>



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>

Change History (5)

comment:1 by Carl Eugen Hoyos, 11 years ago

Component: FFmpegundetermined
Keywords: mkv added; ffmpeg mimetype subtitles removed

Is this also reproducible with current git head?

comment:2 by Carl Eugen Hoyos, 11 years ago

Component: undeterminedFFmpeg
Keywords: crash abort regression added; mkv metadata removed
Priority: minorimportant
Reproduced by developer: set
Status: newopen
Version: unspecifiedgit-master

Regression since 1cadab6 (crash in select_input_file() in ffmpeg.c) / 429c6ca (assert).

$ ffmpeg -i tests/lena.pnm -attach /usr/share/fonts/truetype/DejaVuSans.ttf -metadata:s mimetype=application/x-truetype-font out.mkv
ffmpeg version N-48332-gfe5a2fc Copyright (c) 2000-2012 the FFmpeg developers
  built on Dec 31 2012 03:12:02 with gcc 4.7 (SUSE Linux)
  configuration: --enable-gpl --disable-indev=jack
  libavutil      52. 13.100 / 52. 13.100
  libavcodec     54. 85.100 / 54. 85.100
  libavformat    54. 57.100 / 54. 57.100
  libavdevice    54.  3.102 / 54.  3.102
  libavfilter     3. 30.102 /  3. 30.102
  libswscale      2.  1.103 /  2.  1.103
  libswresample   0. 17.102 /  0. 17.102
  libpostproc    52.  2.100 / 52.  2.100
Input #0, image2, from 'tests/lena.pnm':
  Duration: 00:00:00.04, start: 0.000000, bitrate: N/A
    Stream #0:0: Video: ppm, rgb24, 256x256, 25 tbr, 25 tbn, 25 tbc
Output #0, matroska, to 'out.mkv':
  Metadata:
    encoder         : Lavf54.57.100
    Stream #0:0: Video: mpeg4, yuv420p, 256x256, q=2-31, 200 kb/s, 1k tbn, 25 tbc
    Metadata:
      mimetype        : application/x-truetype-font
    Stream #0:1: Attachment: none
    Metadata:
      filename        : DejaVuSans.ttf
      mimetype        : application/x-truetype-font
Stream mapping:
  Stream #0:0 -> #0:0 (ppm -> mpeg4)
  File /usr/share/fonts/truetype/DejaVuSans.ttf -> Stream #0:1
Press [q] to stop, [?] for help
Assertion ost->source_index >= 0 failed at ffmpeg.c:2976
Aborted

comment:3 by Cigaes, 11 years ago

Should be fixed by adding this:

ost->finished = 1;

In the "handle attached files" loop in ffmpeg_opt.c, along with all ost init.
No time to make a proper patch right now, sorry.

comment:4 by Cigaes, 11 years ago

Should be fixed in Git head.
rtmi1: do you confirm?

comment:5 by Carl Eugen Hoyos, 11 years ago

Resolution: fixed
Status: openclosed

Fixed by Nicolas George.

Note: See TracTickets for help on using tickets.