Quantcast
Channel: How to remove last 4 seconds of MP3 file? - Ask Ubuntu
Viewing all articles
Browse latest Browse all 5

Answer by Aenfa for How to remove last 4 seconds of MP3 file?

$
0
0

You can use ffprobe that should come with ffmpeg to get the duration.

dur=$(($(ffprobe -loglevel error -show_entries format=duration -of default=nk=1:nw=1 inputfilename | xargs printf %.0f)-4))ffmpeg -t ${dur} -i inputfilename -c copy outputfilename

The first line uses ffprobe to get the duration minus 4 seconds then puts it in a var called dur.

I have also used xargs to round the number because bash only accepts whole numbers when doing math operations.

You can use bc if you need more accuracy.

dur=$(ffprobe -loglevel error -show_entries format=duration -of default=nk=1:nw=1 inputfilename)dur=$(bc <<< ${dur}-4)ffmpeg -t ${dur} -i inputfilename -c copy outputfilename

Viewing all articles
Browse latest Browse all 5

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>