Skip to main content

Notice

Please note that most of the software linked on this forum is likely to be safe to use. If you are unsure, feel free to ask in the relevant topics, or send a private message to an administrator or moderator. To help curb the problems of false positives, or in the event that you do find actual malware, you can contribute through the article linked here.
Topic: FLAC to Vorbis in linux (Read 4594 times) previous topic - next topic
0 Members and 2 Guests are viewing this topic.

FLAC to Vorbis in linux

Is it possible to transcode from flac (with oggtags) to vorbis in console (linux) and not loosing the oggtags?
Almost like Oggifier for windows without the GUI?


metrom

FLAC to Vorbis in linux

Reply #1
If you compile the CVS version of oggenc 'successfully,' then it should work. You'll need all the relevant development libraries, including those for FLAC.

I've never been able to do that on my system though.

FLAC to Vorbis in linux

Reply #2
The cvs version of oggenc does not support FLAC
you need the patch from http://www.ph.utexas.edu/~volsung/patches/

btw... the tags are called vorbiscomments and not oggtags as they aren't implemented into the ogg layer

FLAC to Vorbis in linux

Reply #3
Oops. I stand corrected.

I asked volsung himself about this, and he says the patches will be merged into CVS. He was gracious to say that he'll tell me when it's done.

Sorry for the incorrect information, have a nice day. : )

FLAC to Vorbis in linux

Reply #4
Strangely enough I wrote a shell script to do this a few days ago.  Here it is.

Code: [Select]
#!/bin/bash

set -e

while [ -n "$1" ]
do
 out=$(basename $1 | sed 's/flac$/ogg/')
 flac -sdc "$1" | oggenc -q 6 -o "$out" -
 metaflac --export-vc-to=- "$1" | grep -v ^REPLAYGAIN_ |
 vorbiscomment -w "$out" "$out".tmp.$$ &&
 mv "$out".tmp.$$ "$out"
 shift
done

FLAC to Vorbis in linux

Reply #5
Also strangely, I too wrote a Perl script last week to do the same thing.  It generates Ogg Vorbis files if run as "flac2ogg", or MP3's if run as "flac2mp3", moving the tags in either case.  I recently started ripping everything to FLAC, though I "compile" the files to MP3 for use with an Audiotron.

Code: [Select]
#!/usr/bin/perl
#
# flac2ogg / flac2mp3
#
# Converts FLAC files to Ogg Vorbis or MP3, depending on how
# this file is named.
#
# The encoded file is placed in the current directory, or optionally
# the directory specified with the -d option.
#
# Requires "metaflac", "oggenc", and "lame".

# MP3 quality setting
$preset = "standard";

# Ogg Vorbis quality setting
$q = "6";


use Getopt::Std;
use File::Basename;
use File::Spec;

$myname = (File::Spec->splitpath($0))[2];

getopts('td:', \%opt);

$dest = $opt{'d'} || ".";
$test = $opt{'t'} || 0;


# Convert each file name given on the command line.
while ($file = shift) {
   ($base, $path, $type) = fileparse($file, qr{\..*});
   next unless ($type eq '.flac');

   # Read in the tags
   %tags = ();
   open(METAFLAC, "metaflac --export-vc-to=- $file |") || die;
   while (<METAFLAC>) {
       chop;
       ($key, $value) = split('=');
       $tags{uc($key)} = $value;
   }
   close(METAFLAC);

   $flac = "flac -d -c -s $file";

   if ($myname eq "flac2ogg") {
       $tags = "\"=oggenc -q $q\"";
       foreach $key (sort (keys %tags)) {
           $tags .= " -c \"$key=$tags{$key}\"";
       }

       $encode = "oggenc -o $dest/$base.ogg -q $q -Q -c $tags -";
   }
   elsif ($myname eq "flac2mp3") {
       $tags  = "--ta \"$tags{'ARTIST'}\" "      if ($tags{'ARTIST'});
       $tags .= "--tl \"$tags{'ALBUM'}\" "       if ($tags{'ALBUM'});
       $tags .= "--tt \"$tags{'TITLE'}\" "       if ($tags{'TITLE'});
       $tags .= "--ty \"$tags{'DATE'}\" "        if ($tags{'DATE'});
       $tags .= "--tg \"$tags{'GENRE'}\" "       if ($tags{'GENRE'});
       $tags .= "--tn \"$tags{'TRACKNUMBER'}\" " if ($tags{'TRACKNUMBER'});
       $tags .= "--tc \"lame --preset $preset\"";
       
       $encode = "lame --quiet --preset $preset $tags - $dest/$base.mp3";
   }
   else {
       exit 1;
   }

   if ($test) {
       print "$flac | $encode\n";
   }
   else {
       system("$flac | $encode");
   }
}