Hello,

On 2013-06-01 02:06, Richard Lamont wrote:
I have git cloned the python-rivendell thing but I'm completely baffled
to know what to do with it next.
i was in the same case as you, and i never ever used python, so i have
written a php script that does basically what you need.
You can find it as an attachment to this email.

It has to be run from the command line ( /usr/bin/php5 /path/to/script ) and is not interactive (you have to edit the script so that it does what
you want).

On an i3 CPU it took ~20-30 minutes to process 3000 songs of 3:30
average length. YMMV.

Cheers,

Leo
tech @ Graf'hit 94.9MHz
BP 60319 // 60200 Compiègne
+336.81.36.39.39
<?php
// (inspired by seb leblanc's python script normalize.py)
// this script has been written in order to work with rivendell 2.1.4 database
// use at your own risk.

// what it does:
// 1/ analyse CUTS in -cart, -group, -all CUTS added since some date
// 2/ adjust PLAY_GAIN value to reach -23LUFS
// do not use on cuts that are being recorded to, that hangs the analysis 
process

// config options
$PATH_TO_LIBEBUR128=""; // absolute path to the libebur128 'loudness' binary
$RIVENDELL_DB_IP="192.168.x.x"; // SQL server ip
$RIVENDELL_DB_NAME="Rivendell";
$RIVENDELL_DB_USER="";
$RIVENDELL_DB_PASSWORD="";

// choose on what you want to perform the replay gain change
$CART_TO_NORMALIZE="082899"; // single cart
$GROUP="TEMP"; // all cuts of all carts belonging to GROUP 
$LAST_NORM_DATE="2013-01-30 19:44:00"; // all cuts that were imported after 
LAST_NORM_DATE

// uncomment the line corresponding to your needs
//$sqlRequest="SELECT * FROM CUTS WHERE CART_NUMBER = '$CART_TO_NORMALIZE// 
single cart
//$sqlRequest="SELECT * FROM CUTS,CART WHERE CART.NUMBER = CUTS.CART_NUMBER AND 
CART.GROUP_NAME = '$GROUP'"; // all cuts of all carts belonging to GROUP
//$sqlRequest="SELECT * FROM CUTS WHERE ORIGIN_DATETIME > '$LAST_NORM_DATE'"; 
// all cuts imported after LAST_NORM_DATE

$db = mysql_connect("$RIVENDELL_DB_IP", "$RIVENDELL_DB_USER", 
"$RIVENDELL_DB_PASSWORD") or die('connection failed ' . mysql_error());
mysql_select_db("$RIVENDELL_DB_NAME") or die(mysql_error());
$result = mysql_query($sqlRequest) or die(mysql_error());
mysql_close($db);
$rowCheck = mysql_num_rows($result);
if($rowCheck > 0)
{
        while($row = mysql_fetch_array($result))
        {
                echo $row['CUT_NAME']." "; // print cut reference number
                echo $row['PLAY_GAIN']." "; // print current replay gain
                $cutName = $row['CUT_NAME'];
                // analyse levels and get offset
                $command = "$PATH_TO_LIBEBUR128"." scan 
/var/snd/".$row['CUT_NAME'].".wav";
                $rawRes = shell_exec( $command." 2>&1" );
                $LUFSValue = substr($rawRes,-11);
                $LUFSValue = substr($LUFSValue, 0, 5);
                echo $LUFSValue." ";
                $gain = -23 - $LUFSValue;
                $gain = $gain * 100;
                echo " gain :".$gain."\n";
                // write new replay gain
                $req="UPDATE CUTS SET PLAY_GAIN = '$gain' WHERE CUT_NAME = 
'$cutName'";
                $db = mysql_connect("$RIVENDELL_DB_IP", "$RIVENDELL_DB_USER", 
"$RIVENDELL_DB_PASSWORD") or die('connection failed : ' . mysql_error());
                mysql_select_db("$RIVENDELL_DB_NAME") or die(mysql_error());
                mysql_query($req) or die(mysql_error());
                mysql_close($db);

        }
}

//EOF
_______________________________________________
Rivendell-dev mailing list
[email protected]
http://caspian.paravelsystems.com/mailman/listinfo/rivendell-dev

Reply via email to