I have a script where it convert regular file such as mpg to flv. Now when I upload mpg it converts to flv fine. but when I upload avi it does not convert probably and the size of the file is 0. Here is the encoding part of the script. Does anyone see anything wrong.

//get Video
                                        if(strtolower($this->VIDEO_EXT)!='flv')
                                            {
                                                //------Writing to the log file
                                                $log_str = 'cALLING MENCODER FOR FLV CONVERSION:'."\r\n";
                                                $log_str .= $this->CFG['admin']['video']['mencoder_path']."\" ".$source_filename." -o ".$store_dir.$this->VIDEO_NAME.".flv -of lavf -ovc lavc -oac lavc -lavcopts vcodec=flv:vbitrate=".$this->CFG['admin']['video']['vbitrate'].":autoaspect:mbd=2:mv0:trell:v4mv:cbp:last_pred=3:predia=2:dia=2:precmp=2:cmp=2:subcmp=2:preme=2:turbo:acodec=mp3:abitrate=56 -vf scale=320:240 -srate 22050 -af lavcresample=22050 -lavfopts i_certify_that_my_video_stream_does_not_use_b_frames";

                                                //------Writing to the log file
                                                $result = exec("\"".$this->CFG['admin']['video']['mencoder_path']."\" ".$source_filename." -o ".$store_dir.$this->VIDEO_NAME.".flv -of lavf -ovc lavc -oac lavc -lavcopts vcodec=flv:vbitrate=".$this->CFG['admin']['video']['vbitrate'].":autoaspect:mbd=2:mv0:trell:v4mv:cbp:last_pred=3:predia=2:dia=2:precmp=2:cmp=2:subcmp=2:preme=2:turbo:acodec=mp3:abitrate=56 -vf scale=320:240 -srate 22050 -af lavcresample=22050 -lavfopts i_certify_that_my_video_stream_does_not_use_b_frames", $p);

                                                if(count($p))
                                                    {

                                                        foreach($p as $key=>$val)
                                                            $log_str .= $key.': '.$val."\n\r";
                                                    }
                                                $this->writetoTempFile($log_str);
                                                $result = exec("\"".$this->CFG['admin']['video']['flvtool2_path']."\" -UP ". $store_dir.$this->VIDEO_NAME.".flv");
                                                $this->setFormField('playing_time', $this->getPlayingTime($source_filename));
                                            }
                                        else
                                            {
                                                if($this->FLV_UPLOAD_TYPE!='Normal')
                                                    {
                                                        $this->setFormField('playing_time', $this->getPlayingTime($source_filename));
                                                        unlink($source_filename);
                                                    }
                                                else
                                                    {
                                                        $result = exec("\"".$this->CFG['admin']['video']['flvtool2_path']."\" -UP ". $source_filename);
                                                        $this->setFormField('playing_time', $this->getPlayingTime($source_filename));
                                                    }
                                            }
                                        $temp_file = $store_dir.$this->VIDEO_NAME;

Try use FFlib.NET

create a folder : images/flv/

function converttoflv( $in, $out )
{
if(file_exists($out))
{
unlink($out);
}
//$cmd = "ffmpeg -v 0 -i $in -ar 11025 $out 2>&1";(or)
$cmd = exec("/../ffmpeg -i $in -deinterlace -ar 44100 -r 25 -qmin 3 -qmax 6 $out");


}


function flv_import( $upfile, $fname)
{
$fname = preg_replace( '/\..*$/', '', basename( $fname ) );
$flvpath = "$fname.flv";


$destination='images/flv/'."$flvpath";


converttoflv( $upfile, "$destination" );


}


flv_import( $_FILES, $_FILES);

Try this....

You can also use this video to flash converter to do that automatically, which is free.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.