Solved

uploaded video convert into flv

Posted on 2011-09-19
7
501 Views
Last Modified: 2012-05-12
i am using "ffmpeg" encoder to convert video file into flv format but not able to succeed. can anyone help me with PHP Script to convert video file into FLV.
0
Comment
Question by:BhavinKrish
7 Comments
 
LVL 8

Expert Comment

by:psychogr
Comment Utility
0
 
LVL 7

Expert Comment

by:boon86
Comment Utility
try:
                   
    //convert video
						if($video_resize == '1')
						{
							$encodecommand = "/usr/local/bin/mencoder /path/to/your/input/video.mpg -o /path/to/your/output/video.flv -of lavf -oac mp3lame -lameopts abr:br=56 -ovc lavc -lavcopts vcodec=flv:vbitrate=750:mbd=2:mv0:trell:v4mv:cbp:last_pred=3 -lavfopts i_certify_that_my_video_stream_does_not_use_b_frames -vop scale=450:320 -srate 48000";
						}
						else 
						{
							$encodecommand="/usr/local/bin/mencoder /path/to/your/input/video.mpg -o /path/to/your/output/video.flv -of lavf -oac mp3lame -lameopts abr:br=56 -ovc lavc -lavcopts vcodec=flv:vbitrate=750:mbd=2:mv0:trell:v4mv:cbp:last_pred=3 -lavfopts i_certify_that_my_video_stream_does_not_use_b_frames -srate 48000";
						}

                        exec($encodecommand, $output); 

			            //get video duration
						exec("/usr/local/bin/mplayer -vo null -ao null -frames 0 -identify /path/to/your/input/video.mpg", $difh);
    					while (list($k,$v)=each($difh))
    					{
        	    			if ($length = strstr($v,'ID_LENGTH='))
        	    				break;
    					}
						
    					$lx = explode("=",$length);
    					$runtime = $lx[1];

Open in new window


i used mplayer + mencoder for above example.  following is php.ini setting that required:

max_execution_time = 3600
max_input_time = 3600
safe_mode off
open_basedir off
exec() should be allowed
register_argc_argv on

try check above requirement on phpinfo.php
<?php
phpinfo();
?>

hope that help
0
 

Author Comment

by:BhavinKrish
Comment Utility
I am working on video uploading functionality. i have uploaded video files and it is stored  into flv format using below code
exec(ffmpeg -i $video -ab 56 -ar 44100 -b 200 -r 15 -s 320x240 -f flv ".$flv_video);

Open in new window

Now i want to play this *.flv file on my web page. How can I do that?
I got embed code for swf but it is not playing flv file.
0
Complete Microsoft Windows PC® & Mac Backup

Backup and recovery solutions to protect all your PCs & Mac– on-premises or in remote locations. Acronis backs up entire PC or Mac with patented reliable disk imaging technology and you will be able to restore workstations to a new, dissimilar hardware in minutes.

 
LVL 7

Expert Comment

by:boon86
Comment Utility
you need to use jwplayer, here is the wizard with step by step:

http://www.longtailvideo.com/support/jw-player-setup-wizard

and download the player.swf here:

http://www.longtailvideo.com/players/

hope that help.
0
 
LVL 3

Expert Comment

by:garykristen
Comment Utility
Hi BhavinKrish

You need to just execute command for convert video file to flv.

$pth=$JPATH_ROOT."//ffmpeg//ffmpeg.exe";
$vname=$uploadFile = Document root path.'/video_upload/videos/'.video file name."."."flv";

exec("$pth -i $dest -ar 22050 -ab 32 -f flv -s 426×234 $vname");
0
 
LVL 7

Accepted Solution

by:
boon86 earned 500 total points
Comment Utility
if the video dont work with the player, you need to metainject the flv files, because player.swf need to read the meta header of the flv files inorder to player it and try again after you injected, there is 2 tools you can use is:

yamdi
flvtool2
 

usage:
/usr/bin/yamdi -i /path/to/your/input/video.flv -o /path/to/your/output/video.flv

or

/usr/bin/flvtool2 -Uv /path/to/your/input/video.flv  /path/to/your/output/video.flv

Open in new window

0
 

Author Closing Comment

by:BhavinKrish
Comment Utility
good solution
0

Featured Post

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Author Note: Since this E-E article was originally written, years ago, formal testing has come into common use in the world of PHP.  PHPUnit (http://en.wikipedia.org/wiki/PHPUnit) and similar technologies have enjoyed wide adoption, making it possib…
Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
The viewer will learn how to count occurrences of each item in an array.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now