How to cut audio file with avconv?
Solution 1
I think the original problem was with the formatting of your time stamp.
The format is HH:MM:SS
I am not sure I am understanding your question about the order of the options. I do not think it matters as long as -i is followed by the input file name and -ss HH:MM:SS followed my -t HH:MM:SS
The -ss HH:MM:SS is the starting point, and -t HH:MM:SS is the duration
so -ss 00:01:00 -t 00:05:00 would start at the one minute mark and run for 5 minutes.
On my system, using ffmpeg, order does not matter (you can specify time or input file in any order so long as -ss is followed by the duration (-t) )
Solution 2
The problem comes from the different meaning of -ss
depending upon where in the command line it is. It's a carry over from the days when avconv
was still a part of ffmpeg
project, and i believe it is being fixed in the newer versions.
In the olden days if you said something like
ffmpeg -ss 5 -i input
What you meant was "skip to the 5 second mark in the file and begin to read there".
But if you said
ffmpeg -i input -ss 5
You meant "open the input file and skip all the data until the five second mark".
As you can understand the first approach will actually fail quite often, because you are skipping in the file without reading it. It works well only on the files which have timestamps in them, allowing you to read the frame and know if you've gone too far already or not.
Basically the way it worked in ffmpeg was "Guess the bitrate by the first second, and then assume that all other seconds are the same". But, of course, not all the seconds are the same, and if we are talking about a 52 hours of "drift" the error can be quite large.
So if you are using the early post-split version of avconv you should always put -ss
after the file that is being read. But in the newer versions (to the best of my knowledge) this bug was fixed.
x-yuri
Updated on September 18, 2022Comments
-
x-yuri over 1 year
I have a hard time trying to figure out how to cut a file with
avconv
. Here's the command I use:avconv -ss 52:13:49 -t 01:13:52 -i RR119Accessibility.wav RR119Accessibility-2.wav
But it doesn't work. I get the whole file as a result. Well, almost the whole file. Somehow the resulting file has duration
1:16:31
instead of1:17:23
. Also I believe I executed this command in every possible way: with-ss
and-t
after-i
, with-t
specifying ending point, with mp3 files, with specifying audio codec, withffmpeg
. Am I doing it wrong?UPD Thanks to
bodhi.zazen
this works (I corrected the offset and duration reported bymp3splt-gtk
, they were wrong for some reason or other, and the goal was to cut mp3 file)avconv -i RR119Accessibility.mp3 -ss 00:52:08 -t 00:01:08 RR119Accessibility-2.mp3
But this doesn't:
avconv -ss 00:52:08 -t 00:01:08 -i RR119Accessibility.mp3 RR119Accessibility-2.mp3
The resulting file start at 00:52:08 and goes until the end of the original file. I thought
-ss
and-t
are related to input file if specified before-i
. And to output file otherwise. Could someone explain this?-
Panther over 10 yearsthe time format is HH:MM:SS, is the file really 50+ hours long? personally I use ffmpeg
-
x-yuri over 10 yearsOh, you're right. I remember I thought about it but somehow I decided that I'm not mistaken.
-
Panther over 10 yearsso is it working now?
-
x-yuri over 10 yearsBasically, yes. But there is one minor thing I don't understand. I've updated the question. But anyway, you can turn your comment into answer and I'll accept it. And I use
avconv
becauseubuntu
'sffmpeg
says that it's obsolete.
-
-
Panther over 10 yearsI do not think ffmpeg is depreciated. Unless you have a specific need for an updated verson of ffmpeg, you should probably stay with the version in the repos.
-
x-yuri over 10 yearsBut that's what it says: "*** THIS PROGRAM IS DEPRECATED *** This program is only provided for compatibility and will be removed in a future release. Please use avconv instead." But yes, unless I have a specific need, I can probably use the version in the repos.
-
x-yuri over 10 years
-
x-yuri over 10 yearsWell, out of 4 variants (
ffmpeg -i -ss -t
,ffmpeg -ss -t -i
,avconv -i -ss -t
,avconv -ss -t -i
), only the last one doesn't work as expected. That is, instead of getting [offset:offset+specified-duration] I get [offset:original-duration] (if that clarifies matters). If you've got any ideas, I'm all ears :) -
x-yuri over 10 yearsAnd this way it works:
avconv -ss ... -i ... -t ... ...
-
thom over 10 yearsYes x-yuri, that is correct. The current ffmpeg (by ffmpeg) is many versions newer than the old (depricated) hog shipped by libav. Pity they don't co-exist in the repo's
-
x-yuri over 9 yearsThis seems to be some other issue. Both variants start with the right offset, it's the duration that is wrong in the first variant.