Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I am converting a FLAC file to AAC. I have noticed that the duration is off on the output file. This is even the case if you explicitly set the output duration, it just gets ignored

$ ffmpeg -i foo.flac -t 00:02:52.48 -c:a aac -strict -2 bar.aac
ffmpeg version N-51211-ge0e8c20 Copyright (c) 2000-2013 the FFmpeg developers
  built on Mar 22 2013 09:01:53 with gcc 4.7.2 (GCC)
  configuration: --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-libilbc --enable-libmp3lame 
--enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg 
--enable-libopus --enable-librtmp --enable-libschroedinger --enable-libsoxr
--enable-libspeex --enable-libtheora --enable-libtwolame
--enable-libvo-aacenc --enable-libvo-amrwbenc --enable-libvorbis
--enable-libvpx --enable-libx264 --enable-libxavs
--enable-libxvid --enable-zlib
[flac @ 000000000035d960] max_analyze_duration 5000000 reached at 5015510 microseconds

Input #0, flac, from 'foo.flac':
  Duration: 00:02:52.48, bitrate: 446 kb/s
    Stream #0:0: Audio: flac, 44100 Hz, stereo, s16
Output #0, adts, to 'bar.aac':
    Stream #0:0: Audio: aac, 44100 Hz, stereo, fltp, 128 kb/s
Stream mapping:
  Stream #0:0 -> #0:0 (flac -> aac)
Press [q] to stop, [?] for help
size=    2770kB time=00:02:52.50 bitrate= 131.5kbits/s
video:0kB audio:2719kB subtitle:0 global headers:0kB muxing overhead 1.867920%

result

$ ffmpeg -i foo.flac -i bar.aac    
Input #0, flac, from 'foo.flac':
  Duration: 00:02:52.48, bitrate: 446 kb/s
Input #1, aac, from 'bar.aac':
  Duration: 00:02:49.29, bitrate: 134 kb/s

Can I change my command so that the input and output duration match?

share|improve this question

1 Answer 1

up vote 4 down vote accepted

A 'raw' AAC file contains no information about the file's contents. When you enable all debug info you can see that the time is measured depending on the bitrate when importing aac files:

[aac @ 0xa82ba40] Estimating duration from bitrate, this may be inaccurate

But, when you package your aac file in e.g. a MPEG-4 container, all desired contents are stored in the container. Try encoding your flac audio file to aac and mux it into a .m4a container using these parameters and see what happens if you import the .m4a file again:

ffmpeg -i foo.flac -t 00:02:52.48 -c:a aac -strict -2 bar.m4a

share|improve this answer
1  
.m4a (which is literally an MP4 file under a different name) is customarily used for MP4 files containing only audio, and ffmpeg recognises output.m4a as an MP4 file. +1 though, good answer. –  evilsoup Mar 25 '13 at 10:56
    
Thanks, you're right, I edited my answer to match the right MPEG4 container for only audio. –  Nick van Tilborg Mar 25 '13 at 11:17

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.