Opened 13 years ago

Closed 12 years ago

#415 closed defect (fixed)

vcodec copy fails with H264 stream from AVCHD container

Reported by: Damian Owned by:
Priority: normal Component: undetermined
Version: git-master Keywords: h264 av_interleaved_write_frame
Cc: Blocked By:
Blocking: Reproduced by developer: yes
Analyzed by developer: no

Description

I have a Canon HF G10 camcorder, which saves 1080p25/1080i50 H264+AC3 data streams in an AVCHD container.

When attempting to copy the streams into an mp4 (or mov, but not mkv) container, ffmpeg is failing with a 'non monotonically increasing dts' error message before writing the first frame. I'm on Mac OSX 10.6, I've tried both ffmpeg 0.8.0 (compiled by Homebrew) and 0.8.2 (compiled by ./configure && make).

commandline + output:

$ ffmpeg -v 9 -loglevel 99 -i 00167.MTS -vcodec copy -acodec copy 00167.mp4
ffmpeg version 0.8.2, Copyright (c) 2000-2011 the FFmpeg developers
  built on Aug 22 2011 16:25:22 with gcc 4.2.1 (Apple Inc. build 5666) (dot 3)
  configuration: 
  libavutil    51.  9. 1 / 51.  9. 1
  libavcodec   53.  7. 0 / 53.  7. 0
  libavformat  53.  4. 0 / 53.  4. 0
  libavdevice  53.  1. 1 / 53.  1. 1
  libavfilter   2. 23. 0 /  2. 23. 0
  libswscale    2.  0. 0 /  2.  0. 0
[mpegts @ 0x10104ec00] Format mpegts probed with size=2048 and score=100
[mpegts @ 0x10104ec00] stream=0 stream_type=1b pid=1011 prog_reg_desc=HDMV
[mpegts @ 0x10104ec00] stream=1 stream_type=81 pid=1100 prog_reg_desc=HDMV
[h264 @ 0x101057200] Unsupported bit depth: 0
[h264 @ 0x101057200] no picture
    Last message repeated 1 times
Seems stream 0 codec frame rate differs from container frame rate: 50.00 (50/1) -> 50.00 (50/1)
    Last message repeated 1 times
Input #0, mpegts, from '../raw/AVCHD/BDMV/STREAM/00167.MTS':
  Duration: 00:00:01.44, start: 0.483578, bitrate: 12967 kb/s
  Program 1 
    Stream #0.0[0x1011], 72, 1/90000: Video: h264 (High), yuv420p, 1920x1080 [PAR 1:1 DAR 16:9], 1/50, 50 fps, 50 tbr, 90k tbn, 50 tbc
    Stream #0.1[0x1100], 45, 1/90000: Audio: ac3, 48000 Hz, stereo, s16, 256 kb/s
Output #0, mp4, to '00167.mp4':
  Metadata:
    encoder         : Lavf53.4.0
    Stream #0.0, 0, 1/25: Video: ![0][0][0] / 0x0021, yuv420p, 1920x1080 [PAR 1:1 DAR 16:9], 1/25, q=2-31, 25 tbn, 25 tbc
    Stream #0.1, 0, 1/48000: Audio: ac3, 48000 Hz, stereo, 256 kb/s
Stream mapping:
  Stream #0.0 -> #0.0
  Stream #0.1 -> #0.1
Press [q] to stop, [?] for help
[mp4 @ 0x101071e00] Application provided invalid, non monotonically increasing dts to muxer in stream 0: 1 >= 1
av_interleaved_write_frame(): Invalid argument

output of mediainfo:

$ mediainfo 00167.MTS
General
ID                               : 0 (0x0)
Complete name                    : 00167.MTS
Format                           : BDAV
Format/Info                      : Blu-ray Video
File size                        : 2.24 MiB
Duration                         : 1s 350ms
Overall bit rate                 : 13.8 Mbps
Maximum Overall bit rate         : 18.0 Mbps

