VideoHelp Forum
+ Reply to Thread
Results 1 to 20 of 20
Thread
  1. Member
    Join Date
    May 2007
    Location
    Germany
    Search Comp PM
    I need to put the video and audio streams of an MKV file into an MP4 container. So I tried:

    Code:
    $ ffmpeg -i video.mkv -vcodec copy -acodec copy video.mp4
    But, what I get is this error message:

    Code:
    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!

    Do I have to to specify any parameters to pack AC3 into MP4?
    Quote Quote  
  2. I'm a MEGA Super Moderator Baldrick's Avatar
    Join Date
    Aug 2000
    Location
    Sweden
    Search Comp PM
    What ffmpeg version are you using? You probably need a very new build.
    Quote Quote  
  3. Member Soopafresh's Avatar
    Join Date
    Jan 2004
    Location
    United States
    Search Comp PM
    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.
    "Quality is cool, but don't forget... Content is King!"
    Quote Quote  
  4. Member
    Join Date
    May 2007
    Location
    Germany
    Search Comp PM
    I compiled it from SVN (SVN-r20255) just three days ago:

    Code:
    $ 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 :/
    Quote Quote  
  5. I'm a MEGA Super Moderator Baldrick's Avatar
    Join Date
    Aug 2000
    Location
    Sweden
    Search Comp PM
    Could you list what the mkv contain? ffmpeg should show some info.

    Or maybe try mp4box if you can find a mac version.
    Quote Quote  
  6. Member
    Join Date
    May 2007
    Location
    Germany
    Search Comp PM
    I'd prefer to use ffmpeg :/

    Here is the complete output:

    Code:
    $ 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 ?)
    Quote Quote  
  7. Member
    Join Date
    May 2007
    Location
    Germany
    Search Comp PM
    :\
    Quote Quote  
  8. I'm a MEGA Super Moderator Baldrick's Avatar
    Join Date
    Aug 2000
    Location
    Sweden
    Search Comp PM
    Try add
    -f mp4 -r 29.970 -s 720x400 -aspect 4:3

    and see if it makes any difference.
    Quote Quote  
  9. Member
    Join Date
    May 2007
    Location
    Germany
    Search Comp PM
    Thanks for your help, but I get exactly the same error message :/

    Code:
    Could not write header for output file #0 (incorrect codec parameters ?)
    Good example for why upgrading not always is a good idea.
    Quote Quote  
  10. Originally Posted by thuriel
    Code:
    [...]
    [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"

    ->
    Code:
    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
    For DVD, iPad, HD, connected TV, … iMovie & FCPX? MovieConverter-Studio 3 (01/24/2015) - Handle your camcorder's videos? even in 60p or 60i? do a slow-motion? MovieCam.
    Quote Quote  
  11. Member
    Join Date
    Aug 2002
    Location
    South Florida
    Search Comp PM
    Try WinFF
    Quote Quote  
  12. Member
    Join Date
    May 2007
    Location
    Germany
    Search Comp PM
    Thanks, Herve. I do not want to transcode the audio stream because of quality loss. And since the MP4 container officially supports AC3 I think this should be possible.

    I specified the framesize and added this "magic cleaner". Still get the same error message ("Could not write header for output file #0 (incorrect codec parameters ?)"). I assume that ffmpeg is not able to process AC3 in MP4.

    Even when I try to transcode my AC3 to AAC I get errors:

    Code:
    $ ffmpeg -i video.mkv -f mp4 -r 29.970 -s 720x480 -aspect 4:3 -vcodec copy -vbsf h264_mp4toannexb -acodec aac -ab 384k -y video.mp4
    ...
    [NULL @ 0x1077800]error, non monotone timestamps 567 >= 300
    av_interleaved_write_frame(): Error while opening file
    I guess there is only one option left: Hating ffmpeg :/

    Anyway, thanks for all your help. And, pepegot1, there is no Mac version of WinFF, but thanks anyway.
    Quote Quote  
  13. Originally Posted by thuriel
    Still get the same error message ("Could not write header for output file #0 (incorrect codec parameters ?)"). I assume that is not able to process AC3 in MP4.
    there is no concern (for FFmpeg) to wrap AC3 in mp4 (but -last time I tried- QuickTime is not able to read it for example)

    Even when I try to transcode my AC3 to AAC I get errors:
    now the error is not the same

    Code:
    [NULL @ 0x1077800]error, non monotone timestamps 567 >= 300
    non continuous "displayed frames" values (should mean that your file is broken or …ended for FFmpeg)
    Code:
    av_interleaved_write_frame(): Error while opening file
    …are you sure that your video is not broken?
    you could try to wrap it again with VLC (no transcode, just to wrap again audio and video, values should be continuous now)

    bye
    For DVD, iPad, HD, connected TV, … iMovie & FCPX? MovieConverter-Studio 3 (01/24/2015) - Handle your camcorder's videos? even in 60p or 60i? do a slow-motion? MovieCam.
    Quote Quote  
  14. DECEASED
    Join Date
    Jun 2009
    Location
    Heaven
    Search Comp PM
    Originally Posted by thuriel
    And since the MP4 container officially supports AC3 I think this should be possible.
    To the best of my knowledge, only the recent versions of MP4Box and mp4creator
    support wrapping AC3 in the MP4 container. And AFAIK, only the MPC-HC MP4 splitter
    is able to detect AC3 and connect it to an AC3 decoder.

    Sadly the official specs do not guarantee that a feature that should be implemented
    will actually be implemented. Today MP4 "officially" supports AC3, DTS, and VC-1, but...

    so what?
    Quote Quote  
  15. Member
    Join Date
    May 2007
    Location
    Germany
    Search Comp PM
    Originally Posted by Herve
    …are you sure that your video is not broken?
    Quite sure. Every player I used played the video fine (VLC, MPlayer and Quicktime). Besides, I get this Errors from any MKV file (I tried so far).

    Originally Posted by Herve
    you could try to wrap it again with VLC (no transcode, just to wrap again audio and video, values should be continuous now)
    Thanks! I will try this method, when there's some time left in my busy schedule

    Originally Posted by El Heggunte
    And AFAIK, only the MPC-HC MP4 splitter
    is able to detect AC3 and connect it to an AC3 decoder.
    Well, the PS3 also supports H.264/AC3 in MP4
    Quote Quote  
  16. DECEASED
    Join Date
    Jun 2009
    Location
    Heaven
    Search Comp PM
    Originally Posted by thuriel
    Originally Posted by El Heggunte
    And AFAIK, only the MPC-HC MP4 splitter
    is able to detect AC3 and connect it to an AC3 decoder.
    Well, the PS3 also supports H.264/AC3 in MP4
    I wasn't aware of that. Thanks for the updated info.
    Quote Quote  
  17. Originally Posted by thuriel
    Originally Posted by Herve
    …are you sure that your video is not broken?
    Quite sure. Every player I used played the video fine (VLC, MPlayer and Quicktime). Besides, I get this Errors from any MKV file (I tried so far).
    For info:
    - QuickTime first loads your mkv (slow) and build its own private index only available by QuickTime (so you don't have to care with broken files)
    - VLC and Mplayer are real-time streaming softwares, so they accept broken files. They uses Presentation"timecodes"(PTS) and Display"TimeCode"(DTS) to manage to display the stream and keep synch, even if the file is not full (a hole in its middle).
    But FFmepg is not a real-time streaming software, it wants continuous PTS = a valid video file

    bye
    For DVD, iPad, HD, connected TV, … iMovie & FCPX? MovieConverter-Studio 3 (01/24/2015) - Handle your camcorder's videos? even in 60p or 60i? do a slow-motion? MovieCam.
    Quote Quote  
  18. Member
    Join Date
    Apr 2012
    Location
    Omaha, NE
    Search Comp PM
    It's an old thread, but I just had the same problem.

    I also received the message "ffmpeg codec frame size is not set".

    With a little playing around, I extracted the following: "Incompatible sample format 's16' for codec 'ac3', auto-selecting format 'flt'" -- my ac3 file had sample format s16.

    The solution was to specify -c:a ac3 or -acodec ac3, not -c:a copy or -acodec copy (even though the final product has the exact same format/same bitrate/same sample rate). This let ffmpeg auto-"correct" the sample format from s16 to flt.
    Quote Quote  
  19. (message deleted)
    Edit : oops! I didn't notice that it was an old thread (so my "previous and deleted answer" has no more interest. Next time I will finish to read the topic before answering )
    For DVD, iPad, HD, connected TV, … iMovie & FCPX? MovieConverter-Studio 3 (01/24/2015) - Handle your camcorder's videos? even in 60p or 60i? do a slow-motion? MovieCam.
    Quote Quote  
  20. about your warnings:
    Originally Posted by brs5tettba View Post
    "Incompatible sample format 's16' for codec 'ac3', auto-selecting format 'flt'" -- my ac3 file had sample format s16.
    it's a warning (not an error)
    you didn't say which channel order you want, so ffmpeg use its default one (and warn it to you)

    PS:
    "ffmpeg codec frame size is not set"
    …usually means:
    - an error in parameters
    - an argument forgotten (eg: the video size argument, but not always: it will be too simple to understand these messages )

    bye
    For DVD, iPad, HD, connected TV, … iMovie & FCPX? MovieConverter-Studio 3 (01/24/2015) - Handle your camcorder's videos? even in 60p or 60i? do a slow-motion? MovieCam.
    Quote Quote  



Similar Threads

Visit our sponsor! Try DVDFab and backup Blu-rays!