使用PHP-FFMpeg(Laravel 5)的视频有意义的缩略图

我正在使用Laravel 5和 PHP-FFmpeg 库。</ p>

以前有人问过这个问题”使用FFmpeg的视频的有意义的缩略图“可以在命令行中使用。</ p>

但是,我想使用PHP-FFmpeg库实现功能等价。</ p>

我已经扫描了Stack Overflow和PHP-FFmpeg的单元测试来试图计算 出正确的语法,但它不是跳出来的。 </ p>

所以我希望有更多PHP-FFmpeg经验的人可以给我一些指示或示例,说明如何获得与本文中引用的命令行调用相同的结果: 使用FFmpeg的视频有意义的缩略图“。</ p>

提前感谢大家的帮助。</ p>

BTW,这是我在Stack Overflow上的第一篇文章,所以 网站不会让我发布所有相关链接(限制2)或为“PHP-FFmpeg”创建标签。 </ p>
</ div>



I'm working on a project using Laravel 5 and the PHP-FFmpeg Library.

Previously someone else asked this question "Meaningful thumbnails for a Video using FFmpeg" that works from the command line.

However, I want to implement the functional equivalent using the PHP-FFmpeg Library.

I have scanned both Stack Overflow and the Unit Tests for PHP-FFmpeg to try and figure out the correct syntax, but it is just not jumping out at me.

So I'm hoping someone with more experience with PHP-FFmpeg can give me some pointers or an example of how to achieve the same results as the command line calls referenced in this post: "Meaningful thumbnails for a Video using FFmpeg".

Thanks in advance for everyone's help.

BTW, This is my first post on Stack Overflow so the site won't let me post all the relevant links (limit 2) or create a tag for "PHP-FFmpeg".

doutu1939 我很清楚PHPexec()函数,是的,我可以使用它。但是,这不是我的问题。我的问题是使用PHP-FFmpeg库的功能等价物是什么...
5 年多之前 回复
duandi4815 你可以只需执行你想要的命令而不需要PHP-FFmpeg
5 年多之前 回复
duanpa2143 为什么不使用php的exec()函数通过php执行linux命令并将缩略图直接保存到您想要的位置
5 年多之前 回复


这可能有助于 https://trac.ffmpeg.org/wiki/PHP (请参阅页面底部的包装库一节)。</ p>
</ div>



This might help https://trac.ffmpeg.org/wiki/PHP (refer to the section Wrapper Libraries at the bottom of the page).

Csdn user default icon

<div class="post-text" itemprop="text"> <p>I'd like to put a watermark to a streaming video with Laravel-ffmpeg repo from Github, but it doesn't recognize its own methods. I've installed the package with composer according to the repo-s readme.md file from here: <a href="https://github.com/pascalbaljetmedia/laravel-ffmpeg" rel="nofollow noreferrer">https://github.com/pascalbaljetmedia/laravel-ffmpeg</a></p> <p>I know that there was a similar question <a href="https://stackoverflow.com/questions/45660168/laravel-ffmpeg-error-call-to-undefined-method-ffmpeg-ffmpegfromdisk">here</a>. But nobody answered the question and I've got the method inside the files.</p> <p>The installation worked properly. And to stream the video I use these codes: <a href="https://codesamplez.com/programming/php-html5-video-streaming-tutorial" rel="nofollow noreferrer">https://codesamplez.com/programming/php-html5-video-streaming-tutorial</a></p> <p>But when I put the code above to the <code>open()</code> method, Laravel doesn't find the <code>fromDisk</code> method from the FFMpeg.php file.</p> <pre><code>FFMpeg::fromDisk('videos') -&gt;open('steve_howe.mp4') -&gt;addFilter($clipFilter) -&gt;export() -&gt;toDisk('converted_videos') -&gt;inFormat(new \FFMpeg\Format\Video\X264) -&gt;save('short_steve.mkv'); </code></pre> <p>My composer.json look like this:</p> <pre><code>{ "name": "laravel/laravel", "type": "project", "description": "The Laravel Framework.", "keywords": [ "framework", "laravel" ], "license": "MIT", "require": { "php": "^7.1.3", "fideloper/proxy": "^4.0", "illuminate/config": "5.8.*", "illuminate/filesystem": "5.8.*", "illuminate/log": "5.8.*", "illuminate/support": "5.8.*", "laravel/framework": "5.8.*", "laravel/tinker": "^1.0", "league/flysystem": "~1.0", "pbmedia/laravel-ffmpeg": "^4.0", "php-ffmpeg/php-ffmpeg": "^0.13", "symfony/process": "~4.0" }, "require-dev": { "beyondcode/laravel-dump-server": "^1.0", "filp/whoops": "^2.0", "fzaninotto/faker": "^1.4", "mockery/mockery": "^1.0", "nunomaduro/collision": "^3.0", "phpunit/phpunit": "^7.5" }, "config": { "optimize-autoloader": true, "preferred-install": "dist", "sort-packages": true }, "extra": { "laravel": { "dont-discover": [] } }, "autoload": { "psr-4": { "App\\": "app/" }, "classmap": [ "database/seeds", "database/factories" ] }, "autoload-dev": { "psr-4": { "Tests\\": "tests/" } }, "minimum-stability": "dev", "prefer-stable": true, "scripts": { "post-autoload-dump": [ "Illuminate\\Foundation\\ComposerScripts::postAutoloadDump", "@php artisan package:discover --ansi" ], "post-root-package-install": [ "@php -r \"file_exists('.env') || copy('.env.example', '.env');\"" ], "post-create-project-cmd": [ "@php artisan key:generate --ansi" ] } } </code></pre> <p>How could I say to Laravel that recognize the methods?</p> <p>Thank you for the help in advance</p> </div>


