Forum archive - Help: Need to put AC3 into MP4 with ffmpeg

http://www.supermediastore.com/



Forum Archive Home -> Mac -> Help: Need to put AC3 into MP4 with ffmpeg



Help: Need to put AC3 into MP4 with ffmpeg

thuriel posted 2009 Oct 20 14:09
I need to put the video and audio streams of an MKV file into an MP4 container. So I tried:

:
$ ffmpeg -i video.mkv -vcodec copy -acodec copy video.mp4


But, what I get is this error message:

:
Could not write header for output file #0 (incorrect codec parameters ?)


Does ffmpeg fail putting AC3 into the MP4 container? I know, initially MP4 did not support AC3 streams, but over a year ago they officially allowed AC3 to be enclosed in an MP4 (see http://en.wikipedia.org/wiki/Comparison_of_container_formats). So I expect ffmpeg to be aware of that and fulfill my wish! :D

Do I have to to specify any parameters to pack AC3 into MP4?



Baldrick posted 2009 Oct 20 14:16
What ffmpeg version are you using? You probably need a very new build.


Soopafresh posted 2009 Oct 20 14:27
AC3 in an MP4 container is a recent update to the spec. As Baldrick says, you need a recent version of FFMPEG to make it happen.


thuriel posted 2009 Oct 20 15:58
I compiled it from SVN (SVN-r20255) just three days ago:

:
$ ffmpeg -version
FFmpeg version SVN-r20255, Copyright (c) 2000-2009 Fabrice Bellard, et al.
  built on Oct 17 2009 02:49:24 with gcc 4.2.1 (Apple Inc. build 5646)
  configuration: --enable-pthreads --enable-libmp3lame --enable-libtheora --enable-libvorbis --enable-gpl --enable-libxvid --enable-libx264 --enable-nonfree --enable-libfaac --enable-libfaad
  libavutil     50. 3. 0 / 50. 3. 0
  libavcodec    52.37. 0 / 52.37. 0
  libavformat   52.39. 2 / 52.39. 2
  libavdevice   52. 2. 0 / 52. 2. 0
  libswscale     0. 7. 1 /  0. 7. 1
FFmpeg SVN-r20255
libavutil     50. 3. 0 / 50. 3. 0
libavcodec    52.37. 0 / 52.37. 0
libavformat   52.39. 2 / 52.39. 2
libavdevice   52. 2. 0 / 52. 2. 0
libswscale     0. 7. 1 /  0. 7. 1


I hope this is recent enough :D :/



Baldrick posted 2009 Oct 20 16:17
Could you list what the mkv contain? ffmpeg should show some info.

Or maybe try mp4box if you can find a mac version.



thuriel posted 2009 Oct 20 16:26
I'd prefer to use ffmpeg :/

Here is the complete output:

:
$ ffmpeg -i video.mkv -vcodec copy -acodec copy video.mp4
FFmpeg version SVN-r20255, Copyright (c) 2000-2009 Fabrice Bellard, et al.
  built on Oct 17 2009 02:49:24 with gcc 4.2.1 (Apple Inc. build 5646)
  configuration: --enable-pthreads --enable-libmp3lame --enable-libtheora --enable-libvorbis --enable-gpl --enable-libxvid --enable-libx264 --enable-nonfree --enable-libfaac --enable-libfaad
  libavutil     50. 3. 0 / 50. 3. 0
  libavcodec    52.37. 0 / 52.37. 0
  libavformat   52.39. 2 / 52.39. 2
  libavdevice   52. 2. 0 / 52. 2. 0
  libswscale     0. 7. 1 /  0. 7. 1

Seems stream 0 codec frame rate differs from container frame rate: 59.94 (60000/1001) -> 29.97 (30000/1001)
Input #0, matroska, from 'video.mkv':
  Duration: 00:03:14.59, start: 0.000000, bitrate: N/A
    Stream #0.0(eng): Video: h264, yuv420p, 720x480, PAR 8:9 DAR 4:3, 29.97 tbr, 1k tbn, 59.94 tbc
    Stream #0.1(eng): Audio: ac3, 48000 Hz, 6 channels, s16
    Stream #0.2(eng): Audio: ac3, 48000 Hz, 2 channels, s16
    Stream #0.3(eng): Audio: ac3, 48000 Hz, 2 channels, s16
    Stream #0.4(eng): Audio: ac3, 48000 Hz, 2 channels, s16
File 'video.mp4' already exists. Overwrite ? [y/N] y
[mp4 @ 0x1076800]track 1: codec frame size is not set
Output #0, mp4, to 'video.mp4':
    Stream #0.0(eng): Video: libx264, yuv420p, 720x480 [PAR 8:9 DAR 4:3], q=2-31, 1k tbn, 1k tbc
    Stream #0.1(eng): Audio: ac3, 48000 Hz, 6 channels, s16
Stream mapping:
  Stream #0.0 -> #0.0
  Stream #0.1 -> #0.1
Could not write header for output file #0 (incorrect codec parameters ?)



thuriel posted 2009 Nov 20 05:17
:\


Baldrick posted 2009 Nov 20 05:28
Try add
-f mp4 -r 29.970 -s 720x400 -aspect 4:3

and see if it makes any difference.



thuriel posted 2009 Nov 21 05:55
Thanks for your help, but I get exactly the same error message :/

:
Could not write header for output file #0 (incorrect codec parameters ?)


Good example for why upgrading not always is a good idea.



Herve posted 2009 Nov 21 08:31
thuriel :
:
[...]
[mp4 @ 0x1076800]track 1: codec frame size is not set
[...]
Could not write header for output file #0 (incorrect codec parameters ?)
set size according to your input file:
-s 720x480

my advices will be to change audio file format (AC3 in .mp4 is not well handle by most players), prefer aac
and add a "h264 magic cleaner"

->
:
ffmpeg -i video.mkv -s 720x480 -vcodec copy -vbsf h264_mp4toannexb -acodec aac -ab 384k -y video.mp4

and depending on displayed errors, add some others args (like framerate, etc)

bye



pepegot1 posted 2009 Nov 21 08:42
Try WinFF



Login/Register to our forum to be able to post here.








Slysofts AnyDVD HD removes DVD and Blu-ray encryption and region coding. More info or download trial!
About   Advertise   Forum Archive   RSS Feeds   Statistics