Giter Club home page Giter Club logo

php-ffmpeg's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

php-ffmpeg's Issues

FFProbe - bit rate information per stream

First, many thanks for this impressive library.
FFMpeg \ ffprobe provides a lot of metadata and the format () method also returns bit_rate property for all streams.
It would be nice to have bit rate also for each stream separately.

Video Synchronize filter synchronize but leaves metadata

Videos are rendered correctly in players that do not care about this sync metadata (purpose of the filter) but when playing in quick time player (that takes care about metadata), desynchronisation occurs.

Metadata should be removed.

Run video encoding in background

I use PHP-FFmpeg for online video encoding, and it's very useful...But I need to allow users to do other things during video encoding.

In other words, the php script must proceed after call of PHP-FFmpeg's save function, like the "ffmpeg" command has "&" option.

Can PHP-FFmpeg do this ?

Thanks, and sorry for my bad english.

Some code causes inconsistant aspect ratio

I have been encoding my videos into a variety of resolutions and was noticing some were consistently out of line with the others. This causes a very jarring effect when you transition from one resolution to another. I use the RESIZEMODE_INSET setting and first thought it may be due to the method getComputedDimensions in the class DefaultVideo but I pulled the code out and tested it and it was fine. then I found this at line 336 in the FFMpeg class.

$width = $this->getMultiple($dimensions->getWidth(), 16);
$height = $this->getMultiple($dimensions->getHeight(), 16);

in my case this mucks up getComputedDimensions and makes my resolutions very inconsistent with each other. I think its purpose is to try and prevent invalid resolutions but it would be nice to be able to override it.

[Question] Usage without ffprobe

Is there a way to use this without having ffprobe installed?
Or is there a quick way to install it on OSX without compiling?

The problem is, that there are compiled binaries for ffmpeg, but not for ffprobe for OSX.

THX. Frank

Remote File Frame Grabbing

Hi,

This is probably an enhancement, not an issue.
If I disable the "is_file" and "is_readable" checks, the frame grabbing will work with a remote URL - e.g. an http link to a video hosted on S3.

Support for this would be fantastic for what we are trying to do. I'll try and create a fork and send a pull request, but I'm not going to have time for a few weeks - if someone else knows of any quick fixes or reasons why I shouldn't do this, please let me know.

Thanks,
James.

Create frame

I am developing an application with laravel and I am using php ffmpeg to do multiple things, probe, extract frame and encode. I am having an issue with creating a frame from the uploaded video file.
This is how I am creating the frame:
$video = $ffmpeg->open($destinationPath.'/'.$filename);

        $video
            ->frame(FFMpeg\Coordinate\TimeCode::fromSeconds(10))
            ->save(public_path().$frame_path);

This is sometimes working and other times not. I noticed that this bug comes up when I am trying to open a .mov file.

Map audio stream

I would like to know if it's possible to save a video with only one audio.

Comming from a MULTI Audio video, let's say I only want the second Audio stream with my video.

With ffmpeg I would use the -map option.

Any help would be appreciated.

thanks a lot

Symfony 2.0 compatible ?

Composer.json indicate the following :