<div class="post-text" itemprop="text"> <p>I'm using <a href="https://github.com/PHP-FFMpeg/PHP-FFMpeg" rel="nofollow">PHP-FFMpeg</a> in a Laravel 5.2 application to stabilize videos with the help of <a href="https://gist.github.com/maxogden/43219d6dcb9006042849" rel="nofollow">VidStab</a>. I have all the dependencies and everything installed correctly and I can follow the directions on the VidStab repo to stabilize my videos via the command line.</p> <p>My question is how could I do this nicely (the Laravel way) from within PHP? I know I can add a custom filter to the Video object like this:</p> <pre><code>$video = $ffmpeg-&gt;open('shaky_video.mp4'); $video-&gt;addFilter(new CustomFilter('vidstabdetect=stepsize=6:shakiness=8:accuracy=9:result=transform.trf')); </code></pre> <p>But how can I execute this command without the need for <code>$video-save()</code>, which I think is designed to output a video/audio file and not the <code>trf</code> analysis file?</p> <p>I suppose I could just run a PHP exec() command, but I would like to keep this as much object oriented PHP as I can. Any suggestions?</p> <p>Thanks in advance!</p> <hr> <p>I've tried this (added <code>-f null -</code> to filter and then tried running <code>save()</code> to execute the command), but it still creates the mp4 file instead of the trf file:</p> <pre><code>$video = $ffmpeg-&gt;open('shaky_video.mp4'); $video-&gt;addFilter(new CustomFilter('vidstabdetect=stepsize=6:shakiness=8:accuracy=9:result=transform.trf -f null -')); $video-&gt;save(new X264(), 'stabilized.mp4'); </code></pre> </div>


<div class="post-text" itemprop="text"> <p>I'm generating thumbnails like so:</p> <pre><code>exec(ffmpeg -itsoffset -4 -i '.$path.' -vcodec mjpeg -vframes 1 -an -f rawvideo -s 300x300 '.$other_path); </code></pre> <p>Is it possible to not specify the exact size of output image and set it to 100%?</p> </div>

如何修复视频处理和500错误 - (Laravel,FFmpeg)

