Solved

uploaded video convert into flv

Posted on 2011-09-19
7
504 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
ID: 36565177
0
 
LVL 7

Expert Comment

by:boon86
ID: 36565281
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
ID: 36565783
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
Best Practices: Disaster Recovery Testing

Besides backup, any IT division should have a disaster recovery plan. You will find a few tips below relating to the development of such a plan and to what issues one should pay special attention in the course of backup planning.

 
LVL 7

Expert Comment

by:boon86
ID: 36565810
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
ID: 36565877
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
ID: 36565902
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
ID: 36967179
good solution
0

Featured Post

NAS Cloud Backup Strategies

This article explains backup scenarios when using network storage. We review the so-called “3-2-1 strategy” and summarize the methods you can use to send NAS data to the cloud

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
This article discusses how to create an extensible mechanism for linked drop downs.
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…

803 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