2

When I calculate the duration of each individual file I want to concatenate I get 10.24 for both. So I figured when I concatenate the two files I would get a duration of file A plus file B or 10.24 + 10.24 giving me a total duration of 20.48 for the combined file. But no matter what command I use to concentrate I cannot get the same duration. Am I doing something wrong?

ffprobe -i "audioA.mp3" -show_entries format=duration -v quiet -of csv="p=0"
10.24 
ffprobe -i "audioB.mp3" -show_entries format=duration -v quiet -of csv="p=0"
10.24 

Which makes a total of 10.24 + 10.24 = 20.48 seconds

But when I concatenate the files I get a different duration. Here are my different tries.

Try 1

FFMPEG -y -i 'concat:audioA.mp3|audioB.mp3' -map 0:a -codec:a copy -map_metadata -1 output.mp3
ffprobe -i "output.mp3" -show_entries format=duration -v quiet -of csv="p=0"
20.610612

Try 2

FFMPEG -y -i audioA.mp3 -i audioB.mp3 -filter_complex [0:a][1:a]concat=n=2:v=0:a=1 output.mp3
ffprobe -i "output.mp3" -show_entries format=duration -v quiet -of csv="p=0
20.453878

Try 3

FFMPEG -y -i 'concat:audioA.mp3|audioB.mp3' output.mp3
ffprobe -i "output.mp3" -show_entries format=duration -v quiet -of csv="p=0"
20.506122
  • Is there a command to use to concatenate that will output a file with the same duration?
  • Is there a way to do that without reencoding?
  • What makes the durations different in the combined files above?
John Pollard
  • 3,729
  • 3
  • 24
  • 50
  • From my experience with FFmpeg, it's complicated to achieve a precise duration. I have seen the duration of my outputs changing depending on the format, the codec and the filters used (obivously). If you want to concatenate them without reencoding, you have information [there](https://stackoverflow.com/questions/49371422/how-to-merge-two-videos-without-re-encoding) – Jao Sep 21 '20 at 14:01
  • Yea the thing is both the files are the same exact file. So it's the same codec bitrate - everything is the exact same. Not sure why the duration would be different when put together. And the calculated durations are always consistent. – John Pollard Sep 21 '20 at 19:30
  • Did you manage to keep the same duration? I am interested in the solution – user3884677 Apr 15 '21 at 12:37
  • I did not unfortunately :/ – John Pollard Mar 08 '23 at 21:03

0 Answers0