PHP Classes

File: exsample.php

Recommend this page to a friend!
  Classes of Marko Schulz   flv2mp3   exsample.php   Download  
File: exsample.php
Role: Example script
Content type: text/plain
Description: Exsample script
Class: flv2mp3
Extract MP3 audio from Flash video movies
Author: By
Last change: Bug: Not the orginal input file should be streamed.
Date: 15 years ago
Size: 1,138 bytes
 

Contents

Class file image Download
<?php


// @exsample
/*
 * This file I have download from youtube.com with the url
 * http://www.youtube.com/watch?v=P_gDz-Qlef0&feature=PlayList&p=E79725C3F709B278&playnext=1&index=1
*/

try {

// Path to the downloaded flv file
(string) $file = "P_gDz-Qlef0.flv";

// Load the Flv2Mp3 class
include_once( 'flv2mp3.class.php' );

// Create the $mp3 object
$mp3 = new Flv2Mp3( array( 'delete' => False ) );

// Convert the flv file into mp3
if ( $mp3->convert( $file ) ) {
    if (
is_file( $mp3->getOutfile( $file ) ) ) {
       
$mp3->stream( $mp3->getOutfile( $file ) );
    }
}

// If you have set the parameter delete => Fale you have
// to delete the converted file manually.
if ( is_file( $mp3->getOutfile( $file ) ) ) {
    echo
$mp3->getOutfile( $file )." exist!";
}

// You can also stream the mp3 with the convert method
// if ( !$mp3->convert( $file, True ) ) {
// echo "Can't convert ".$file;
// }
 
} catch ( Exception $error ) {

    echo
"Error: <br/>\n";
    echo
$error->getMessage()."<br/>\n";
    echo
"Line: ".$error->getLine()." in ".$error->getFile()."<br/>\n";
    echo
$error;

}


?>