Opened 11 years ago

Closed 11 years ago

Last modified 11 years ago

#2107 closed defect (invalid)

m2ts encoding fails with H.264 bitstream malformed, no startcode found, use the h264_mp4toannexb bitstream filter (-bsf h264_mp4toannexb) av_interleaved_write_frame(): Invalid argument

Reported by: John Galt Owned by:
Priority: normal Component: undetermined
Version: unspecified Keywords:
Cc: Blocked By:
Blocking: Reproduced by developer: no
Analyzed by developer: no

Description

Summary of the bug:
All input files with h264 and any audio track when attempting to encode to m2ts with -f mpegts fails with the below information

How to reproduce:

% ffmpeg -i "input.mkv" -map 0:0 -map 0:1 -map 0:2 -c:a:1 copy -c:v copy -c:a:0 copy -f mpegts "output.m2ts"
ffmpeg version N-48284-g518239c Copyright (c) 2000-2012 the FFmpeg developers
built on Dec 29 2012 22:41:41 with gcc 4.7.2 (GCC)
configuration: --disable-static --enable-shared --enable-gpl --enable-version3 --disable-w32threads --enable-avisynth --enable-bzlib --enable-fontconfig --enable-frei0r --enable-gnutls --enable-libass --enable-libbluray --enable-libcaca --enable-libfreetype --enable-libgsm --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-librtmp --enable-libschroedinger --enable-libtheora --enable-libtwolame --enable-libvo-aacenc --enable-libvo-amrwbenc --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libxavs --enable-libxvid --enable-zlib
libavutil      52. 12.100 / 52. 12.100
libavcodec     54. 81.100 / 54. 81.100
libavformat    54. 50.104 / 54. 50.104
libavdevice    54.  3.102 / 54.  3.102
libavfilter     3. 30.101 /  3. 30.101
libswscale      2.  1.103 /  2.  1.103
libswresample   0. 17.102 /  0. 17.102
libpostproc    52.  2.100 / 52.  2.100
Input #0, matroska,webm, from 'input.mkv':
Metadata:
creation_time   : 2012-12-13 00:44:15
Duration: 01:58:53.15, start: 0.000000, bitrate: 14053 kb/s
Chapter #0.0: start 0.000000, end 447.447000
Metadata:
title           : 00:00:00.000
Chapter #0.1: start 447.447000, end 811.686000
Metadata:
title           : 00:07:27.447
Chapter #0.2: start 811.686000, end 1282.490000
Metadata:
title           : 00:13:31.686
Chapter #0.3: start 1282.490000, end 1608.106000
Metadata:
title           : 00:21:22.490
Chapter #0.4: start 1608.106000, end 1911.201000
Metadata:
title           : 00:26:48.106
Chapter #0.5: start 1911.201000, end 2488.403000
Metadata:
title           : 00:31:51.201
Chapter #0.6: start 2488.403000, end 2973.429000
Metadata:
title           : 00:41:28.403
Chapter #0.7: start 2973.429000, end 3250.414000
Metadata:
title           : 00:49:33.429
Chapter #0.8: start 3250.414000, end 3635.006000
Metadata:
title           : 00:54:10.414
Chapter #0.9: start 3635.006000, end 4089.919000
Metadata:
title           : 01:00:35.006
Chapter #0.10: start 4089.919000, end 4523.352000
Metadata:
title           : 01:08:09.919
Chapter #0.11: start 4523.352000, end 5037.741000
Metadata:
title           : 01:15:23.352
Chapter #0.12: start 5037.741000, end 5665.869000
Metadata:
title           : 01:23:57.741
Chapter #0.13: start 5665.869000, end 6064.433000
Metadata:
title           : 01:34:25.869
Chapter #0.14: start 6064.433000, end 6389.383000
Metadata:
title           : 01:41:04.433
Chapter #0.15: start 6389.383000, end 7133.152000
Metadata:
title           : 01:46:29.383
Stream #0:0(eng): Video: h264 (High), yuv420p, 1920x812, SAR 1:1 DAR 480:203, 23.98 fps, 23.98 tbr, 1k tbn, 47.95 tbc (default)
Stream #0:1(eng): Audio: dts (DTS), 48000 Hz, 5.1(side), fltp, 1536 kb/s (default)
Metadata:
title           : DTS
Stream #0:2(eng): Audio: ac3, 48000 Hz, 5.1(side), fltp, 640 kb/s
Metadata:
title           : AC3
Stream #0:3(dut): Subtitle: dvd_subtitle
Metadata:
title           : HQ Wit
Stream #0:4(dut): Subtitle: dvd_subtitle
Metadata:
title           : HQ Geel
Stream #0:5(dut): Subtitle: subrip
Metadata:
title           : Normaal SRT
Stream #0:6(eng): Subtitle: dvd_subtitle
Metadata:
title           : HQ White
Stream #0:7(eng): Subtitle: dvd_subtitle
Metadata:
title           : HQ Yellow
Stream #0:8(eng): Subtitle: subrip
Stream #0:9(spa): Subtitle: dvd_subtitle
Metadata:
title           : HQ White
Stream #0:10(spa): Subtitle: dvd_subtitle
Metadata:
title           : HQ Yellow
Stream #0:11(spa): Subtitle: subrip
Metadata:
title           : Normal SRT
Output #0, mpegts, to '\\darwinserver\Movies\Looper (2012)\Looper (2012).m2ts':
Metadata:
encoder         : Lavf54.50.104
Chapter #0.0: start 0.000000, end 447.447000
Metadata:
title           : 00:00:00.000
Chapter #0.1: start 447.447000, end 811.686000
Metadata:
title           : 00:07:27.447
Chapter #0.2: start 811.686000, end 1282.490000
Metadata:
title           : 00:13:31.686
Chapter #0.3: start 1282.490000, end 1608.106000
Metadata:
title           : 00:21:22.490
Chapter #0.4: start 1608.106000, end 1911.201000
Metadata:
title           : 00:26:48.106
Chapter #0.5: start 1911.201000, end 2488.403000
Metadata:
title           : 00:31:51.201
Chapter #0.6: start 2488.403000, end 2973.429000
Metadata:
title           : 00:41:28.403
Chapter #0.7: start 2973.429000, end 3250.414000
Metadata:
title           : 00:49:33.429
Chapter #0.8: start 3250.414000, end 3635.006000
Metadata:
title           : 00:54:10.414
Chapter #0.9: start 3635.006000, end 4089.919000
Metadata:
title           : 01:00:35.006
Chapter #0.10: start 4089.919000, end 4523.352000
Metadata:
title           : 01:08:09.919
Chapter #0.11: start 4523.352000, end 5037.741000
Metadata:
title           : 01:15:23.352
Chapter #0.12: start 5037.741000, end 5665.869000
Metadata:
title           : 01:23:57.741
Chapter #0.13: start 5665.869000, end 6064.433000
Metadata:
title           : 01:34:25.869
Chapter #0.14: start 6064.433000, end 6389.383000
Metadata:
title           : 01:41:04.433
Chapter #0.15: start 6389.383000, end 7133.152000
Metadata:
title           : 01:46:29.383
Stream #0:0(eng): Video: h264, yuv420p, 1920x812 [SAR 1:1 DAR 480:203], q=2-31, 23.98 fps, 90k tbn, 23.98 tbc (default)
Stream #0:1(eng): Audio: dts, 48000 Hz, 5.1(side), 1536 kb/s (default)
Metadata:
title           : DTS
Stream #0:2(eng): Audio: ac3, 48000 Hz, 5.1(side), 640 kb/s
Metadata:
title           : AC3
Stream mapping:
Stream #0:0 -> #0:0 (copy)
Stream #0:1 -> #0:1 (copy)
Stream #0:2 -> #0:2 (copy)
Press [q] to stop, [?] for help
[mpegts @ 024d30a0] H.264 bitstream malformed, no startcode found, use the h264_mp4toannexb bitstream filter (-bsf h264_mp4toannexb)
av_interleaved_write_frame(): Invalid argument

