HydrogenAudio

Lossless Audio Compression => FLAC => Topic started by: verloren on 2002-07-25 20:33:05

Title: FLAC to Ogg
Post by: verloren on 2002-07-25 20:33:05
I'm looking for suggestions of the easiest way to transcode between FLAC and Ogg.  I really like OggDropXPd, so anything similarly straightforward would be great.

Cheers, Paul
--
Rarewares mirror at http://audio.ciara.us/rarewares (http://audio.ciara.us/rarewares)
Title: FLAC to Ogg
Post by: spoon on 2002-07-25 21:01:09
dBpowerAMP Music Converter - with the Ogg Codec (now Version 1) and FLAC (now 1.0.3) from codec central on my site, it will keep your ID tags - and even map the correct tag name (Ogg has different ones for Track Number than the rest of the world).
Title: FLAC to Ogg
Post by: Infophreak on 2002-07-25 21:09:15
IIRC, there is a FLAC commandline decoder. Under the assumption that it is called "flacdec" (probably wrong, but you get the point), which decodes a FLAC compressed file to console (not to a file), a usable commandline would be:

flacdec "filename.wav" | oggenc -q 5 -o "output.ogg" -

obviously, you'd need flacdec and oggenc to be in your path (/bin, /usr/bin, c:winnt or whatever your current OS likes)

for doing the same to multiple FLAC files under windows, try the following:

for %f in (*.flac) do flacdec "%f" | oggenc -q 5 -o "%f.ogg" -

the only problem with this command is that you get a bunch of files named .flac.ogg, but that's nothing a short perl-script can't fix.

