Recording a audio streming file from different server

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
shreyansh
Forum Newbie
Posts: 2
Joined: Sun Apr 08, 2012 6:27 am

Recording a audio streming file from different server

Post by shreyansh »

Hi Friends,

I want to record a streaming audio from http://example.co.uk:8008/ and save the fiile on our server so how can i record the streaming video i use some thing like this code please check that is correct or not:--

Code: Select all

<?php 

// cron podcast script



$fileday = date('l');

$filetime = date('H:i');
echo $fileday;
echo $filetime;

$dbhost="localhost"; // Host name 

$dbusername="username"; // Mysql username 

$dbpassword="password"; // Mysql password 

$db_name="database name"; // Database name 







// Do Not Edit Below This Line CORE SITE CODE



// Mysql db Connection

mysql_connect("$dbhost", "$dbusername", "$dbpassword")or die("cannot connect"); 

mysql_select_db("$db_name")or die("cannot select DB");





// check if we need to record

$SQLtext = "SELECT * FROM timetable WHERE cast_day='$fileday' AND start_time='$filetime'";

$result = mysql_query($SQLtext);

while($row = mysql_fetch_row($result)) {

$process = "start";

$filer = $row[3]; // dj name 

$filetime_chk = $row[1]; // start time

$fileday_chk = $row[6]; // day

$lengthr = $row[2]; // length

// additional info now

$dj_img = $row[4]; // djs image

$genre = $row[5]; // genre

$cast_active = "no"; // dont make active untill complete 

}

// end check







// EDIT BELOW --- CONFIGURATION



$curlpath = "/usr/bin/curl"; // path to curl

$folder = "/podcasts/"; // ensure folder has chmod 777

$directory = "podcasts/"; // recordings folder name

$rstream = "http://example.co.uk:8008/"; 



// NEVER TOUCH BELOW HERE UNLESS YOU UNDERSTAND PHP



$addfile = date('d-m');

$filerec2 = "$filer-$addfile";

$filerec = str_replace(" ","_",$filerec2);

$truefile = "$folder$filerec".'.mp3';

$podname = "$filerec.mp3";


if ($process == "start") {





$sql="INSERT INTO podcasts (start_time, show_length, dj_name, dj_image, genre, cast_day, cast_active, podcast_file,file_rec) VALUES ('$filetime_chk','$lengthr','$filer','$dj_img','$genre','$fileday_chk','$cast_active','$podname','$addfile')";

$r = mysql_query($sql) or die("A MySQL error has occurred.<br />Your Query: " . $your_query . "<br /> Error: (" . mysql_errno() . ") " . mysql_error());






echo $podname;
$reccom = "curl -m $lengthr $rstream >$truefile";

$last_line = system("$reccom");
echo $last_line;





echo "<br>Running Command $reccom <br>";




} else { 
echo "Sorry Nothing to do Atm";
}



?>
webstreamer
New php-forum User


Posts: 1
Joined: Sun Apr 08, 2012 3:08 am
shreyansh
Forum Newbie
Posts: 2
Joined: Sun Apr 08, 2012 6:27 am

Re: Recording a audio streming file from different server

Post by shreyansh »

i mean how i record a shoutcast audio streaming and save file on our server.....please help me.....
Post Reply