Video
ID                               : 4113 (0x1011)
Menu ID                          : 1 (0x1)
Format                           : AVC
Format/Info                      : Advanced Video Codec
Format profile                   : High@L4.0
Format settings, CABAC           : Yes
Format settings, ReFrames        : 2 frames
Codec ID                         : 27
Duration                         : 1s 360ms
Bit rate mode                    : Variable
Bit rate                         : 13.0 Mbps
Maximum bit rate                 : 16.0 Mbps
Width                            : 1 920 pixels
Height                           : 1 080 pixels
Display aspect ratio             : 16:9
Frame rate                       : 25.000 fps
Color space                      : YUV
Chroma subsampling               : 4:2:0
Bit depth                        : 8 bits
Scan type                        : Interlaced
Scan order                       : Top Field First
Bits/(Pixel*Frame)               : 0.251
Stream size                      : 2.11 MiB (94%)

Audio
ID                               : 4352 (0x1100)
Menu ID                          : 1 (0x1)
Format                           : AC-3
Format/Info                      : Audio Coding 3
Mode extension                   : CM (complete main)
Codec ID                         : 129
Duration                         : 1s 440ms
Bit rate mode                    : Constant
Bit rate                         : 256 Kbps
Channel(s)                       : 2 channels
Channel positions                : Front: L R
Sampling rate                    : 48.0 KHz
Bit depth                        : 16 bits
Compression mode                 : Lossy
Stream size                      : 45.0 KiB (2%)

Original file is attached and at http://frey.co.nz/share/00167.MTS (2.2MB)

Attachments (2)

00167.MTS (2.2 MB ) - added by Damian 13 years ago.
AVCHD file causing 'non monotonically increasing dts' error with -vcodec copy
00008.MTS (2.5 MB ) - added by Adruna 13 years ago.
Extra file: non monotonically increasing dts to muxer in stream 0: 1 >= 1

Change History (10)

by Damian, 13 years ago

Attachment: 00167.MTS added

AVCHD file causing 'non monotonically increasing dts' error with -vcodec copy

comment:1 by Damian, 13 years ago

-- I forgot to state that the video 00167.MTS was recorded at 1080i 50fps 'FXP' quality (17Mbps). I didn't try other quality/FPS settings.

comment:2 by Damian, 13 years ago

-- Also note that -vcodec copy to a Matroska mkv stream doesn't trigger the error. Could it be related to AVFMT_TS_NONSTRICT ?

comment:3 by Carl Eugen Hoyos, 13 years ago

Priority: importantnormal
Reproduced by developer: set
Status: newopen
Version: 0.8.2git-master

Do you believe this is a regression?

comment:4 by Damian, 13 years ago

I don't think so -- some casual googling seem to show up long-standing issues with -vcodec copy and h.264 B-frames (which are present in the provided 00167.MTS).

comment:5 by Adruna, 13 years ago

I have the same problem with the "JVC Everio GZ-HM650" at XP recording mode, 1920x1080 pixels, Average Approximate 17 Mbps.
FFMPEG build: N-32023-gf138c7f

Not working:
ffmpeg -i 0001.MTS -vcodec copy -acodec copy out/0001.mp4
but when transcoding like:
ffmpeg -i 0001.MTS -vcodec libx264 -acodec copy out/0001.mp4
it Works.

I will add a small sample file later on.

comment:6 by Damian, 13 years ago

I've discovered that ffmbc http://code.google.com/p/ffmbc/ can do this out of the box (tested ffmbc 0.6):

ffmbc -i 00167.MTS -vcodec copy -acodec aac -ab 256k 00167.mp4

produces an .mp4 that Quicktime is perfectly happy to play. I wonder how easy/difficult it would be to backport ffmbc patches to ffmpeg?

by Adruna, 13 years ago

Attachment: 00008.MTS added

Extra file: non monotonically increasing dts to muxer in stream 0: 1 >= 1

comment:7 by Carl Eugen Hoyos, 12 years ago

Keywords: h264 av_interleaved_write_frame added

comment:8 by Carl Eugen Hoyos, 12 years ago

Resolution: fixed
Status: openclosed
Note: See TracTickets for help on using tickets.