Showing posts with label ogg. Show all posts
Showing posts with label ogg. Show all posts

Sunday, June 13, 2010

Cut mp3 and ogg files without decoding

Audio editing software (in many cases at least) is decoding the audio files before edit. At the end they are encoded again. If you only want to split the file with the mentioned method the quality of the file decreases.
The command line tool mp3splt [1] does that job (without de-/encoding) for mp3 and ogg files. (And there is even a gtk-gui.)

The basic command is just:

mp3splt [options] filename starttime endtime

e.g. mp3splt -f filename.mp3 02.55 06.22
Option -f for variable bitrates
The output will be in filename_02m_55s__06m_22s.mp3

There are several options. Take a look at the manual [2].

[1] http://mp3splt.sourceforge.net
[2] http://mp3splt.sourceforge.net/mp3splt_page/documentation/man.html

Monday, May 11, 2009

Noise reduction with audacity

I recorded some interviews for my PhD thesis during OpenExpo (in Bern). The background noise unfortunately was very loud so I had to concentrate very hard while listening. Audacity has the nice effect "noise reduction". I tried it and normalized the track afterwards. The difference is magnificent. Now it's easy to understand the answers to my questions, althou the voices sound a little bit unnatural now (but that doesn't matter).

Thursday, April 30, 2009

How to convert wma to ogg

How can I convert all *.wma to *.ogg in one directory?
I first tried the approved ffmeg. That one helped me many times with good results.

Version 1:
find -name '*wma' -exec ffmpeg -i {} -acodec vorbis -ab 128k {}.ogg \;
rename 's/\.wma//' *\.wma\.ogg
(Test the renameing: rename --no-act --verbose 's/\.wma//' *\.wma\.ogg)
or

Version 2:
for i in *.wma; do ffmpeg -i "$i" -vn -acodec vorbis -ab 128k "${i/.wma}".ogg; done
# ffmpeg: -vn => novideo, -acodec vorbis => ogg-encoder, -ab set audio bitrate to 128k (64 is standard. That option doesn't seem to work with ogg :-(
# ${i/.wma} is cutting the filename $i from ".wma"

The quality gets really worse.

Best quality with version 3:

1. Step: Convert wma to flac with ffmeg
ffmpeg -i input.wma -vn -acodec flac output.flac

2. Step: Convert flac to ogg with oggenc
oggenc input.flac -q2 -o output.ogg
# -q quality 2 (1 bad .. 10 excellent)
# -o output-file

Or all in one line to convert the whole directory:
for i in *.wma; do ffmpeg -i "$i" -vn -acodec flac -y tmp.flac; oggenc tmp.flac -q2 -o "${i/.wma}".ogg; done; rm -f tmp.flac
# -y Overwrite output files.
# rm -f delete without further questions

Wednesday, December 24, 2008

Convert ogg to mp3

My sister is here for the holidays. Unfortunately her mp3 player only supports mp3 and no ogg. :-(
I helped her to convert their ripped ogg files from her kubuntu system into mp3 files. The following command transforms the whole directory from ogg in mp3.

for i in *.ogg; do sox "$i" "${i/.ogg}".mp3; done

(sox old.ogg neu.mp3 is the basic command to transform ogg to mp3.)

Sunday, November 16, 2008

Extract mp3 from flv

Tonight I tried to rip the audio track from a flv file. First I wanted to convert it into ogg but as the audio track is a mp3 stream itself I decided just to rip the mp3 data into a file (same quality as in the video file. A higher samplerate would only increase filesize).

UPDATE: Today the audiostream is often aac (not mp3 anymore). That means, you have to use mp4 instead of mp3 with ffmpeg ... -f mp4 ... .mp4).

One of those commands will do the job:
mplayer -dumpaudio in-video.flv -dumpfile out-audio.mp3
ffmpeg -i input.flv -f mp3 -vn -acodec copy output.mp3

To convert all files (*.flv to *.mp3) in the directory use one of the following commands:
for i in *.flv; do mplayer -dumpaudio -dumpfile "${i/.flv}".mp3 "$i"; done
for i in *.flv; do ffmpeg -i "$i" -f mp3 -vn -acodec copy "${i/.flv}".mp3; done

#ffmpeg: -f mp3 => force mp3 format, -vn => novideo, -acodec copy => stream-copy
# ${i/.flv} is cutting the filename $i from ".flv"

UPDATE: As the files are not always in the same format and my portable music player couldn't play mp4 I decided to convert them to ogg.
ffmpeg -i input.flv/mp4 -vn -acodec vorbis output.ogg

This script will transform all flv files in your directory into mp3 files.

1. Create a new file e.g. with kate and name it flv2mp3.sh

#!/bin/bash
for i in *.flv
do
echo "$i"
# Alternative 1
# mplayer -dumpaudio -dumpfile "${i/.flv}".mp3 "$i"
#Alternative 2
ffmpeg -i "$i" -f mp3 -vn -acodec copy "${i/.flv}".mp3
done

2. Change the right of this file:
chmod +x flv2mp3.sh

3. Goto the directory and run the script