EzDevInfo.com

ffmpeg-php

FFmpegPHP is a pure OO PHP port of ffmpeg-php writter in C. It adds an easy to use, object-oriented API for accessing and retrieving information from video and audio files. It has methods for returning frames from movie files as images that can be manipulated using PHP's image functions. This works well for automatically creating thumbnail image… FFmpegPHP – Freecode a pure php wrapper for ffmpeg.

Detect FFmpeg installation and Version

I'm writing a PHP script that converts uploaded video files to FLV on the fly, but I only want it to run that part of the script if the user has FFmpeg installed on the server.

Would there be a way to detect this ahead of time? Could I perhaps run an FFmpeg command and test whether it comes back "command not found?"


Source: (StackOverflow)

FFMpeg - Creating Thumbnail for Video file

I am new to php. I have installed ffmpeg in my local iis.. Is it possible to generate a thumbnail image for a flv file.? Please help..


Source: (StackOverflow)

Advertisements

ffmpeg h.264 video plays in Safari but not in Chrome

I'm using ffmpeg to encode a .MOV raw video into a compressed H.264 video for display on an html5 website. I'm using the below string to encode the video:

ffmpeg -y \
-i in.mov
-b 3500k -bt 4000k \
-acodec libfaac -ac 2 -ar 48000 -ab 192k \
-vcodec libx264 -vpre ultrafast -vpre baseline \
out.mp4

The resulting video looks great and plays fine in Safari, but Chrome can't recognize it. Any ideas?

Thanks.


Source: (StackOverflow)

Is it possible to install SoX on XAMPP and how to use it?

I have installed sox on my windows. It is working on windows command prompt.

C:\Program Files\sox-14-4-2>sox audio1.vox audio2.wav

I don't know how to use this on php. Is it required to install this sox on xampp server too. If yes, then how to install this. Please let me know the whole procedure for converting vox file to wav.

I have tried this code but I did not get success.

echo shell_exec("c:/Program Files/sox-14-4-2/sox -y -i audio1.vox filenew.wav &");

Source: (StackOverflow)

Youtube Data API V3 Javascript - Upload audio and image as video

I am working on youtube data api v3 to upload an image and an audio as video with image will be displayed as a video.

I can able to upload videos as it is already given as an example.

I tried thumbnail: $('#file_image').val(), to set video thumbnail. But it didn't work as I expected. I also search over the internet to get an idea. But didn't get any idea.