"require": {
"php" : ">=5.3.3",
"symfony/process" : "~2.0"

The problem being that symfony version 2.0 doesn't include any library called "processBuilder" in FFProbe.php (use Symfony\Component\Process\ProcessBuilder;).

The processBuilder appear in the symfony2 api only from symfony 2.1. (source : http://api.symfony.com/2.0/index.html)

Resulting in the following error :

Fatal error: Class 'Symfony\Component\Process\ProcessBuilder' not found in /path/Symfony/vendor/PHP-FFmpeg-master/src/FFMpeg/FFProbe.php on line 96

Unable to load FFProbe

I know this isn't exactly an issue with this package, but I have this error: "Unable to load FFProbe", and there does not seem to be any FFProbe binaries in the entire internet for PHP (5.4). FFMpeg is installed and working, but can't find anything on Probe. Running windows WAMP server for development and Linux server for production, if anyone has any ideas where to get these.

Your FFProbe version is too old and does not support `-help` option, please upgrade.

When trying to use FFprobe in this package, it throws an exception saying it is too old, yet I have upgraded to the latest version of FFmpeg and FFprobe, and running ffprobe -help works in the console/terminal.

Installed the package via composer as so:

"require": {
  "php-ffmpeg/php-ffmpeg": "0.4.4"
}

The error traces to line 60 of /vendor/php-ffmpeg/php-ffmpeg/src/FFMpeg/FFProbe/OptionsTester.php:

try {
  $output = $this->ffprobe->command(array('-help', '-loglevel', 'quiet'));
} catch (ExecutionFailureException $e) {
  throw new RuntimeException('Your FFProbe version is too old and does not support `-help` option, please upgrade.', $e->getCode(), $e);
}

This is locally on a Mac OS 10.9.1, I've updated FFmpeg via:

brew update
brew upgrade ffmpeg

This upgraded my ffmpeg and ffprobe versions to 1.2.4, as ffmpeg -version and ffprobe -version, both give 1.2.4.

I've created an FFprobe instance with configuration passed through it, with the binary paths I get from executing which ffmpeg and which ffprobe. But then when trying to read a file, it throws the exception:

$config = array(
 'ffmpeg.binarie' => '/usr/local/bin/ffmpeg'
 'ffprobe.binaries' => '/usr/local/bin/ffprobe'
 'timeout' => 3600
 'ffmpeg.threads' => 12
)

$ffprobe = FFMpeg\FFProbe::create($config);

$file_path = '/htdocs/mp4/test1.mp4';

$file_info = $ffprobe
  ->streams($file_path)
  ->videos()
  ->first()
  ->get('duration');


echo '<pre>';
print_r($file_info);
echo '</pre>';

Any thoughts as to why or how to fix? Many thanks!

Change Binary timeout to maintain backward compatibility

In 0.2.1, a new function process timeout customization appeared which arrived with one minute timeout on any conversation process.

I think it would be better to set it to 0 to maintain backward compatibility with previous versions.

Support for WAV encoding

I have a basic WAV encoder. I think this should be a standard format for this library. Can i submit a pull request?

Video::save() cannot be called multiple times

Video::save() has the side-effect of adding filters, which means that you can't reliably call it multiple times.

Here's an example:

$source = $ffmpeg->open('source.avi');

$source->save(new \FFMpeg\Format\Video\WebM(), 'processed.webm');

//This fails, because $source was "contaminated" with filters,
//which added params like "-f webm", etc.
$source->save(new \FFMpeg\Format\Video\X264(), 'processed.mp4');

Audio::save() likely exhibits the same behavior.

IMO, this should either be fixed by:

  • removing the side-effects - moving from $this->addFilter() calls to a new local FiltersCollection
  • documenting the current behavior

Unknown errors thrown but actual FFMpeg command works...

Hi,

First congrat for the work done on PHP-FFmpeg!

I'm using it together with a PHP Job/Queue system to manage video encodings on a distributed architecture. Sadly I've encounter some very strange behaviors during the debug phase.

I'm working on :

  • Ubuntu 12.04 LTS server
  • PHP5.3.23 (dotdeb) with Suhosin-Patch
  • FFMpeg 1.2

I do apply many processes (= FFMpeg commands) on each submitted video.
For example I'm encoding two H264/FLV videos : one in HD (720p) the other in LD (360p).
Those two LD/HD videos use exactly the same settings (= FFMpeg arguments).

Still, each time I use PHP-FFmpeg the Symfony Process fails before the HD is completly encoded. It sends back an error with exit code "15" or "-1" (it seems those are unknown error in both case).

Note that there is no problem when I run the PHP-FFMpeg generated command manually. Moreover I can't find any track of an error in the exception thrown by PHP-FFMpeg's symfony Process execution...

Here is the command generated by ProcessBuilder:

'/usr/local/bin/ffmpeg' '-y' '-i' '/tmp/video/original/adf7aaec5eb3a381ca67a10813c88c714814fe7e.mov' '-maxrate' '2560k' '-profile:v' 'high' '-preset' 'fast' '-s' '1280x720' '-r' '25' '-b_strategy' '1' '-bf' '3' '-g' '25' '-vcodec' 'libx264' '-b:v' '2048k' '-threads' '1' '-refs' '6' '-coder' '1' '-sc_threshold' '40' '-flags' '+loop' '-me_range' '16' '-subq' '7' '-i_qfactor' '0.71' '-qcomp' '0.6' '-qdiff' '4' '-trellis' '1' '-b:a' '92k' '-acodec' 'libmp3lame' '-ac' '2' '-ar' '44100' '/tmp/video/front/flv_hd/adf7aaec5eb3a381ca67a10813c88c714814fe7e.flv'

Here is an example of the output from the thrown exception:

ffmpeg version 1.2 Copyright (c) 2000-2013 the FFmpeg developers
  built on Apr 16 2013 12:32:12 with gcc 4.4.3 (Ubuntu 4.4.3-4ubuntu5.1)
  configuration: --enable-gpl --enable-libfaac --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libtheora --enable-libvorbis --enable-libvpx --enable-libx264 --enable-nonfree --enable-version3
  libavutil      52. 18.100 / 52. 18.100
  libavcodec     54. 92.100 / 54. 92.100
  libavformat    54. 63.104 / 54. 63.104
  libavdevice    54.  3.103 / 54.  3.103
  libavfilter     3. 42.103 /  3. 42.103
  libswscale      2.  2.100 /  2.  2.100
  libswresample   0. 17.102 /  0. 17.102
  libpostproc    52.  2.100 / 52.  2.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '/tmp/video/original/adf7aaec5eb3a381ca67a10813c88c714814fe7e.mov':
  Metadata:
    major_brand     : qt  
    minor_version   : 537199360
    compatible_brands: qt  
    creation_time   : 2009-08-05 14:51:58
  Duration: 00:00:47.76, start: 0.000000, bitrate: 9838 kb/s
    Stream #0:0(eng): Video: h264 (Main) (avc1 / 0x31637661), yuv420p, 1280x720, 9695 kb/s, 25 fps, 25 tbr, 2500 tbn, 5k tbc
    Metadata:
      creation_time   : 2009-08-05 14:51:58
      handler_name    : Gestionnaire d?alias Apple
    Stream #0:1(eng): Audio: aac (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 129 kb/s
    Metadata:
      creation_time   : 2009-08-05 14:51:58
      handler_name    : Gestionnaire d?alias Apple
[libx264 @ 0x9db9740] VBV maxrate specified, but no bufsize, ignored
[libx264 @ 0x9db9740] using cpu capabilities: MMX2 SSE2Fast SSSE3 Cache64 SlowShuffle
[libx264 @ 0x9db9740] profile High, level 4.0
[libx264 @ 0x9db9740] 264 - core 130 r2 c832fe9 - H.264/MPEG-4 AVC codec - Copyleft 2003-2013 - http://www.videolan.org/x264.html - options: cabac=1 ref=6 deblock=1:0:0 analyse=0x3:0x113 me=hex subme=7 psy=1 psy_rd=1.00:0.00 mixed_ref=1 me_range=16 chroma_me=1 trellis=1 8x8dct=1 cqm=0 deadzone=21,11 fast_pskip=1 chroma_qp_offset=-2 threads=3 lookahead_threads=1 sliced_threads=0 nr=0 decimate=1 interlaced=0 bluray_compat=0 constrained_intra=0 bframes=3 b_pyramid=2 b_adapt=1 b_bias=0 direct=1 weightb=1 open_gop=0 weightp=1 keyint=25 keyint_min=2 scenecut=40 intra_refresh=0 rc_lookahead=25 rc=abr mbtree=1 bitrate=2048 ratetol=1.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 ip_ratio=1.41 aq=1:1.00
Output #0, flv, to '/tmp/video/front/flv_hd/adf7aaec5eb3a381ca67a10813c88c714814fe7e.flv':
  Metadata:
    major_brand     : qt  
    minor_version   : 537199360
    compatible_brands: qt  
    encoder         : Lavf54.63.104
    Stream #0:0(eng): Video: h264 ([7][0][0][0] / 0x0007), yuv420p, 1280x720, q=-1--1, 2048 kb/s, 1k tbn, 25 tbc
    Metadata:
      creation_time   : 2009-08-05 14:51:58
      handler_name    : Gestionnaire d?alias Apple
    Stream #0:1(eng): Audio: mp3 ([2][0][0][0] / 0x0002), 44100 Hz, stereo, fltp, 92 kb/s
    Metadata:
      creation_time   : 2009-08-05 14:51:58
      handler_name    : Gestionnaire d?alias Apple
Stream mapping:
  Stream #0:0 -> #0:0 (h264 -> libx264)
  Stream #0:1 -> #0:1 (aac -> libmp3lame)
Press [q] to stop, [?] for help
'. [] []645 fps= 11 q=29.0 size=    7504kB time=00:00:26.41 bitrate=2327.4kbits/s

I hope you'll be able to help me on this.
Thank you for your time!

FFProbe not found, PHP-FFmpeg not working...

Similar to issue #45, I seem to have a problem loading FFProbe (but that issue didn't actually present any working solution).
I use Xampp (32-bit version) on a Windows 7 (64-bit) computer.
PHP version is 5.4.7.

Before trying PHP-FFmpeg I had (and still have) ffmpeg-php installed.
After a fruitless search for decent (install) information about ffmpeg-php, I found out it was simply too slow, so therefore I resorted to PHP-FFmpeg, hoping for a better experience.
Alas, for PHP-FFmpeg I found even less information, and no information at all about solving problems...
So any help is very welcome.

This is the expetion php throws at me...
Uncaught exception 'Alchemy\BinaryDriver\Exception\ExecutableNotFoundException' with message 'Executable not found, proposed : avprobe, ffprobe' in path\to\vendor\Alchemy\binary-driver\src\Alchemy\BinaryDriver\AbstractBinary.php:160
Stack trace:
-0 path\to\vendor\php-ffmpeg\php-ffmpeg\src\FFMpeg\Driver\FFProbeDriver.php(48): Alchemy\BinaryDriver\AbstractBinary::load(Array, NULL, Object(Alchemy\BinaryDriver\Configuration))
-1 path\to\vendor\php-ffmpeg\php-ffmpeg\src\FFMpeg\FFProbe.php(206): FFMpeg\Driver\FFProbeDriver::create(Array, NULL)
-2 path\to\vendor\php-ffmpeg\php-ffmpeg\src\FFMpeg\FFMpeg.php(118): FFMpeg\FFProbe::create(Array, NULL, NULL)
-3 path\to\script.php(20) in path\to\vendor\php-ffmpeg\php-ffmpeg\src\FFMpeg\Driver\FFProbeDriver.php on line 50

Encoding Failed

I am running the basic script provided in the documentation. This is on a linux server. I am using a .mov file for testing. The frame is generated but the encoding fails with the following error.

exception 'Alchemy\BinaryDriver\Exception\ExecutionFailureException' with message 'ffmpeg failed to execute command '/usr/bin/ffmpeg' '-y' '-i' 'Algonquin elevators 4.mov' '-f' 'webm' '-vcodec' 'libvpx' '-acodec' 'libvorbis' '-b:v' '1000k' '-refs' '6' '-coder' '1' '-sc_threshold' '40' '-flags' '+loop' '-me_range' '16' '-subq' '7' '-i_qfactor' '0.71' '-qcomp' '0.6' '-qdiff' '4' '-trellis' '1' '-b:a' '128k' 'export-webm.webm'' in /var/www/aims/vendor/alchemy/binary-driver/src/Alchemy/BinaryDriver/ProcessRunner.php:100 Stack trace: #0 /var/www/aims/vendor/alchemy/binary-driver/src/Alchemy/BinaryDriver/ProcessRunner.php(72): Alchemy\BinaryDriver\ProcessRunner->doExecutionFailure(''/usr/bin/ffmpe...') #1 /var/www/aims/vendor/alchemy/binary-driver/src/Alchemy/BinaryDriver/AbstractBinary.php(209): Alchemy\BinaryDriver\ProcessRunner->run(Object(Symfony\Component\Process\Process), Object(SplObjectStorage), false) #2 /var/www/aims/vendor/alchemy/binary-driver/src/Alchemy/BinaryDriver/AbstractBinary.php(137): Alchemy\BinaryDriver\AbstractBinary->run(Object(Symfony\Component\Process\Process), false, Array) #3 /var/www/aims/vendor/php-ffmpeg/php-ffmpeg/src/FFMpeg/Media/Video.php(155): Alchemy\BinaryDriver\AbstractBinary->command(Array, false, Array) #4 /var/www/aims/ffmpeg-test/index.php(37): FFMpeg\Media\Video->save(Object(FFMpeg\Format\Video\WebM), 'export-webm.web...') #5 {main} Next exception 'FFMpeg\Exception\RuntimeException' with message 'Encoding failed' in /var/www/aims/vendor/php-ffmpeg/php-ffmpeg/src/FFMpeg/Media/Video.php:165 Stack trace: #0 /var/www/aims/ffmpeg-test/index.php(37): FFMpeg\Media\Video->save(Object(FFMpeg\Format\Video\WebM), 'export-webm.web...') #1 {main}

The ffmpeg is working good through cmd line, also it works if I run shell_exec

shell_exec("ffmpeg -i Algonquin elevators 4.mov output.webm &");

Optimization for image extraction

The change is especially useful on long videos because the seek is more important.
I changed the file in this FFMpeg.php php-ffmpeg/php-ffmpeg/src/FFMpeg.

before:
         $ cmd = $ this-> binary
             . '-I'. escapeshellarg ($ this-> pathfile)
             . 'Vframes-1-ss'. $ time
             . '-F image2'. escapeshellarg ($ output);

FFMpeg command:
ffmpeg-i '/ home/720_document.mp4' vframes-1-f image2-ss 2278 '/ home / test.jpg'

after:
         $ cmd = $ this-> binary
             . '-ss'. $ time
             . '-I'. escapeshellarg ($ this-> pathfile)
             . '-F image2-1 vframes'. escapeshellarg ($ output);

FFMpeg command:
ffmpeg-ss 2278-i '/ home/720_document.mp4'-f image2-1 vframes '/ home / test.jpg'

Test result with a seek of 2278:
before:
time ffmpeg-i '/ home/720_document.mp4' vframes-1-f image2-ss 2278 '/ home / test.jpg'
real 4m21.061s
user 4m18.851s
sys 0m1.627s

after:
time ffmpeg-ss 2278-i '/ home/720_document.mp4'-f image2-1 vframes '/ home / test.jpg'
real 0m0.732s
user 0m0.104s
sys 0m0.023s

thank you

Set frame dimension

Hello!

When you choose to save a frame from the video, is there any way to make it save the video in a specific dimension. In my case I want to create posters and thumbnails, so I have to save two different times, but I'd like to have different dimensions.

Problem with two-pass video encoding.

When using the '-pass' FFMpeg in this write statistics in a log file, the parameter '-passlogfile' allows you to specify the name of the log file, but the current version does not specify the name of the log during the convertion of a video.

Cella problem when two FFMpeg running simultaneously on the server, because both can post at the same time in the log. Or even a writing statistics during the first pass and the second bed in the stats second pass and thus encoding plant.

It would be enough to change this part of code to add the parameter '-passlogfile' using log as the name, the name of the video input or output.

         $ passes [] = $ cmd_part1. 'One-pass'. $ cmd_part2
             . '-An'. escapeshellarg ($ tmpfile-> getPathname ());

         $ passes [] = $ cmd_part1. '-Pass 2'. $ cmd_part2
             . '-Ac 2-ar 44100'. escapeshellarg ($ outputPathfile);

Thank you.

Set video bitrate

Hello and thanks for this awesome wrapper. I've been experimenting with it for a few hours now and finally got things running the way I'd like them to except for one thing, the bitrate.

How do I go about setting the bitrate for the conversions, it's really essential as I need to be able to control the quality.

Thanks in advance,
Jonathan

rotation x resize issue

Since we have a rotation filter, applying rotation of 90° or 270° and resize filter on the same media results in a wrong output if the resize mode is not set to fit.

As resize computes final dimension based on the source dimension, as width and height are inverted in case of a 90° (counter) clockwise rotation.

There are multiple solutions to this issue :

  • Merge resize and rotate filter so the dimension computation mechanism would know if source dimensions should be inverted
  • Decouple dimension computation mechanism from the resize filter and I don't have yet the solution
  • Attach metadata to the media so that filters could update them, later filters would get these updated data.

I'm more in favor of the last solution. Any ideas ?

Unable to load FFProbe - WAMP

I am able to run the ffmpeg and ffprobe through command line but in the browser it gives me "Unable to load FFProbe" error. I have followed steps mentioned in #64

PHP-FFMPEG throws runtime exception but the the ffmpeg process is still running.

Hi,

First of all, I would like to thank you for the awesome library you have built.

I have been using PHP-FFMpeg for couple of months and it has been great. Yesterday, My server had utilized its CPU 100%. looking into the cause I realized that there were quite few processes running ffmpeg. It turns out that my worker was trying to encode an avi file, but each time it would fail because of a frame sync error and it would start again trying to encode the file again. But each time that it failed, the background process created by PHP-FFMpeg to run ffmpeg was still running so the server ended up with few ffmpeg processes that slowed down the server. When I ran the command manually, I noticed that ffmpeg threw an error complaining about frame sync error and it then continued to encode the file afterwards. the encoded video actually had good quality. I saw the same issue when my worker failed due to encoding taking longer than expected but when i checked the background process was still running. here is the message I got:

[Symfony\Component\Process\Exception\ProcessTimedOutException]
The process "'/usr/bin/ffmpeg' '-y' '-i' '/home/taher/public_html/phonics.com/app/../web/uploads/5328ce9822be2.avi' '-f' 'webm' '-threads' '12' '-vcodec' 'libvpx' '-acodec' 'libvorbis' '-b:v' '1000k' '-refs' '6' '-coder' '1' '-sc_threshold' '40' '-flags' '+loop' '-me_range' '16' '-subq' '7' '-i_qfactor' '0.71' '-qcomp' '0.6' '-qdiff' '4' '-trellis' '1' '-b:a' '128k' '/home/taher/public_html/phonics.com/app/../web/uploads/5328d82329f8b.webm'" exceeded the timeout of 3600 seconds.

However, the background process doing the encoding is still running:

PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
29057 taher 20 0 1055m 31m 5600 R 570 0.4 434:47.50 ffmpeg

Here is my code:

$ffmpeg->open($path)
->save(new Video\WebM(), $webmPath)
->save(new Video\X264(), $mp4Path);

Is there a way to configure php-ffmpeg to just log errors like this and continue with encoding and only throw exceptions if the background ffmpeg process exites with failure. Is there a way to make sure that the background process stops if php-ffmpeg throws an exception?

Thanks
Taher

Symfony2 ProcessUtils escapeshellarg() warning

Hello,

I got issue with php-ffmpeg/php-ffmpeg 0.4 with symfony 2.4.

Stacktrace:

ContextErrorException: Warning: escapeshellarg() expects parameter 1 to be string, resource given in /home/kofel/src/intranet/vendor/symfony/symfony/src/Symfony/Component/Process/ProcessUtils.php line 72
in /home/kofel/src/intranet/vendor/symfony/symfony/src/Symfony/Component/Process/ProcessUtils.php line 72
at ErrorHandler->handle('2', 'escapeshellarg() expects parameter 1 to be string, resource given', '/home/kofel/src/intranet/vendor/symfony/symfony/src/Symfony/Component/Process/ProcessUtils.php', '72', array('argument' => resource))
at escapeshellarg(resource) in /home/kofel/src/intranet/vendor/symfony/symfony/src/Symfony/Component/Process/ProcessUtils.php line 72
at ProcessUtils::escapeArgument(resource)
at array_map(array('Symfony\Component\Process\ProcessUtils', 'escapeArgument'), array('/usr/bin/avconv', '-y', '-i', '/tmp/phpTd3NwJ', '-async', '1', '-metadata:s:v:0', 'start_time=0', '-s', '640x480', '-vcodec', 'libx264', '-acodec', 'libfaac', '-b:v', '1000k', '-refs', '6', '-coder', '1', '-sc_threshold', '40', '-flags', '+loop', '-me_range', '16', '-subq', '7', '-i_qfactor', '0.71', '-qcomp', '0.6', '-qdiff', '4', '-trellis', '1', '-b:a', '128k', '-pass', '1', '-passlogfile', '/tmp/ffmpeg-passes5343e3b0f04499zm9i/pass-5343e3b0f04f6', resource)) in /home/kofel/src/intranet/vendor/symfony/symfony/src/Symfony/Component/Process/ProcessBuilder.php line 166
at ProcessBuilder->getProcess() in /home/kofel/src/intranet/vendor/alchemy/binary-driver/src/Alchemy/BinaryDriver/ProcessBuilderFactory.php line 163
at ProcessBuilderFactory->create(array('-y', '-i', '/tmp/phpTd3NwJ', '-async', '1', '-metadata:s:v:0', 'start_time=0', '-s', '640x480', '-vcodec', 'libx264', '-acodec', 'libfaac', '-b:v', '1000k', '-refs', '6', '-coder', '1', '-sc_threshold', '40', '-flags', '+loop', '-me_range', '16', '-subq', '7', '-i_qfactor', '0.71', '-qcomp', '0.6', '-qdiff', '4', '-trellis', '1', '-b:a', '128k', '-pass', '1', '-passlogfile', '/tmp/ffmpeg-passes5343e3b0f04499zm9i/pass-5343e3b0f04f6', resource)) in /home/kofel/src/intranet/vendor/alchemy/binary-driver/src/Alchemy/BinaryDriver/AbstractBinary.php line 137
at AbstractBinary->command(array('-y', '-i', '/tmp/phpTd3NwJ', '-async', '1', '-metadata:s:v:0', 'start_time=0', '-s', '640x480', '-vcodec', 'libx264', '-acodec', 'libfaac', '-b:v', '1000k', '-refs', '6', '-coder', '1', '-sc_threshold', '40', '-flags', '+loop', '-me_range', '16', '-subq', '7', '-i_qfactor', '0.71', '-qcomp', '0.6', '-qdiff', '4', '-trellis', '1', '-b:a', '128k', '-pass', '1', '-passlogfile', '/tmp/ffmpeg-passes5343e3b0f04499zm9i/pass-5343e3b0f04f6', resource), false, array(object(VideoProgressListener))) in /home/kofel/src/intranet/vendor/php-ffmpeg/php-ffmpeg/src/FFMpeg/Media/Video.php line 155
at Video->save(object(X264), resource) in /home/kofel/src/intranet/src/Berg/Intranet/KnowledgeBundle/Controller/KnowledgeController.php line 363
at KnowledgeController->videoUploadAction(object(Request))
at call_user_func_array(array(object(KnowledgeController), 'videoUploadAction'), array(object(Request))) in /home/kofel/src/intranet/app/bootstrap.php.cache line 2929
at HttpKernel->handleRaw(object(Request), '1') in /home/kofel/src/intranet/app/bootstrap.php.cache line 2901
at HttpKernel->handle(object(Request), '1', true) in /home/kofel/src/intranet/app/bootstrap.php.cache line 3040
at ContainerAwareHttpKernel->handle(object(Request), '1', true) in /home/kofel/src/intranet/app/bootstrap.php.cache line 2307
at Kernel->handle(object(Request)) in /home/kofel/src/intranet/web/app_dev.php line 30
at require('/home/kofel/src/intranet/web/app_dev.php') in /home/kofel/src/intranet/vendor/symfony/symfony/src/Symfony/Bundle/FrameworkBundle/Resources/config/router_dev.php line 30

Snippet code:

        $ffmpeg = \FFMpeg\FFMpeg::create();
        $video = $ffmpeg->open((string) $file);

        $video
            ->filters()
            ->resize(new \FFMpeg\Coordinate\Dimension(640, 480))
            ->synchronize();

        $mp4tmp = tmpfile();
        $webmtmp = tmpfile();

        $video
            ->save(new \FFMpeg\Format\Video\X264(), $mp4tmp)
            ->save(new \FFMpeg\Format\Video\WebM(), $webmtmp);

$file is just Symfony's UploadedFile object.

How to debug a failed encoding?

How do I get a more specific reason for a failure when encoding? Is it possible, even?

At the moment I just get an error like this:

exception 'Alchemy\BinaryDriver\Exception\ExecutionFailureException' with message 'ffmpeg failed to execute command '/usr/bin/ffmpeg' '-y' '-i' '/var/www/resources/original-videos/4.mov' '-vcodec' 'libx264' '-acodec' 'libfaac' '-b:v' '1000k' '-refs' '6' '-coder' '1' '-sc_threshold' '40' '-flags' '+loop' '-me_range' '16' '-subq' '7' '-i_qfactor' '0.71' '-qcomp' '0.6' '-qdiff' '4' '-trellis' '1' '-b:a' '128k' '-pass' '1' '-passlogfile' '/tmp/ffmpeg-passes531338a937a85kp7dv/pass-531338a937d92' '/var/www/resources/processing/4/videos/default.mp4'' in /var/www/vendor/alchemy/binary-driver/src/Alchemy/BinaryDriver/ProcessRunner.php:100

There's also another exception:

Next exception 'FFMpeg\Exception\RuntimeException' with message 'Encoding failed' in /var/www/vendor/php-ffmpeg/php-ffmpeg/src/FFMpeg/Media/Video.php:165

Obviously, these do not provide much help. I may be missing a codec or something, but how do I find that out?

Timecode or TimeCode ?

I guess there is an issue with FFMpeg\Media\Video : the public function frame() (line 156) seems to use ' Timecode $at ' (with no capital C) in its signature for FFMpeg\Coordinate\TimeCode

I did not tried yet but I guess its going to issue an error :)

Allow multiple streams stream as input

I am using this ffmpeg command in my PHP script and came across your library, I am particularly interested in the "progress" provided by this library. I am not very proficient to programming and would like to ask whether equivalent of this is possible in PHP-FFmpeg.

ffmpeg -i $aacAudioStreamURL -i $mp4VideoStreamURL -acodec copy -vcodec copy -f matroska -map_metadata -1 out.mp4

Any way to use it without composer?

Sorry for posting this here, but I can't find any forum nor mailing list. If one exists, I can't find any link to it.

Is it possible to use this library without relying on Composer? I have php 5.1.6 so I can't install composer.

"Encoding failed" with nginx and php-fpm

I got this error every time I try to run the script

FFMpeg\Exception\RuntimeException

File: vendor/php-ffmpeg/php-ffmpeg/src/FFMpeg/Media/Video.php:148
Message: Encoding failed

ffmpeg failed to execute command '/usr/bin/ffmpeg' '-y' '-i' '/tmp/php8aiScI' '-s' '1024x554' '-threads' '12' '-vcodec' 'libx264' '-acodec' 'libmp3lame' '-b:v' '1000k' '-refs' '6' '-coder' '1' '-sc_threshold' '40' '-flags' '+loop' '-me_range' '16' '-subq' '7' '-i_qfactor' '0.71' '-qcomp' '0.6' '-qdiff' '4' '-trellis' '1' '-b:a' '128k' '-pass' '1' '-passlogfile' 'pass-5231cb6a9085e' '/tmp/video97410_6e1fd0a1dc77c18b94da7f8210d331f8.mp4'

But if I ran it manually in the command-line it works fine (the ffmpeg command)

I also tried this solution you have in other project, but it doesn't solve the issue

Custom enconding settings

How can I specify custom encoding settings? save method currently has hardcoded settings, is it possible to specify my own?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.