If the windows commandline supported escaped characters (fat chance that'll ever be impletmented), i'd write:

for %f in (*.flac) do flacdec "%f" | oggenc -q 5 -o "%fbbbbogg" -

but alas, the commandline has gotten worse and worse ever since win98 :

if you are running a pre win2k version of windows, you might need to do a LFNFOR ON in the console first.

feel free to use any other quality parameter, that you like
Title: FLAC to Ogg
Post by: verloren on 2002-07-25 21:11:27
Looks good - thanks!
Title: FLAC to Ogg
Post by: Emanuel on 2002-07-25 22:10:05
OggdropXPd uses libsndfile for handling file formats. The author Erik wrote that he will have some work to do until 1.0.0rc3 is finished. Version 1.0.0 will follow soon after, and then he will have a look at FLAC support. I hope John33 will have the serious look at FLAC support as he stated on the thread here:
http://www.hydrogenaudio.org/forums/showth...ht=oggdrop+flac (http://www.hydrogenaudio.org/forums/showthread.php?s=&threadid=1813&highlight=oggdrop+flac)

Spoon: I do like your app! I think the more support FLAC and Vorbis will get, it's for the better.

Emanuel
Title: FLAC to Ogg
Post by: john33 on 2002-07-25 22:42:00
Paul, a simple batch file like:
Code: [Select]
rem Usage: flac2ogg quality (like 0, or 6.25) input file name

@echo off

flac.exe -s -d -c %2 | oggenc.exe -q %1 - -o %2.ogg

will process one at a time.
Title: FLAC to Ogg
Post by: jcoalson on 2002-07-26 01:35:55
Quote
Originally posted by verloren
I'm looking for suggestions of the easiest way to transcode between FLAC and Ogg.  I really like OggDropXPd, so anything similarly straightforward would be great.


You might also look into sonice (http://www.cyclooctane.com/sonice/)

Josh
Title: FLAC to Ogg
Post by: meff on 2002-07-26 02:12:03
heres my nix code for flac -> mpp
you can easily modify it for ogg

a bit hackish though i wrote it very quickly awhile ago..

convertflactompp.pl
Code: [Select]
#!/usr/bin/perl -w
#
# quick&dirty.
# convert flac's in specified directory to mpp(mpc).
# rodney "meff" gordon ii.
#
# sat9feb 7.01pm 2002
#

use strict;

if(!defined($ARGV[0]) || !defined($ARGV[1])) {
       print "not enough arguments.n";
       print "runopts: ./thisexec srcdir dstdirnnsucks from src and spits into dst.n";
       exit;
}

my @flacs;

# set this to a dir with lots of space (holds uncompressed wavs)
my $tmpDir = '/home/meff/tmp/';

my $srcDir = $ARGV[0];
my $dstDir = $ARGV[1];

# sanity checks
unless(-d $srcDir && -d $dstDir) {
       print "either src or dst dir does not exist.n";
       exit;
}

# read in the files, sort out the flacs
opendir(DIR, $srcDir);
my @dirRead = readdir(DIR);
closedir(DIR);
foreach(@dirRead) {
       if($_ =~ m/.flac$/) {
               push(@flacs, $_);
       }
}


##
## CORE
##

# main loop
foreach(@flacs) {
       ConvertToMpp($_);
}
exit;


sub ConvertToMpp {
       my $flac = shift;

       # generate the names
       my $flacWav = $flac;
       my $flacMpp = $flac;
       $flacWav =~ s/.flac/.wav/;
       $flacMpp =~ s/.flac/.mpc/;

       print "converting $srcDir/$flac to $tmpDir/$flacWav" . "...n";
       system("flac -d -o "$tmpDir/$flacWav" "$srcDir/$flac"");
       print "n";

       print "encoding $tmpDir/$flacWav to $dstDir/$flacMpp" . "...n";
       system("mppenc --xtreme "$tmpDir/$flacWav" "$dstDir/$flacMpp"");
       print "n";

       print "cleaning up...n";
       system("rm "$tmpDir/$flacWav"");
       print "n";

       print "$srcDir/$flac conversion to $dstDir/$flacMpp complete.n";
}
Title: FLAC to Ogg
Post by: Dezibel on 2002-07-26 09:34:14
...and a little bit cleaner:

Code: [Select]
#!/usr/bin/perl



# flac2ogg Version 0.2

# Copyright (C) 2002 Dezibel <dezibel@email.com>





my $flac = "flac";         # replace with 'C:Programmeflac.exe' for windows

my $encoder = "oggenc";    # replace with 'C:Programmeoggenc.exe' for windows

my $comline = "-q6";       # replace with your commandline





if($ARGV[0] eq '') { die "nno path given! try "flac2ogg <path>"nn"; }



chdir("$ARGV[0]") or die "ncan't change to $ARGV[0]!nn";

@flacs = glob("*.flac");



foreach(@flacs) {

   @name = split /./, $_;

   rename("$_", "tmp.flac");

   system("$flac -d tmp.flac");

   rename("tmp.flac", "$_");

   system("$encoder $comline tmp.wav");

   unlink("tmp.wav");

   rename("tmp.ogg", "$name[0].ogg");

}



print "nall jobs done!nn";


put this code to an file "flac2ogg"
change ther rights from this file: "chmod ugo+x flac2ogg"
and copy this file as root to "/usr/bin/flac2ogg"

to transcode: flac2ogg <path> (the destinations files are in source path)

edit: little modifications for portability.

Dezibel
Title: FLAC to Ogg
Post by: Jon Ingram on 2002-07-26 09:52:55
All this Perl... my eyes are watering. Do none of you use a decent (http://www.python.org) programming language?

Title: FLAC to Ogg
Post by: Dezibel on 2002-07-26 10:03:17
nope

Dezibel
Title: FLAC to Ogg
Post by: meff on 2002-07-26 10:03:31
Quote
Originally posted by Jon Ingram
All this Perl... my eyes are watering. Do none of you use a decent (http://www.python.org) programming language?



Python
I rather code C#

Well, perl, php.. i386 and sparc asm, and c.. and various shell languages, all have ups and downs, but I have the most fun with perl..
Title: FLAC to Ogg
Post by: Dezibel on 2002-07-26 10:10:39
Quote
Originally posted by meff
but I have the most fun with perl..


...yes!

Dezibel

--
tr "windolfs" "linux"