Change History (8)

comment:1 by Carl Eugen Hoyos, 11 years ago

Resolution: invalid
Status: newclosed

Did you try the bitstream filter?

comment:2 by John Galt, 11 years ago

From what I can gather it is being used but failing. (its supposed to be on by default for m2ts). Do you have a parameter to force it?

comment:3 by Carl Eugen Hoyos, 11 years ago

Yes, please search the title of this ticket carefully for the option to force the h264_mp4toannexb bitstream filter.

comment:4 by John Galt, 11 years ago

So far, after about 200 links I haven't found anything.

I would think that since it fails without whatever the flag happens to be that needs to be set for all m2ts files, that it should automatically add it for m2ts files and just work. Hence Please consider this a bug (and please provide me with whatever the work around is in the mean time.

Thanks!

comment:5 by Carl Eugen Hoyos, 11 years ago

Please test the following:

$ ffmpeg -i "input.mkv" -map 0:0 -map 0:1 -map 0:2 -c:a:1 copy -c:v copy -c:a:0 copy -f mpegts -vbsf h264_mp4toannexb "output.m2ts"

comment:6 by John Galt, 11 years ago

That works... Thanks! But shouldn't it know to do that automatically and not require it?

comment:7 by John Galt, 11 years ago

I should update this to say that the above command line works ... sometimes.

Other times the resulting video stutters like crazy. Oddly if you then do another of video and audio into mp4 the resulting video plays fine.

Also if you use h264info on the video it will also play fine. It would be nice if ffmpeg could detect whatever is causing this and fix it in the file if necessary.

Suggestions?

in reply to:  7 comment:8 by Carl Eugen Hoyos, 11 years ago

Replying to JohnGalt:

Suggestions?

If you have a problem with ffmpeg (the command line application), please do not hesitate to ask for support on the user mailing list, see http://ffmpeg.org/contact.html
If you believe that you found a bug in FFmpeg, please open a ticket on this bug tracker.

In both cases, please do not forget to post your failing command line together with complete, uncut console output and provide an input sample.

Note: See TracTickets for help on using tickets.