<div class="post-text" itemprop="text"> <p>I'm setting up a new website with Laravel for uploading videos... I have read all the possible solutions but none of them help me to solve the issue...</p> <p>This is my issue: When I upload a small file (&lt;10mb) the web works fine, the video get uploaded and the video get converted, the dashboard shows the converted videos---</p> <p>When I try to upload a large file, the file get uploaded, the video get converted with a green frame on it (really uggly) and the site goes to a 500 server error...</p> <p>I'm using Laravel Jobs to do the conversion.</p> <p>My Controller code:</p> <pre><code> &lt;?php namespace App\Http\Controllers; use Illuminate\Http\Request; use Illuminate\Support\Facades\DB; use Illuminate\Support\Facades\Storage; use Symfony\Component\HttpFoundation\Response; use Carbon; use Closure; use App\Jobs\ConvertVideoForPreview; use FFMpeg\FFProbe; use FFMpeg\Coordinate\Dimension; use FFMpeg\Format\Video\X264; use Pawlox\VideoThumbnail\Facade\VideoThumbnail; use Pbmedia\LaravelFFMpeg\FFMpegFacade as FFMpeg; use Illuminate\Contracts\Filesystem\Filesystem; use App\Video; class VideoController extends Controller { public function createVideo(){ return view('video.createVideo'); } public function saveVideo(Request $request){ set_time_limit(0); ini_set('memory_limit', '1024M'); //Validar Formulario $validatedData = $this -&gt; validate($request, [ 'title' =&gt; 'required', 'description' =&gt; 'required', 'palabras' =&gt; 'required', 'video' =&gt; 'mimetypes:video/mp4,video/quicktime' ]); $video = new Video(); $user = \Auth::user(); $video -&gt; user_id = $user-&gt;id; $video -&gt; title = $request -&gt; input('title'); $video -&gt; description = $request -&gt; input('description'); $video -&gt; palabras = $request -&gt; input('palabras'); $video_file = $request -&gt; file('video'); if($video_file){ $video_path = 'original'.'_'.$video_file -&gt; getClientOriginalName(); Storage::disk('videos')-&gt; put($video_path, \File::get($video_file)); $videoUrl = storage_path('app/videos/').$video_path; $storageUrl = storage_path('app/thumbs/'); $fileName = 'thumb'.'_'.time().'.jpg'; $second = 2; VideoThumbnail::createThumbnail($videoUrl, $storageUrl, $fileName, $second, $width = 640, $height = 480); $video -&gt; preview = $fileName; $video -&gt; video_path = $video_path; } $video -&gt; save(); ConvertVideoForPreview::dispatch($video); return redirect() -&gt; route('home') -&gt; with (array( 'message' =&gt; 'El video se ha enviado con exito')); } public function getImage($filename){ $file = Storage::disk('thumbs') -&gt; get($filename); return new Response($file, 200); } public function getVideo($filename){ $file = Storage::disk('converted_videos') -&gt; get($filename); return new Response($file, 200); } } </code></pre> <p>This is my ConvertVideo Job:</p> <pre><code> &lt;?php namespace App\Jobs; use App\Video; use Carbon\Carbon; use FFMpeg; use FFMpeg\Format\Video\X264; use Illuminate\Http\Request; use Illuminate\Bus\Queueable; use Illuminate\Queue\SerializesModels; use Illuminate\Queue\InteractsWithQueue; use Illuminate\Contracts\Queue\ShouldQueue; use Illuminate\Foundation\Bus\Dispatchable; class ConvertVideoForPreview implements ShouldQueue { use Dispatchable, InteractsWithQueue, Queueable, SerializesModels; public $video; public function __construct(Video $video) { $this -&gt; video = $video; } public function handle() { $converted_name= 'preview'.'-'.$this -&gt; video -&gt; video_path.'.mp4'; FFMpeg::open('videos/'.$this -&gt; video -&gt; video_path) -&gt; export() -&gt; inFormat(new \FFMpeg\Format\Video\X264) -&gt; save('converted_videos/'.$converted_name); $this -&gt; video -&gt; update([ 'video_preview' =&gt; $converted_name, 'processed' =&gt; true ]); } } </code></pre> <p>One of my goals is to upload large video files (&lt;=4GB), show a uploading process bar and a encoding process bar during the video upload.</p> <p>I getting this error:</p> <pre><code> [core:error] [pid 14787:tid 139975366489856] [client] Script timed out before returning headers: index.php, </code></pre> <p>It's happend when the video es proccesing and the redirect to home dashboard it's call...</p> <p>The FFMPEG works:</p> <pre><code>[2019-07-19 17:20:41] local.INFO: ffprobe executed command successfully [2019-07-19 17:21:52] local.INFO: ffmpeg executed command successfully [2019-07-19 17:21:52] local.INFO: ffmpeg running command '/usr/local/bin/ffmpeg' '-y' '-i' '/home/tribus/public_html/storage/app/videos/original_Sequence 01.mov' '-threads' '12' '-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' '2' '-passlogfile' '/tmp/ffmpeg-passes5d31fbe9010e6ldt9s/pass-5d31fbe90152d' '/home/tribus/public_html/storage/app/converted_videos/preview-original_Sequence 01.mov.mp4' </code></pre> <p>I have tried: Change all the memory and file size in PHP.ini, Nginx, Apache... (Probably I'm missing one)... </p> <p>Changed timeouts too.</p> <p>My environment: VPS 4GB 50GB, APACHE 2.4, PHP7.3, MySql MariaDB, WebServer: Apache-Nginx, Laravel 5.8.</p> <p>Can anyone help me to reach this?...</p> <p>This is how the large video looks after converted and show 500 error in the browser: <a href="https://i.stack.imgur.com/YzjSd.png" rel="nofollow noreferrer">Error video processed</a></p> </div>

无法加载FFProbe - Ubuntu - Laravel 5.5

<div class="post-text" itemprop="text"> <p>I know there are already many questions asked over this issue. Been searching for the solution since last 2 days. I have found several forums:</p> <p><a href="https://stackoverflow.com/questions/51526185/ubuntu-laravel-5-6-unable-to-load-ffprobe-using-php-ffmpeg">Ubuntu - Laravel 5.6 - Unable to load ffprobe (using php-ffmpeg)</a></p> <p><a href="https://stackoverflow.com/questions/38598649/unable-to-load-ffprobe-in-laravel-app">Unable to load FFProbe in laravel app</a></p> <p><a href="https://stackoverflow.com/questions/51125964/getting-error-unable-to-load-ffprobe">getting error Unable to load FFprobe</a></p> <p><a href="https://stackoverflow.com/questions/29916963/laravel-unable-to-load-ffprobe">Laravel unable to load FFProbe?</a></p> <p><a href="https://stackoverflow.com/questions/32859455/unable-to-load-ffprobe-driver-for-ffmpeg">Unable to load FFProbe driver for FFmpeg</a></p> <p>I have already tried all of the above suitable solutions but none worked. Also tried installing the below given packages.</p> <p><code>composer require sormagec/laravel-ffmpeg</code></p> <p><code>composer require pbmedia/laravel-ffmpeg</code> (Didn't work because of laravel version, I guess)</p> <p>I have set the binary paths correctly:</p> <pre><code>return [ 'default_disk' =&gt; 'local', 'ffmpeg.binaries' =&gt; '/usr/bin/ffmpeg', 'ffmpeg.threads' =&gt; 12, 'ffprobe.binaries' =&gt; '/usr/bin/ffprobe', 'timeout' =&gt; 3600, ]; </code></pre> <p>I am using Laravel 5.5 version</p> <p>I am not sure what else is missing or where am I lacking. I have installed ffmpeg in my ubuntu. And other required packages in my Laravel application. Please help me out if anything else is missing. </p> </div>


IIS环境,多进程,thinkphp运行FFMPEG的截取视频缩略图 代码:"ffmpeg -i " . $srcAddr . " -y -f image2 -ss 3 -t 0.001 " . $dntAddr; 运行后,可以生产缩略图,但是点击项目其他链接,php-cgi.exe直接关闭报500错误。 是否是运行ffmpeg时,进程僵尸了?该怎么解决? 有遇到故这个问题的吗?


<div class="post-text" itemprop="text"> <p>i want to create a thumbnails on video that uploaded, i've been using mmpeg, i've been try this code but it not working yet</p> <p>this is my code on controller</p> <pre><code>use ffmpeg\FFMPEG; public function store(Request $request) { $news = new News; $filename = $request-&gt;file('attachment')-&gt;getClientOriginalName(); $request-&gt;file('attachment')-&gt;storeAs('attachment', $filename); $thumbnails = new FFMPEG; $thumbnails-&gt;getThumbnails($filename, 'thumbnails', 5); } </code></pre> <p>i've been also setting on config/app.php like this</p> <pre><code>LinkThrow\Ffmpeg\Provider\FfmpegServiceProvider::class, //providers </code></pre> <p><code>'FFMPEG' =&gt; LinkThrow\Ffmpeg\Facade\FfmpegFacade::class, //aliases</code></p> <p>the error is</p> <blockquote> <p>Class 'ffmpeg\FFMPEG' not found</p> </blockquote> <p>is there need to setting up on config/ffmpeg.php too ?</p> </div>



PHP-FFMpeg filters() - > resize()throw使用未定义的常量RESIZEMODE_INSET

<div class="post-text" itemprop="text"> <p>I'm using <code>PHP-FFMpeg</code> to use FFMpeg with php, unfortunately I can't set resize filter.</p> <p>This is my code:</p> <pre><code>$video = $ffmpeg-&gt;open('video.mov'); $dimension = new FFMpeg\Coordinate\Dimension(1920, 1080); $video-&gt;filters() -&gt;resize($dimension, RESIZEMODE_INSET, true, 1) -&gt;synchronize(); $format = new FFMpeg\Format\Video\X264('aac', 'libx264'); $format-&gt;setAudioChannels(2)-&gt;setAudioKiloBitrate(256); $video-&gt;save($format, 'video.mp4'); </code></pre> <p>But it throws this error:</p> <p><code>Use of undefined constant RESIZEMODE_INSET - assumed 'RESIZEMODE_INSET'</code></p> <p>I tried also:</p> <p><code>-&gt;resize($dimension, 'RESIZEMODE_INSET', true, 1)</code></p> <p>and</p> <p><code>-&gt;resize($dimension, 'inset', true, 1)</code></p> <p>But I can't get the video converted without stretching.</p> <p>Thanks in advance</p> </div>

PHP / FFmpeg无法保存视频

<div class="post-text" itemprop="text"> <p>The error is:</p> <blockquote> <p>[Sun May 19 11:41:03.158185 2019] [php7:error] [pid 32405] [client] PHP Fatal error: Uncaught Alchemy\BinaryDriver\Exception\ExecutionFailureException: ffmpeg failed to execute command '/usr/bin/ffmpeg' '-y' '-i' 'Sample.mp4' '-async' '1' '-metadata:s:v:0' 'start_time=0' '-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' '-vf' '[in]scale=320:240 [out]' 'export-webm.webm' in /vendor/alchemy/binary-driver/src/Alchemy/BinaryDriver/ProcessRunner.php:100 Stack trace: #0 /vendor/alchemy/binary-driver/src/Alchemy/BinaryDriver/ProcessRunner.php(72): Alchemy\BinaryDriver\ProcessRunner-&gt;doExecutionFailure(''/usr/bin/ffmpe...') #1 /vendor/alchemy/binary-driver/src/Alchemy/BinaryDriver/AbstractBinary.php(209): Alchemy\BinaryDriver\ProcessRunner-&gt;run(Object(Symfony\Component\Process\Process), Object(SplObjectStorage), false) #2 /vendor/alchemy/binary-driver/src/Alchemy/BinaryDriver/AbstractBinary.php(137): Alchemy\BinaryDr in /vendor/php-ffmpeg/php-ffmpeg/src/FFMpeg/Media/AbstractVideo.php on line 106a</p> </blockquote> <p>What I trying to do is, save video:</p> <pre><code>require '/vendor/autoload.php'; $ffmpeg = FFMpeg\FFMpeg::create(); $ffprobe = FFMpeg\FFProbe::create(); $video = $ffmpeg-&gt;open('Sample.mp4'); $video -&gt;filters() -&gt;resize(new FFMpeg\Coordinate\Dimension(320, 240)) -&gt;synchronize(); $video -&gt;save(new FFMpeg\Format\Video\X264('aac'), 'export-x264.mp4') </code></pre> <p>What I have done:</p> <p>I searched and similar topics tell me to set permission to my files and folders, I set user and also set 755 to files and folders but still I have this error and no success, any idea?</p> <p>Errorlog:</p> <blockquote> <p>Fatal error: Uncaught Alchemy\BinaryDriver\Exception\ExecutionFailureException: ffmpeg failed to execute command '/usr/bin/ffmpeg' '-y' '-i' 'Sample.mp4' '-async' '1' '-metadata:s:v:0' 'start_time=0' '-vcodec' 'libx264' '-acodec' 'aac' '-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' '-vf' '[in]scale=320:240 [out]' '-pass' '1' '-passlogfile' '/tmp/ffmpeg-passes5ce11d01dc0038yfbl/pass-5ce11d01dc0c7' 'export-x264.mp4' in /vendor/alchemy/binary-driver/src/Alchemy/BinaryDriver/ProcessRunner.php:100 Stack trace: #0 /vendor/alchemy/binary-driver/src/Alchemy/BinaryDriver/ProcessRunner.php(72): Alchemy\BinaryDriver\ProcessRunner-&gt;doExecutionFailure(''/usr/bin/ffmpe...')</p> <h1>1 /vendor/alchemy/binary-driver/src/Alchemy/BinaryDriver/AbstractBinary.php(209):</h1> <p>Alchemy\BinaryDriver\ProcessRunner-&gt;run(Object(Symfony\Component\Process\Process), Object(SplObjectStorage), false) #2 /vendor/alchemy/binary-driver in /vendor/php-ffmpeg/php-ffmpeg/src/FFMpeg/Media/AbstractVideo.php on line 106</p> </blockquote> </div>


<div class="post-text" itemprop="text"> <p>I'm trying to use FFMPEG on my website on localhost to take a thumbnail of a video that is being uploaded and save it to a folder on the server but it is not working.</p> <p>I've tested if this code works by running the code on a video file in the same directory and it works fine but when I tried integrating it into my website it does not work.</p> <pre><code>&lt;?php $fileHead=$title."-".$artist; $output = 'uploadedvidpics/'.$fileHead.'.jpg'; function make_jpg($fileTmpName, $output, $fromdurasec="05") { global $ffmpegpath; if(!file_exists($fileTmpName)) return false; $command = "$ffmpegpath -i $fileTmpName -an -ss 00:00:$fromdurasec -r 1 -vframes 1 -f mjpeg -y $output"; @exec( $command, $ret ); if(!file_exists($output)) return false; if(filesize($output)==0) return false; return true; } if (make_jpg($fileTmpName, $output)){ #echo 'success'; }else{ array_push($errors,"There was an error creating thumbnail!"); } ?&gt; </code></pre> <p>I expect the file to take a thumbnail, save it in a directory named uploadedvidpics</p> </div>

在Ubuntu 12.04中安装FFMpeg并在PHP-FFMpeg中使用它

<div class="post-text" itemprop="text"> <p>I have tried many many failed attempt to install FFMpeg in my Ubuntu 12.04. I used following links: <a href="http://www.mysql-apache-php.com/ffmpeg-install.htm" rel="nofollow">1</a>, <a href="http://blog.shineservers.com/installing-and-configuring-ffmpeg-and-ffpeg-php/" rel="nofollow">2</a>, <a href="https://www.ndchost.com/wiki/server-administration/install-ffmpeg" rel="nofollow">3</a> and many others.</p> <p>Then I need to use it in <a href="https://github.com/PHP-FFMpeg/PHP-FFMpeg" rel="nofollow">PHP-FFMpeg</a> And Then I need to deploy in Linux based server. This is my requirement.</p> <p>But after much trying, I just downloaded static build through this <a href="http://johnvansickle.com/ffmpeg/" rel="nofollow">link</a>.</p> <p>This helped me to successfully convert video and use FFMpeg through terminal in Ubuntu. But I cannot use it through PHP-FFMpeg library <strong>which I need to run</strong>. In docs of PHP-FFMpeg it is written <br></p> <blockquote> <p>This library requires a working FFMpeg install. You will need both FFMpeg and FFProbe binaries to use it. Be sure that these binaries can be located with system PATH to get the benefit of the binary detection, otherwise you should have to explicitely give the binaries path on load.</p> </blockquote> <p>and I am not getting this.</p> </div>


<div class="post-text" itemprop="text"> <p>I have read <a href="https://stackoverflow.com/questions/9107710/create-video-thumbnail-of-all-files-in-a-directory-via-ffmpeg-and-php">this</a> but didnt help too much.</p> <p>I have a folder called <strong>videos</strong> and another folder called <strong>thumbnails</strong>. I have many mp4 videos in video folder and want to catch thumbnails at 4th second to the thumbnails folder using ffmpeg and php. </p> <ol> <li>I am using Wamp server 2.2 on windows whit php 5.3.8 and Apache 2.2.21 </li> <li>I downloaded ffmpeg from <strong>FFmpeg Windows Builds</strong> section of <a href="http://www.ffmpeg.org/download.html" rel="nofollow noreferrer">ffmpeg download page</a> and the static 32 build from <a href="http://ffmpeg.zeranoe.com/builds/win32/static/ffmpeg-latest-win32-static.7z" rel="nofollow noreferrer">this</a> link. </li> <li><p>I extracted the 7z file to my website root<br> here is my php code: </p> <pre><code>$ffmpeg = "includes/ffmpeg/bin/ffmpeg"; foreach(glob('files/videos/*.mp4') as $pathname){ $filename = substr($pathname,13,strripos($pathname,'.mp4')-13); $thumbnail = 'files/thumbnails/'.$filename.'.jpg'; exec("ffmpeg -i $pathname -an -y -f mjpeg -ss 00:00:04 -vframes 1 $thumbnail"); } </code></pre></li> </ol> <p>but nothing happens and the thumbnails folder is always empty!<br> - How can I find out is ffmpeg installed on my server or not?<br> - How can I get my script to work?<br> Please help</p> </div>


<div class="post-text" itemprop="text"> <p>I have written a code to get an image from an uploaded mp4 video using ffmpeg in YII.</p> <p>In localhost, when i have written absolute path like <code>d:/wamp/www/projectname/ffmpeg</code> like this, it is working perfectly and i am getting image but when I tried like below using <code>baseurl</code></p> <pre><code>$var="http://".$_SERVER['HTTP_HOST'].Yii::app()-&gt;request-&gt;baseUrl; $ffmpeg = $var."/ffmpeg/bin/ffmpeg.exe"; </code></pre> <p>I am unable to get the image from video.</p> <p>Here is my code</p> <pre><code>$var="http://".$_SERVER['HTTP_HOST'].Yii::app()-&gt;request-&gt;baseUrl; $ffmpeg = $var."/ffmpeg/bin/ffmpeg.exe"; // $uploaddir is my file upload path $video = $uploaddir.$image_name; //where to save the image $iname = basename($image_name, ".mp4"); $image = $uploaddir.'/'.$iname.'_img.jpg'; //time to take screenshot at $interval = 5; //screenshot size pn $size = '640x480'; //ffmpeg command $cmd="$ffmpeg -i ".$video." -ss 00:00:01.100 -f image2 -vframes 1 ".$image; exec($cmd); </code></pre> </div>

无法在Ubuntu 14.04上安装ffmpeg-php

<div class="post-text" itemprop="text"> <p>I downloaded <strong>FFmpeg (version 2.2.3)</strong> and compiled with <strong>--disable-yasm</strong> and <strong>--enable-shared</strong> configuration and installed.</p> <p>I then downloaded <strong>ffmpeg-php</strong> extension from here - <a href="http://sourceforge.net/projects/ffmpeg-php/files/ffmpeg-php/0.6.0/" rel="nofollow">http://sourceforge.net/projects/ffmpeg-php/files/ffmpeg-php/0.6.0/</a></p> <p>I was able to phpize and configure successfully.</p> <p><strong>phpize output:</strong></p> <pre><code>Configuring for: PHP Api Version: 20121113 Zend Module Api No: 20121212 Zend Extension Api No: 220121212 </code></pre> <p><strong>php --version output:</strong></p> <pre><code>PHP 5.5.9-1ubuntu4.4 (cli) (built: Sep 4 2014 06:56:34) Copyright (c) 1997-2014 The PHP Group Zend Engine v2.5.0, Copyright (c) 1998-2014 Zend Technologies with Zend OPcache v7.0.3, Copyright (c) 1999-2014, by Zend Technologies </code></pre> <p>But, when I try to make install my ffmpeg-php extension after successfully configuring, I am getting following error.</p> <p><strong>Error log:</strong></p> <pre><code>/bin/bash /tmp/ffmpeg-php-0.6.0/libtool --mode=compile cc -I. -I/tmp/ffmpeg-php-0.6.0 -DPHP_ATOM_INC -I/tmp/ffmpeg-php-0.6.0/include -I/tmp/ffmpeg-php-0.6.0/main -I/tmp/ffmpeg-php-0.6.0 -I/usr/include/php5 -I/usr/include/php5/main -I/usr/include/php5/TSRM -I/usr/include/php5/Zend -I/usr/include/php5/ext -I/usr/include/php5/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/ -DHAVE_CONFIG_H -g -O2 -Wall -fno-strict-aliasing -c /tmp/ffmpeg-php-0.6.0/ffmpeg-php.c -o ffmpeg-php.lo libtool: compile: cc -I. -I/tmp/ffmpeg-php-0.6.0 -DPHP_ATOM_INC -I/tmp/ffmpeg-php-0.6.0/include -I/tmp/ffmpeg-php-0.6.0/main -I/tmp/ffmpeg-php-0.6.0 -I/usr/include/php5 -I/usr/include/php5/main -I/usr/include/php5/TSRM -I/usr/include/php5/Zend -I/usr/include/php5/ext -I/usr/include/php5/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/ -DHAVE_CONFIG_H -g -O2 -Wall -fno-strict-aliasing -c /tmp/ffmpeg-php-0.6.0/ffmpeg-php.c -fPIC -DPIC -o .libs/ffmpeg-php.o In file included from /usr/include/x86_64-linux-gnu/sys/stat.h:105:0, from /usr/include/php5/main/php_streams.h:28, from /usr/include/php5/main/php.h:396, from /tmp/ffmpeg-php-0.6.0/ffmpeg-php.c:40: /usr/include/x86_64-linux-gnu/bits/stat.h:91:21: error: field 'st_atim' has incomplete type struct timespec st_atim; /* Time of last access. */ ^ /usr/include/x86_64-linux-gnu/bits/stat.h:92:21: error: field 'st_mtim' has incomplete type struct timespec st_mtim; /* Time of last modification. */ ^ /usr/include/x86_64-linux-gnu/bits/stat.h:93:21: error: field 'st_ctim' has incomplete type struct timespec st_ctim; /* Time of last status change. */ ^ /usr/include/x86_64-linux-gnu/bits/stat.h:152:21: error: field 'st_atim' has incomplete type struct timespec st_atim; /* Time of last access. */ ^ /usr/include/x86_64-linux-gnu/bits/stat.h:153:21: error: field 'st_mtim' has incomplete type struct timespec st_mtim; /* Time of last modification. */ ^ /usr/include/x86_64-linux-gnu/bits/stat.h:154:21: error: field 'st_ctim' has incomplete type struct timespec st_ctim; /* Time of last status change. */ ^ In file included from /usr/include/php5/main/php_streams.h:28:0, from /usr/include/php5/main/php.h:396, from /tmp/ffmpeg-php-0.6.0/ffmpeg-php.c:40: /usr/include/x86_64-linux-gnu/sys/stat.h:365:31: error: array type has incomplete element type const struct timespec __times[2], ^ /usr/include/x86_64-linux-gnu/sys/stat.h:372:54: error: array type has incomplete element type extern int futimens (int __fd, const struct timespec __times[2]) __THROW; ^ In file included from /usr/include/php5/main/php.h:402:0, from /tmp/ffmpeg-php-0.6.0/ffmpeg-php.c:40: /usr/include/php5/TSRM/tsrm_virtual_cwd.h:218:2: error: unknown type name 'time_t' time_t expires; ^ /usr/include/php5/TSRM/tsrm_virtual_cwd.h:246:86: error: unknown type name 'time_t' CWD_API realpath_cache_bucket* realpath_cache_lookup(const char *path, int path_len, time_t t TSRMLS_DC); ^ /tmp/ffmpeg-php-0.6.0/ffmpeg-php.c: In function 'zm_startup_ffmpeg': /tmp/ffmpeg-php-0.6.0/ffmpeg-php.c:94:5: warning: implicit declaration of function 'avcodec_init' [-Wimplicit-function-declaration] avcodec_init(); ^ make: *** [ffmpeg-php.lo] Error 1 </code></pre> <p>How can I solve this? Or is there any other php library which can be used to extract all metadata of a video like bit rate, frame rate etc?</p> </div>

使用cpulimit和PHP减少FFmpeg CPU使用率

<div class="post-text" itemprop="text"> <p>I run <a href="https://ffmpeg.org/" rel="nofollow noreferrer">FFmpeg</a> on my server using PHP <code>exec()</code>.</p> <p>It currently uses 100% of the cpu thread while encoding. </p> <p>I followed <a href="https://lorenzo.mile.si/2016/07/limiting-cpu-usage-and-server-load-with-ffmpeg/" rel="nofollow noreferrer">this gude</a> that uses a program called <a href="https://github.com/opsengine/cpulimit" rel="nofollow noreferrer">cpulimit</a> to reduce it to 30%.</p> <hr> <p><strong>PHP</strong></p> <pre><code>$args = "nice -19 cpulimit -l 30 -- ffmpeg -y -i intput.avi -vcodec libx264 -acodec aac -b:a 192k -threads 1 output.mp4" exec(escapeshellcmd($args)); </code></pre> <p>FFmpeg/PHP works, and it will work with <code>nice</code>/<code>cpulimit</code> through the terminal, but after adding<br> <code>nice -19 cpulimit -l 30 --</code> to the PHP script it no longer works with <code>exec()</code>.</p> <hr> <p><strong>Output</strong></p> <p>FFmpeg output returns blank. I'm not able to see the full output, I tried using:</p> <pre><code>$output = shell_exec($args); echo "&lt;p&gt;$output&lt;/p&gt;" </code></pre> <p>and</p> <pre><code>file_put_contents("/var/www/mysite/logs/$output.log", $line . PHP_EOL, FILE_APPEND); </code></pre> <p>But they return 1 empty line.</p> <hr> <p><strong>Solution</strong></p> <p>My thought is that www-data runs FFmpeg and <code>nice</code>/<code>cpulimit</code> may need root?</p> <p>How can I get PHP <code>exec()</code> to work with FFmpeg args and cpulimit? </p> <p>Or is there an alternative way to limit the usage %?</p> </div>


<div class="post-text" itemprop="text"> <p>I got </p> <blockquote> <p>PHP Fatal error: Class 'ffmpeg_movie not found</p> </blockquote> <p>I found several archives with php_ffmpeg.dll also I have add <code>extension=php_ffmpeg.dll</code> in php.ini, restart the apache but nothing related with <strong>ffmpeg</strong> shows up when check phpinfo()</p> <p>My server is running on Windows and I need help with installing that library.</p> <p>I just look in error.log and found following line</p> <blockquote> <p>PHP Warning: PHP Startup: Unable to load dynamic library 'C:\xampp\php\ext\php_ffmpeg.dll' - The specified module could not be found. in Unknown on line 0 but the dll file is there</p> </blockquote> </div>


<div class="post-text" itemprop="text"> <p>I want to mimic the bing video preview functionality, with a thumbnail preview, then onMouseOver, load and play a video file. I plan to use <a href="http://videojs.com/" rel="nofollow">VideoJS</a> (html5 + flash) for the video playback. I need to use ffmpeg to produce these video files.</p> <p>How can I create a mp4 preview with video only, which contains 1s of every other minute of the full clip, and shrink resolution to a fixed width (maintaining aspect ratio, preferably with zoom crop) using php + ffmpeg command line?</p> <p>I'm assuming it can be done somehow along the lines of cutting 1s clips, then combine the smaller clips, and re-encode for a final rescaled output.</p> <p>*<strong>Edit</strong>: Using ffmpeg is a design requirement. Pulling out 1s clips, should be fairly easy, but combining them seems to be somewhat complex with ffmpeg. I don't want cycling thumbnails, I want a video preview which contains a number of 1s clips. Eg. runtime in seconds: 100-101, and 200-201 combined in a heavily compressed clip. I am asking for a command line example of how to do this in an efficient manner.</p> </div>


<div class="post-text" itemprop="text"> <p>I'm using the PHP-FFMpeg repository to do some video work inside my Laravel application, but I'm encountering some issues setting it up. Once I've installed the PHP-FFMpeg repo, I try and create an <code>FFMpeg</code> instance:</p> <pre><code>$ffmpeg = \FFMpeg\FFMpeg::create(); </code></pre> <p>However, this does not work. In response, I get an ErrorException that simply states:</p> <pre><code>Unable to load FFProbe </code></pre> <p>This does not make sense to me, as when I run <code>ffmpeg</code> and <code>ffprobe</code> from my Mac's terminal, I can see they are installed. This is clearly a path/resolving issue, but I'm unsure how to fix it. Any ideas?</p> <p>This is all hosted under a MAMP project, running on localhost. </p> </div>

技术大佬:我去,你写的 switch 语句也太老土了吧

昨天早上通过远程的方式 review 了两名新来同事的代码,大部分代码都写得很漂亮,严谨的同时注释也很到位,这令我非常满意。但当我看到他们当中有一个人写的 switch 语句时,还是忍不住破口大骂:“我擦,小王,你丫写的 switch 语句也太老土了吧!” 来看看小王写的代码吧,看完不要骂我装逼啊。 private static String createPlayer(PlayerTypes p...


提到“程序员”,多数人脑海里首先想到的大约是:为人木讷、薪水超高、工作枯燥…… 然而,当离开工作岗位,撕去层层标签,脱下“程序员”这身外套,有的人生动又有趣,马上展现出了完全不同的A/B面人生! 不论是简单的爱好,还是正经的副业,他们都干得同样出色。偶尔,还能和程序员的特质结合,产生奇妙的“化学反应”。 @Charlotte:平日素颜示人,周末美妆博主 大家都以为程序媛也个个不修边幅,但我们也许...


CSDN:因博主近期注重写专栏文章(已超过150篇),订阅博主专栏人数在突增,近期很有可能提高专栏价格(已订阅的不受影响),提前声明,敬请理解! 目录 博客声明 大数据了解博主粉丝 博主的粉丝群体画像 粉丝群体性别比例、年龄分布 粉丝群体学历分布、职业分布、行业分布 国内、国外粉丝群体地域分布 博主的近期访问每日增量、粉丝每日增量 博客声明 因近期博主写专栏的文章越来越多,也越来越精细,逐步优化文章。因此,最近一段时间,订阅博主专栏的人数增长也非常快,并且专栏价




接着上回说,培训班学习生涯结束了。后面每天就是无休止的背面试题,不是没有头脑的背,培训公司还是有方法的,现在回想当时背的面试题好像都用上了,也被问到了。回头找找面试题,当时都是打印下来天天看,天天背。 不理解呢也要背,面试造飞机,上班拧螺丝。班里的同学开始四处投简历面试了,很快就有面试成功的,刚开始一个,然后越来越多。不知道是什么原因,尝到胜利果实的童鞋,不满足于自己通过的公司,嫌薪水要少了,选择...

面试了一个 31 岁程序员,让我有所触动,30岁以上的程序员该何去何从?





已经连续五年参加大厂校招、社招的技术面试工作,简历看的不下于万份 这篇文章会用实例告诉你,什么是差的程序员简历! 疫情快要结束了,各个公司也都开始春招了,作为即将红遍大江南北的新晋UP主,那当然要为小伙伴们做点事(手动狗头)。 就在公众号里公开征简历,义务帮大家看,并一一点评。《启舰:春招在即,义务帮大家看看简历吧》 一石激起千层浪,三天收到两百多封简历。 花光了两个星期的所有空闲时...


近日,有网友在某职场社交平台吐槽,自己裸辞两个月了,但是找工作却让自己的心态都要崩溃了,全部无果,不是已查看无回音,就是已查看不符合。 “工作八年,两年一跳,裸辞两个月了,之前月薪60K,最近找工作找的心态崩了!所有招聘工具都用了,全部无果,不是已查看无回音,就是已查看不符合。进头条,滴滴之类的大厂很难吗???!!!投简历投的开始怀疑人生了!希望 可以收到大厂offer” 先来看看网...


这是世界编程大赛第一名作品(97年Mekka ’97 4K Intro比赛)汇编语言所写。 整个文件只有4095个字节, 大小仅仅为16KB! 不仅实现了3D动画的效果!还有一段震撼人心的背景音乐!!! 内容无法以言语形容,实在太强大! 下面是代码,具体操作看最后! @echo off more +1 %~s0|debug e100 33 f6 bf 0 20 b5 10 f3 a5...

不要再到处使用 === 了

我们知道现在的开发人员都使用 === 来代替 ==,为什么呢?我在网上看到的大多数教程都认为,要预测 JavaScript 强制转换是如何工作这太复杂了,因此建议总是使用===。这些都...


A站 AcFun弹幕视频网,简称“A站”,成立于2007年6月,取意于Anime Comic Fun,是中国大陆第一家弹幕视频网站。A站以视频为载体,逐步发展出基于原生内容二次创作的完整生态,拥有高质量互动弹幕,是中国弹幕文化的发源地;拥有大量超粘性的用户群体,产生输出了金坷垃、鬼畜全明星、我的滑板鞋、小苹果等大量网络流行文化,也是中国二次元文化的发源地。 B站 全称“哔哩哔哩(bilibili...




前期回顾: MySQL性能优化(一):MySQL架构与核心问题 MySQL性能优化(二):选择优化的数据类型 MySQL性能优化(三):深入理解索引的这点事 MySQL性能优化(四):如何高效正确的使用索引 前面章节我们介绍了如何选择优化的数据类型、如何高效的使用索引,这些对于高性能的MySQL来说是必不可少的。但这些还完全不够,还需要合理的设计查询。如果查询写的很糟糕,即使表结构再合理、索引再...

用了这个 IDE 插件,5分钟解决前后端联调!

点击上方蓝色“程序猿DD”,选择“设为星标”回复“资源”获取独家整理的学习资料!作者 |李海庆我是一个 Web 开发前端工程师,受到疫情影响,今天是我在家办公的第78天。开发了两周,...

大厂的 404 页面都长啥样?最后一个笑了...

每天浏览各大网站,难免会碰到404页面啊。你注意过404页面么?猿妹搜罗来了下面这些知名网站的404页面,以供大家欣赏,看看哪个网站更有创意: 正在上传…重新上传取消 腾讯 正在上传…重新上传取消 网易 淘宝 百度 新浪微博 正在上传…重新上传取消 新浪 京东 优酷 腾讯视频 搜...


网上很多的文章和帖子中在介绍秒杀系统时,说是在下单时使用异步削峰来进行一些限流操作,那都是在扯淡! 因为下单操作在整个秒杀系统的流程中属于比较靠后的操作了,限流操作一定要前置处理,在秒杀业务后面的流程中做限流操作是没啥卵用的。


不怕告诉你,我自从喜欢上了这12个UP主,哔哩哔哩成为了我手机上最耗电的软件,几乎每天都会看,可是吧,看的越多,我就越觉得自己是个废柴,唉,老天不公啊,不信你看看…… 间接性踌躇满志,持续性混吃等死,都是因为你们……但是,自己的学习力在慢慢变强,这是不容忽视的,推荐给你们! 都说B站是个宝,可是有人不会挖啊,没事,今天咱挖好的送你一箩筐,首先啊,我在B站上最喜欢看这个家伙的视频了,为啥 ,咱撇...


某站后端代码被“开源”,同时刷遍全网的,还有代码里的那些神注释。 我们这才知道,原来程序员个个都是段子手;这么多年来,我们也走过了他们的无数套路… 首先,产品经理,是永远永远吐槽不完的!网友的评论也非常扎心,说看这些代码就像在阅读程序员的日记,每一页都写满了对产品经理的恨。 然后,也要发出直击灵魂的质问:你是尊贵的付费大会员吗? 这不禁让人想起之前某音乐app的穷逼Vip,果然,穷逼在哪里都是...

Java14 新特性解读

Java14 已于 2020 年 3 月 17 号发布,官方特性解读在这里:https://openjdk.java.net/projects/jdk/14/以下是个人对于特性的中文式...


小弟最近在学校无聊的很哪,浏览网页突然看到一张图片,都快流鼻血。。。然后小弟冥思苦想,得干一点有趣的事情python 爬虫库安装https://s.taobao.com/api?_ks...

疫情后北上广深租房价格跌了吗? | Alfred数据室


面试官给我挖坑:a[i][j] 和 a[j][i] 有什么区别?

点击上方“朱小厮的博客”,选择“设为星标”后台回复&#34;1024&#34;领取公众号专属资料本文以一个简单的程序开头——数组赋值:int LEN = 10000; int[][] ...


就在昨天互联网又发生一起让人心酸的程序员犯罪事件,著名的百度不限速下载软件 Pandownload PC 版作者被警方抓获。案件大致是这样的:软件的作者不仅非法盗取用户数据,还在QQ群进...





Intellij IDEA 美化指南

经常有人问我,你的 IDEA 配色哪里搞的,我会告诉他我自己改的。作为生产力工具,不但要顺手而且更要顺眼。这样才能快乐编码,甚至降低 BUG 率。上次分享了一些 IDEA 有用的插件,反...



太厉害了,终于有人能把TCP/IP 协议讲的明明白白了

一图看完本文 一、 计算机网络体系结构分层 计算机网络体系结构分层 计算机网络体系结构分层 不难看出,TCP/IP 与 OSI 在分层模块上稍有区别。OSI 参考模型注重“通信协议必要的功能是什么”,而 TCP/IP 则更强调“在计算机上实现协议应该开发哪种程序”。 二、 TCP/IP 基础 1. TCP/IP 的具体含义 从字面意义上讲,有人可能会认为...

腾讯面试题: 百度搜索为什么那么快?

我还记得去年面腾讯时,面试官最后一个问题是:百度/google的搜索为什么那么快? 这个问题我懵了,我从来没想过,搜素引擎的原理是什么 然后我回答:百度爬取了各个网站的信息,然后进行排序,当输入关键词的时候进行文档比对……巴拉巴拉 面试官:这不是我想要的答案 我内心 这个问题我一直耿耿于怀,终于今天,我把他写出来,以后再问,我直接把这篇文章甩给他!!! 两个字:倒排,将贯穿整篇文章,也是面试官...

相关热词 c# 按行txt c#怎么扫条形码 c#打包html c# 实现刷新数据 c# 两个自定义控件重叠 c#浮点类型计算 c#.net 中文乱码 c# 时间排序 c# 必备书籍 c#异步网络通信