I want to generate a new (fully valid) MP3 file from an existing MP3 file. The new file should only contain the last N seconds of the track.
There's -t
option in avconv
for getting first N seconds:
-t duration (output)
Stop writing the output after its duration reaches duration. duration may be a number in seconds, or in "hh:mm:ss[.xxx]" form.
Is there an option to crop last N seconds? avconv
is not requirement in my case, all other tools are acceptable.
You can simply use
ffprobe
to get the duration of the audio.Calculate nth_second and use it with
ffmpeg
Following is the shell script for the process.