UploadVideo.prototype.uploadFile = function(file) {
  var metadata = {
    snippet: {
      title: $('#title').val(),
      description: $('#description').text(),
      tags: this.tags,
      thumbnail: $('#file_image').val(),
      categoryId: this.categoryId
    },

Is this feature achievable using youtube data api? I knew that we can upload an image and audio together works as video in youtube (not through API).

Youtube reference url

Youtube data api Reference

UPDATE:

Using ffmpeg we can able to create a video by combining audio and image. The created video uploaded to Youtube via Youtube DATA API. It works. Now I am trying to automate the following scenario using a script.

Upload Image and Audio. Create the video using ffmpeg. Once video successfully created, upload the video using Youtube DATA API.

I can able to create a video using ffmpeg commands in command line. But when I try to use PHP code, the command is not executing.


Source: (StackOverflow)

ffmpeg and php to get an image out of a video and convert video to ogg

hello all i am having a video hosting site and have successfully installed ffmpeg on my local server everything working good just some problems are i can not get the video duration and dont know how to convert the video to ogg format i can convert the video to mp4 but not sure if the sa,me code works for converting ogg format also

and one more thnig is that i can get a thumb nail out of the video at the starting of the video but i want it after 50 seconds please see the code below and correct or suggest me something please ,,.....

   $base = basename($uploadfile, $safe_file['ext']);
                $new_file = $base.'mp4';
                $new_image = $base.'jpg';
                $new_image_path = $live_img.$new_image;
                $new_flv = $live_dir.$new_file;

  equire 'vendor/autoload.php';
        //ececute ffmpeg generate mp4
        exec('ffmpeg -i '.$uploadfile.' -f mp4 -s 896x504 '.$new_flv.'');
        //execute ffmpeg and create thumb
        exec('ffmpeg  -i '.$uploadfile.' -f mjpeg -vframes 71 -s 768x432 -an '.$new_image_path.''); 

Source: (StackOverflow)

Install ffmpeg-php on CentOS

I'm trying to install ffmpeg-php on server (CentOS) but after the "make" command I get an error:

  from /usr/local/src/ffmpeg-php-0.6.0/ffmpeg-php.c:40:
  /usr/include/bits/stat.h:91: error: field 'st_atim' has incomplete type
  /usr/include/bits/stat.h:92: error: field 'st_mtim' has incomplete type
  /usr/include/bits/stat.h:93: error: field 'st_ctim' has incomplete type
  In file included from /usr/local/include/php/main/php_streams.h:28,
             from /usr/local/include/php/main/php.h:400,
             from /usr/local/src/ffmpeg-php-0.6.0/ffmpeg-php.c:40:
  /usr/include/sys/stat.h:367: error: array type has incomplete element type
  /usr/include/sys/stat.h:374: error: array type has incomplete element type
  In file included from /usr/local/include/php/main/php.h:406,
             from /usr/local/src/ffmpeg-php-0.6.0/ffmpeg-php.c:40:



/usr/local/include/php/TSRM/tsrm_virtual_cwd.h:218: error: expected specifier-qualifier-list before 'time_t'
/usr/local/include/php/TSRM/tsrm_virtual_cwd.h:246: error: expected declaration specifiers or '...' before 'time_t'
/usr/local/src/ffmpeg-php-0.6.0/ffmpeg-php.c: In function 'zm_startup_ffmpeg':
/usr/local/src/ffmpeg-php-0.6.0/ffmpeg-php.c:94: warning: implicit declaration of function 'avcodec_init'
make: *** [ffmpeg-php.lo] Error 1

The ffmpeg was installed successfully as well as mplayer and mencoder.

ffpeg:

 configuration: --enable-gpl --enable-libmp3lame --enable-libtheora --enable-libvo-aacenc --enable-libvorbis --enable-libvpx --enable-libx264 --enable-version3
 libavutil      51. 73.101 / 51. 73.101
 libavcodec     54. 56.100 / 54. 56.100
 libavformat    54. 27.101 / 54. 27.101
 libavdevice    54.  2.100 / 54.  2.100
 libavfilter     3. 16.104 /  3. 16.104
 libswscale      2.  1.101 /  2.  1.101
 libswresample   0. 15.100 /  0. 15.100
 libpostproc    52.  0.100 / 52.  0.100

Any help?


Source: (StackOverflow)

use command yum in my server Centos 5.8

I wana install ffmpeg-php in my server but.
I can't use command yum in my server Centos 5.8.
There is somme one to help me plz ??


Source: (StackOverflow)

playing video while encoding with ffmpeg

in my Webapplication the user should be able to upload his own videos (either format). I am using ffmpeg to encode the video to .mp4 and .flv using the command:

ffmpeg -i uservid.whatever output.mp4 output.flv

while ffmpeg encodes the video, it's loaded in the flowplayer on the users-page. But flowplayer always says "file not found" cause ffmpeg is not yet finish with encoding.

Is there a possibility to load the video in a certain player even if it is not yet completly encoded? maybe there is a ffmpeg option?

Thanks


Source: (StackOverflow)

using FFMPEG to convert to MP4 with maximum browsers compatibilty

I'm converting from WMV to FLV using FFMPEG, and my problem is that the FLV videos are so big! the 15 minutes video's size ranges between 150MB and 1GB!
I'm using the following FFMPEG command to convert and split WMV videos :

nohup nice -1 ffmpeg -y -ss 00:00:00 -t 00:15:00 -async 1 -i INPUT.WMV -acodec libmp3lame OUTPUT.FLV

And I've tried converting to MP4 before and the video size was much smaller than the FLV video.

So my questions are:

  • Would the MP4 videos have any compatibility issues browsers?
  • Would it work on iPhone, iPad? (I know FLV videos doesn't work on iPhones or iPads)
  • What is the best FFMPEG command to convert to MP4 without losing the quality of the video?

Source: (StackOverflow)

Find absolute path to ffmpeg

I installed ffmpeg and ffmpeg-php to my dedicated server and with a small script i am trying to extract an image from specific second.

<?php

$extension = "ffmpeg";
$extension_soname = $extension . "." . PHP_SHLIB_SUFFIX;
$extension_fullname = PHP_EXTENSION_DIR . "/" . $extension_soname;

$timeOffset = "00:00:30";
$videoPath = "sample.mp4";
$extensi = ".jpg";
$folder = "images/";
$finalfilename = $folder . $randomfilename . $extensi;

echo $extension_fullname; //I AM GETING THIS /usr/lib64/php/modules/ffmpeg.so

if (exec("ffmpeg -ss $timeOffset -i $videoPath  -frames:v 1 $finalfilename")){
echo "Done";
}else{
echo "Error";   
}
?>

as you can see in my execution command ther is ffmpeg, but how can i find the absolute path to ffmpeg? Take a look in my screenshot maybe this helps you to tell me..

My last question is what is ffmpeg-php? Do i need it? i already install it.

Thank you

enter image description here


Source: (StackOverflow)

ffmpeg compresses upto 32 kbps only

i have created a php code which compresses mp3 while uploaded to 32kbps bit rate i have referred this thread

How to compress or convert to low quality Mp3 file from PHP

used this code

exec("ffmpeg -i inputfile.mp3 -ab 24000 outputfile.mp3") 

but the problem is i cant compress more than 32kbps .my code instruct to compress upto 24kbps but after execution i can see the output file is 32kbps. can anyone tell what should i do so that i can compress more than 32kbps .or is there any limitation of ffmpeg ??


Source: (StackOverflow)

Error when installing ffmpeg-php

I am trying to install ffmpeg and ffmpeg-php and am getting an error when I try to use make. I've tried to get to the bottom of it but it has me stumped. I tried finding which file has references to swscale.h but didn't have any luck. Has anyone encountered this error before?

root@vps [/usr/local/src/ffmpeg-php-0.6.0]# make
/bin/sh /usr/local/src/ffmpeg-php-0.6.0/libtool --mode=compile gcc  -I. -
I/usr/local/src/ffmpeg-php-0.6.0 -DPHP_ATOM_INC -I/usr/local/src/ffmpeg-
I/usr/local/src/ffmpeg-php-0.6.0 -DPHP_ATOM_INC -I/usr/local/src/ffmpeg-
php-0.6.0/include -I/usr/local/src/ffmpeg-php-0.6.0/main -
I/usr/local/src/ffmpeg-php-0.6.0 -I/usr/local/include/php -
I/usr/local/include/php/main -I/usr/local/include/php/TSRM -
I/usr/local/include/php/Zend -I/usr/local/include/php/ext -
I/usr/local/include/php/ext/date/lib -I/usr/local/include/libavcodec/ -
I/usr/local/include/libavformat/ -I/usr/local/include/libavutil/ -
I/usr/local/include/libswscale/ -I/usr/local/include/libavfilter/ -
I/usr/local/include/libavdevice/  -I/usr/local/include/php -DHAVE_CONFIG_H
-g -O2 -Wall -fno-strict-aliasing   -c /usr/local/src/ffmpeg-php-
0.6.0/ffmpeg-php.c -o ffmpeg-php.lo
gcc -I. -I/usr/local/src/ffmpeg-php-0.6.0 -DPHP_ATOM_INC -
I/usr/local/src/ffmpeg-php-0.6.0/include -I/usr/local/src/ffmpeg-php-
0.6.0/main -I/usr/local/src/ffmpeg-php-0.6.0 -I/usr/local/include/php -
I/usr/local/include/php/main -I/usr/local/include/php/TSRM -
I/usr/local/include/php/Zend -I/usr/local/include/php/ext -
I/usr/local/include/php/ext/date/lib -I/usr/local/include/libavcodec/ -
I/usr/local/include/libavformat/ -I/usr/local/include/libavutil/ -
I/usr/local/include/libswscale/ -I/usr/local/include/libavfilter/ -
I/usr/local/include/libavdevice/ -I/usr/local/include/php -DHAVE_CONFIG_H -g 
-O2 -Wall -fno-strict-aliasing -c /usr/local/src/ffmpeg-php-0.6.0/ffmpeg-
php.c  -fPIC -DPIC -o .libs/ffmpeg-php.o
/usr/local/src/ffmpeg-php-0.6.0/ffmpeg-php.c:46:21: error: swscale.h: No 
such file or directory
/usr/local/src/ffmpeg-php-0.6.0/ffmpeg-php.c: In function 'zm_info_ffmpeg':
/usr/local/src/ffmpeg-php-0.6.0/ffmpeg-php.c:156: error: 'LIBSWSCALE_IDENT' 
undeclared (first use in this function)
/usr/local/src/ffmpeg-php-0.6.0/ffmpeg-php.c:156: error: (Each undeclared 
identifier is reported only once
/usr/local/src/ffmpeg-php-0.6.0/ffmpeg-php.c:156: error: for each function 
it appears in.)
make: *** [ffmpeg-php.lo] Error 1

Source: (StackOverflow)

Compress / Reduce file size of VIDEO

I currently have a system in place where the user can upload a MP4 file and the same is available for download on mobile devices. But sometimes, the videos are more than 5MB in size and back here in my country, majority of the population uses 2G. So it typically takes 15-20 minutes to download large videos.

Is there any way in which I can compress MP4 files while they are being uploaded and then save them in the folder so that instead of a 5MB video, I get a 2MB video which takes relatively less time to download. File format will always be MP4 only.

I know of FFMPEG-PHP, but as far as I read, it only supports extracting information of the video and for video conversion. I could not find any reference for VIDEO COMPRESSION. I would be grateful if you could guide me on this.


Source: (StackOverflow)

PHP FFMPEG not working when I upload mp4 file

To convert video to formats compatible with HTML5 video I wrote the following script:

    $srcFile = "name/of/the/video.mp4";
    $destFile = "/media/video/newfilename";
    $ffmpegPath = "/usr/local/bin/ffmpeg";
    $flvtool2Path = "/usr/local/bin/flvtool2";

    // Create our FFMPEG-PHP class
    $ffmpegObj = new ffmpeg_movie($srcFile);
    // Save our needed variables
    $srcWidth = makeMultipleTwo($ffmpegObj->getFrameWidth());
    $srcHeight = makeMultipleTwo($ffmpegObj->getFrameHeight());
    $srcFPS = $ffmpegObj->getFrameRate();
    $srcAB = intval($ffmpegObj->getAudioBitRate()/1000);
    $srcAR = $ffmpegObj->getAudioSampleRate();
    $srcVB = floor($ffmpegObj->getVideoBitRate()/1000); 


    // Call our convert using exec() to convert to the three file types needed by HTML5
    exec($ffmpegPath . " -i ". $srcFile ." -vcodec libx264 -vpre hq -vpre ipod640 -b ".$srcVB."k -bt 100k -acodec libfaac -ab " . $srcAB . "k -ac 2 -s " . $srcWidth . "x" . $srcHeight . " ".$destFile.".mp4");

    exec($ffmpegPath . " -i ". $srcFile ." -vcodec libvpx -r ".$srcFPS." -b ".$srcVB."k -acodec libvorbis -ab " . $srcAB . " -ac 2 -f webm -g 30 -s " . $srcWidth . "x" . $srcHeight . " ".$destFile.".webm");

    exec($ffmpegPath . " -i ". $srcFile ." -vcodec libtheora -r ".$srcFPS." -b ".$srcVB."k -acodec libvorbis -ab " . $srcAB . "k -ac 2 -s " . $srcWidth . "x" . $srcHeight . " ".$destFile.".ogv");

It is supposed to take any input video type and convert it to mp4, ogv and webm. When I run the script on a .mov file it returns a mp4 and ogv file, but not webm. When I run it on a .mp4 file it returns no converted files at all. Is there something wrong with the way I am converting the files? Any help?


Source: (StackOverflow)