split mp3 or extract audio from video
split mp3 or extract audio from video
Split your audio or extract parts from it
Sometimes you want to split an audio file into pieces, e.g. split a large audiobook into smaller parts.This could be useful since sometimes the input audio is read incorrectly by players. My phones player shows that the audio length is 58mins, while the actual length is 90mins. This wont let me rewind the media.
Or you might want to cut out some parts of the media - parts with silence, noise etc.
If you only have one file - install the audacity and split the file or extract the parts the way you want. Use this as an example guide.
For multiple files you might want to use some command line tool and have the same actions applied to all of them.
Good tool for this is avconv from libav-tools. This packet is already installed on my system, install it manually if needed.
The command you need is:
avconv -i "$yourfile" -t $part_duration -ss $skip_time -acodec copy -y "$output_file"
-i - your input file
-t - duration of the part you extract. Can be specified in seconds or as hh:mm:ss
-ss - how much time should be skipped from the beginning of the input audio
-y - the destination file for the output
A simple script can do the batch processing - split all the input audio files 30min long. Assume the max length of input is 9000 seconds
#!/bin/bash
#split audio file, output the same codec as input
#time in seconds - the duration of the parts
x=1800
for i in "$@"
do
sum=0
while test $sum -lt 9000
do
ext="${i: -3}"
fname="$i".$sum.$ext
avconv -i "$i" -t $x -ss $sum -acodec copy -y "$fname"
sum=$((sum+x))
size=$(stat -c%s "$fname")
#if the output is small->remove (usually when the input has ended on earlier iterations)
if test $size -lt 3000
then rm "$fname"
fi
done
done
Extract audio from video
avconv can do this as well.Add the -nv flag to disable the video rendering.
This example extracts the original audio, I suggest to do the recoding (with avconv) in the second step, since it produces strange results if you attempt all at once.
#extract the original track
% avconv -i video.mp4 -t 10 -ss 0 -acodec copy -vn -y sound.aac
#recode to ogg
% avconv -i sound.aac -acodec libvorbis -y sound.ogg
For single files use the GUI way - install avidemux.
#extract the original track
% avconv -i video.mp4 -t 10 -ss 0 -acodec copy -vn -y sound.aac
#recode to ogg
% avconv -i sound.aac -acodec libvorbis -y sound.ogg
For single files use the GUI way - install avidemux.
It allows you to select the region and extract the sound from it.
download file now
Comments
Post a Comment