Log in

View Full Version : ffmpeg does not demux AVC from MP4 correctly?


LigH
1st October 2009, 16:09
Currently we have a little "challenge" to demux AVC video from a supposed FLV file - which was found to be in fact an MP4 file - using only ffmpeg, mencoder or mplayer.

General
Complete name : atu.mp4
Format : MPEG-4
Format profile : Base Media / Version 2
Codec ID : mp42
File size : 9.41 MiB
Duration : 3mn 51s
Overall bit rate : 341 Kbps
Encoded date : UTC 2008-01-04 23:28:16
Tagged date : UTC 2008-01-04 23:28:16

Video
ID : 2
Format : AVC
Format/Info : Advanced Video Codec
Format profile : Baseline@L1.1
Format settings, CABAC : No
Format settings, ReFrames : 1 frame
Codec ID : avc1
Codec ID/Info : Advanced Video Coding
Duration : 3mn 51s
Bit rate mode : Variable
Bit rate : 225 Kbps
Maximum bit rate : 1 219 Kbps
Width : 320 pixels
Height : 136 pixels
Display aspect ratio : 2.35:1
Frame rate mode : Constant
Frame rate : 25.000 fps
Resolution : 24 bits
Colorimetry : 4:2:0
Scan type : Progressive
Bits/(Pixel*Frame) : 0.206
Stream size : 6.20 MiB (66%)
Title : (C) 2007 Google Inc. v06.24.2007.
Encoded date : UTC 2008-01-04 23:28:16
Tagged date : UTC 2008-01-04 23:28:16

Audio
ID : 1
Format : AAC
Format/Info : Advanced Audio Codec
Format version : Version 4
Format profile : LC
Format settings, SBR : No
Codec ID : 40
Duration : 3mn 51s
Bit rate mode : Variable
Bit rate : 114 Kbps
Maximum bit rate : 147 Kbps
Channel(s) : 2 channels
Channel positions : L R
Sampling rate : 44.1 KHz
Resolution : 16 bits
Stream size : 3.15 MiB (33%)
Title : (C) 2007 Google Inc. v06.24.2007.
Encoded date : UTC 2008-01-04 23:28:16
Tagged date : UTC 2008-01-04 23:28:16

The first surprise was to find out that ffmpeg needs a filename extension matching to the wanted output format, or you always get errors like "Unable to find a suitable output format for 'outputfile'". So we were already happy to find working combinations of extension and format; but the result was incorrect, DGAVCIndex could not find any video in the supposedly demuxed file.

So I compared it against MP4Box, which worked fine:

MP4Box.exe -raw 2 -out atu.264 atu.mp4

Result: 6509061 bytes, working in DGAVCIndex

ffmpeg.exe -vcodec copy -an -i atu.mp4 atu.h264

Result: 6497042 bytes, NOT working in DGAVCIndex

ffmpeg.exe -vcodec copy -an -i atu.mp4 -f rawvideo atu.raw

Result: 6497042 bytes, NOT working in DGAVCIndex (atu.raw is binary identical to atu.h264)

So ... is a "raw AVC" file more than just raw? Or does ffmpeg miss to demultiplex a piece of it?

Dark Shikari
1st October 2009, 17:07
-vbsf h264_mp4toannexb

LigH
1st October 2009, 19:15
ffmpeg.exe -vcodec copy -an -vbsf h264_mp4toannexb -i atu.mp4 atu.h264

Result: 6512227 bytes, working in DGAVCIndex :thanks:

Contains even a little more than the result of MP4Box.

Dark Shikari
1st October 2009, 19:21
I'm surprised that works at all... -i goes before other options:

ffmpeg.exe -i atu.mp4 -vcodec copy -an -vbsf h264_mp4toannexb atu.h264

halsboss
5th October 2009, 06:33
Erm, I'd thought sourcing the latest automated win32 builds of ffmpeg from http://ffmpeg.arrozcru.org/autobuilds/ was a good idea until I discovered "-acodec libfaac" no longer works... any hints on links to a website which has latest builds including libfaac ?

If no go there, what other audio would you suggest instead inside an .mp4 ?

Dark Shikari
5th October 2009, 07:31
Erm, I'd thought sourcing the latest automated win32 builds of ffmpeg from http://ffmpeg.arrozcru.org/autobuilds/ was a good idea until I discovered "-acodec libfaac" no longer works... any hints on links to a website which has latest builds including libfaac ?

If no go there, what other audio would you suggest instead inside an .mp4 ?libfaac is not available under a GPL-compatible license, and as such cannot be legally distributed with ffmpeg.

You can encode with Nero's encoder and mux separately, or you can use ffmpeg's new AAC encoder (-acodec aac). But note that the latter is very beta and has quality significantly worse than FAAC.