Giter Site home page Giter Site logo

protonemedia / laravel-ffmpeg Goto Github PK

View Code? Open in Web Editor NEW
1.6K 46.0 193.0 10.3 MB

This package provides an integration with FFmpeg for Laravel. Laravel's Filesystem handles the storage of the files.

Home Page: https://protone.media/en/blog/how-to-use-ffmpeg-in-your-laravel-projects

License: MIT License

PHP 100.00%
ffmpeg laravel-ffmpeg php-ffmpeg laravel php video hls hls-live-streaming hls-stream

laravel-ffmpeg's People

Contributors

aronquiray avatar carusogabriel avatar chistel avatar chivincent avatar christoxz avatar dylan-dpc avatar ibrainventures avatar injektion avatar joecampo avatar laravel-shift avatar lazar2038 avatar manavo avatar marbocub avatar pascalbaljet avatar rcerljenko avatar song374561 avatar

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

laravel-ffmpeg's Issues

Unable to save concatenated video

I've tried to merge videos and followed this part https://github.com/PHP-FFMpeg/PHP-FFMpeg#concatenation and this is my code:

(1)

$ffmpeg = FFMpeg::fromDisk('public');
$video = $ffmpeg->open('/downloadable_videos/clip1.mp4' );
$mergeFile = $video->concat(array('downloadable_videos/clip1.mp4', '/downloadable_videos/clip2.mp4'))
		    			->saveFromSameCodecs('/downloadable_videos/output.mp4', TRUE);

Finnally, I've got this error.
image

(2)
Anyway, I try to make my own way:
Create concat.txt and put contents:
file 'clip1.mp4'
file 'clip2.mp4'

and run this command:
$ ffmpeg.exe -f concat -i concat.txt -c copy -an output.mp4
it's working fine, but you know how can i implement this into code?

Do you have any examples(1) or show me some tips on how to implement(2)?

FFProbe

Hi guys,

Sorry I'm writing this question to Issues section, but do you have any plans to support FFProbe?

How do you fetch information of a media?

Thank you.

Filter crf without bitrate

Hello

I have a little problem. I can add the '-crf' filter without any problem, but it doesn't have any effect on the quality and size of the videos. I think I must also remove the '-b:v' '100k' bitrate filter which is automaticly added when I save the file in the x264 format. I think when I can remove the bitrate filter the crf filter will work as expected.

At the moment is the output is following and I want to remove the '-b:v' '100k' completly. How is this possible`?

'/usr/bin/ffmpeg' '-y' '-i' 'bla.mp4' '-preset' 'slow' '-crf' '28' '-threads' '12' '-vcodec' 'libx264' '-acodec' 'libfaac' '-b:v' '100k' '-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=1440:-1[out]' '-pass' '1' '-passlogfile' '/tmp/ffmpeg-passes59a47fa95d453sukeb/pass-59a47fa95da34' '/tmp/laravel-ffmpegVA4Ye7.mp

https://trac.ffmpeg.org/wiki/Encode/H.264

$ffmpeg = FFMpeg::open($save_path.$filename) ->addFilter(['-vf', 'scale=1440:-1', '-preset', 'slow', '-crf', 28]) ->export() ->toDisk('supercdn') ->inFormat((new \FFMpeg\Format\Video\X264)->setKiloBitrate(100)) ->save("/test/.$filename);

Thanks a lot for your help!

Progress Tracking

As far as I saw it's not possible to track the progress of the file to convert, is this feature planned to be implemented or do I have to find another solution?

Duration time of clipped video

Hi! I see that I can clip video here:
$start = \FFMpeg\Coordinate\TimeCode::fromSeconds(5)
$clipFilter = new \FFMpeg\Filters\Video\ClipFilter($start);

So, I can start video from 5second, but where to change duration time?
For example I have 15 min video and how to make 15 sec from it starting from one minute?

RTSP Streaming record

Is this package support for recording RTSP stream?
E.g. I have url for access my livestream IP Camera, rtsp://admin:[email protected]:554/live1.sdp
How do I record using that URL?

Example app?

is there any chance of studying an example app made with this project to better understand the details of an implementation? Thanks for your attention!

Watermarks - Error initializing filter 'movie'

My code:
`

     $video_file = FFMpeg::fromDisk('public')
    ->open('files/original/'.Auth::user()->id.'/'.$file_name.'.'.$file_extension);

    /* Add watermarks to the video */
    $watermarkFilter = new \FFMpeg\Filters\Video\WatermarkFilter(public_path('assets\img\watermark.png'));

    $video_file->addFilter($watermarkFilter)
    ->export()
    ->toDisk('public')
    ->inFormat(new \FFMpeg\Format\Video\X264('libmp3lame'))
    ->save('files/copy/'.Auth::user()->id.'/'.$file_name.'.'.$file_extension);

`
It gives error "Encoding Failed - ffmpeg failed to execute command"

The same command on the command line results in an error

"[Parsed_movie_0 @ 04e5bea0] Failed to avformat_open_input 'D'
[AVFilterGraph @ 04e75c60] Error initializing filter 'movie' with args 'D:wampwwwsell-a-videopublicassetsimgwatermark.png'
Error reinitializing filters!
Failed to inject frame into filter network: No such file or directory
Error while processing the decoded data for stream #0:0
[libmp3lame @ 04e5d6a0] 3 frames left in the queue on closing
Conversion failed!"

However when i try a simple command on the command line it works:
`
ffmpeg -i birds.mp4 -i watermark.png -filter_complex "overlay=10:10" birds1.mp4

`
Please help.

Temporary Video Files

Hi Pascal,

I'm currently running this plugin on a small server with very little storage space and keep running into the issue of filling up storage. I've written a cron job to remove these files every few minutes, but it would be great if the plugin removed these files after they are used.

Since this use case is rather specific, maybe there could be a flag to tell the plugin whether to do this or not? Just a suggestion, but it would be a major help.

HLS and MediaExporter merge to official PHP-FFMpeg?

Would it be beneficial to merge the HLS and MediaExporter feature to the official PHP-FFMpeg?

HLS is pretty much a standard for streaming online video.

I ended up having to fork the original project to add HLS support and many others use setAdditionalParameters feature to achieve the same goal.

After going through your repo, I realized @pascalbaljet is much further along than me in implementing the full FFmpeg HLS feature set.

@jens1o

Error: Failed to execute command - Encoding Failed

I keep getting this error, even when i try to do some simple video conversion. FFMpeg is working fine, i tested some commands through the command line and it worked fine but i get this error when using this package. Video thumbnails works fine but other video manipulation results in this error.

My code is:
`

        $video_file = FFMpeg::fromDisk('public')
        ->open('files/original/'.Auth::user()->id.'/'.$file_name.'.'.$file_extension);

        $start = \FFMpeg\Coordinate\TimeCode::fromSeconds(2);
        $clipFilter = new \FFMpeg\Filters\Video\ClipFilter($start);


        $video_file->addFilter(function ($filters) {
            $filters->resize(new \FFMpeg\Coordinate\Dimension(640, 480));
        })
        ->export()
        ->toDisk('public')
        ->inFormat(new \FFMpeg\Format\Video\X264())
        ->save('short_steve.mp4');

`

This is the error i recieve:

ExecutionFailureException in ProcessRunner.php line 100:
ffmpeg failed to execute command "D:/wamp/bin/ffmpeg/bin/ffmpeg.exe" "-y" "-i" "D:\wamp\www\sell-a-video\storage\app/public\files/original/3/3-9lg7hK.mp4" "-ss" "00:00:02.00" "-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" "1" "-passlogfile" "C:\Windows\TEMP\ffmpeg-passes59082e90450edzn2gy/pass-59082e90454d5" "D:\wamp\www\sell-a-video\storage\app/public\short_steve.mp4"

Add multiple filters

Hi I want to add multiple filters and you please give me the example how can I add multiple filters
I tried many way
#number1
->addFileter('-preset', 'ultrafast')
->addFilter('-crf', 22)
#number2
->addFileter('-preset', 'ultrafast', '-crf', 22)
#number3
->addFileter(['-preset', 'ultrafast'], ['-crf', 22])
It still not working
please give me the example thanks

Can not get duration of video .mkv

Dear all.

I can not get duration of video file type = .mkv('mkv' => 'video/x-matroska',)

File Media.php, function getDurationInSeconds() Line 34.

We don't have key 'duration' so i can not get duration time of video. How can i get duration time of video file type = .mkv.
I don't have proplem with other file type (avi, mp4, mpeg, mov...)

Function:
public function getDurationInSeconds(): int
{
return $this->media->getStreams()->first()->get('duration');
}

Result of dd($this->media->getStreams()->first())
Stream {#455
-properties: array:34 [
"index" => 0
"codec_name" => "h264"
"codec_long_name" => "H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10"
"profile" => "High"
"codec_type" => "video"
"codec_time_base" => "317/19001"
"codec_tag_string" => "[0][0][0][0]"
"codec_tag" => "0x0000"
"width" => 1920
"height" => 1080
"coded_width" => 1920
"coded_height" => 1080
"has_b_frames" => 1
"sample_aspect_ratio" => "1:1"
"display_aspect_ratio" => "16:9"
"pix_fmt" => "yuv420p"
"level" => 40
"color_range" => "tv"
"color_space" => "bt709"
"color_transfer" => "bt709"
"color_primaries" => "bt709"
"chroma_location" => "left"
"field_order" => "progressive"
"refs" => 1
"is_avc" => "true"
"nal_length_size" => "4"
"r_frame_rate" => "19001/634"
"avg_frame_rate" => "19001/634"
"time_base" => "1/1000"
"start_pts" => 0
"start_time" => "0.000000"
"bits_per_raw_sample" => "8"
"disposition" => array:12 [
"default" => 1
"dub" => 0
"original" => 0
"comment" => 0
"lyrics" => 0
"karaoke" => 0
"forced" => 0
"hearing_impaired" => 0
"visual_impaired" => 0
"clean_effects" => 0
"attached_pic" => 0
"timed_thumbnails" => 0
]
"tags" => array:1 [
"language" => "eng"
]
]
}

Thanks & best regards.

Support for x265 codec?

So far this has been easy to install and use, although I am curious - am I able to use the x265 codec?

(1/1) FatalThrowableError Call to undefined method FFMpeg\FFMpeg::fromDisk()

here is my code, i'm using laravel to build the application

use FFMpeg\FFMpeg;
use FFMpeg\FFProbe;

FFMpeg::fromDisk('vidpuz')
        ->open($export_as)
        ->getFrameFromSeconds(10)
        ->export()
        ->toDisk('thumnails')
        ->save($thumbnail_path);

i don't know how it means, and i tried the fromFilesystem before, also return an undefined error, and i tried different value in fromDisk like fromDisk(public_path()) or fromDisk('vidpuz') also not working

Give the duration of the file.

Hi! I am trying to cut a file. I am using this code:

$start = \FFMpeg\Coordinate\TimeCode::fromSeconds(5)
$clipFilter = new \FFMpeg\Filters\Video\ClipFilter($start);

FFMpeg::fromDisk('videos')
    ->open('steve_howe.mp4')
    ->addFilter($clipFilter)
    ->export()
    ->toDisk('converted_videos')
    ->inFormat(new \FFMpeg\Format\Video\X264)
    ->save('short_steve.mkv');

How can I set duration of the video? Now if I have 10 sec lenght video i give start 5 sec and then I get 5 sec video. What if I want to have video from 2 do 8 sec lenght from 10 second video? How to do it?

Merge two audio files

Hey, first of all thanks for a great package.

I'm trying to merge two audio files together using the amix filter. I've got the command line working so I'm simply trying to get it working using your package.

This is what I'm trying:

FFMpeg::fromDisk('s3')
        ->open($this->path) // equals main.wav
        ->open('/songs/tag.wav')
        ->addFilter('-filter_complex amix=inputs=2:duration=first:dropout_transition=3');
        ->export()
        ->inFormat(new \FFMpeg\Format\Audio\Mp3)
        ->save('/songs/main/' . $this->id . '.mp3', 'public');
    }

And this is the working command line

ffmpeg -i main.wav -i tag.wav -filter_complex amix=inputs=2:duration=first:dropout_transition=3 main.mp3

If you can help me with this, or provide any references to similar code it would be greatly appreciate.

Thanks again!

FrameFilterInterface expected instead of SegmentedFilter

Hello,

I am already on Laravel 5.4. Maybe it is an incompatibility issue with the newest version. Have a look at the stack trace.

With best regards,

Oliver

Symfony\Component\Debug\Exception\FatalThrowableError: Type error: Argument 1 passed to FFMpeg\Media\Frame::addFilter() must be an instance of FFMpeg\Filters\Frame\FrameFilterInterface, instance of Pbmedia\LaravelFFMpeg\SegmentedFilter given in /Users/oj/code/kinklink/vendor/php-ffmpeg/php-ffmpeg/src/FFMpeg/Media/Frame.php:61
Stack trace:
#0 [internal function]: FFMpeg\Media\Frame->addFilter(Object(Pbmedia\LaravelFFMpeg\SegmentedFilter))
#1 /Users/oj/code/kinklink/vendor/pbmedia/laravel-ffmpeg/src/Media.php(77): call_user_func_array(Array, Array)
#2 /Users/oj/code/kinklink/vendor/pbmedia/laravel-ffmpeg/src/SegmentedExporter.php(46): Pbmedia\LaravelFFMpeg\Media->addFilter(Object(Pbmedia\LaravelFFMpeg\SegmentedFilter))
#3 /Users/oj/code/kinklink/vendor/pbmedia/laravel-ffmpeg/src/HLSPlaylistExporter.php(74): Pbmedia\LaravelFFMpeg\SegmentedExporter->saveStream('/Users/oj/code/...')
#4 /Users/oj/code/kinklink/vendor/pbmedia/laravel-ffmpeg/src/HLSPlaylistExporter.php(95): Pbmedia\LaravelFFMpeg\HLSPlaylistExporter->exportStreams()
#5 /Users/oj/code/kinklink/vendor/pbmedia/laravel-ffmpeg/src/MediaExporter.php(60): Pbmedia\LaravelFFMpeg\HLSPlaylistExporter->savePlaylist('/Users/oj/code/...')
#6 /Users/oj/code/kinklink/app/Jobs/ProcessContentVideo.php(118): Pbmedia\LaravelFFMpeg\MediaExporter->save('/Users/oj/code/...')
#7 [internal function]: App\Jobs\ProcessContentVideo->handle()

Question: Resize output image

Hi,

Please I want to create thumbnail of video, and I want all thumbs are the same size, here is my code but it does not work :

FFMpeg::fromDisk('local')
            ->open('1.mp4')
            ->addFilter(function ($filters) {
                $filters->resize(new \FFMpeg\Coordinate\Dimension(100, 100));
            })
            ->getFrameFromSeconds(10)
            ->export()
            ->toDisk('local')
            ->save('1.png')
            

Realtime HLS Encoding Progress Percentage

I use VueJs to Upload a video and sent it to a Job,
My Job code looks like:

    public function handle()
    {
        $file = public_path().'/storage/user_uploads/media/cache/'. $this->filename;

        $lowBitrate = (new X264())->setKiloBitrate(50)->setAudioCodec('aac');
        $midBitrate = (new X264)->setKiloBitrate(150)->setAudioCodec('aac');
        $highBitrate = (new X264)->setKiloBitrate(300)->setAudioCodec('aac');

        FFMpeg::fromDisk('videos-cache')
            ->open($this->filename)
            ->exportForHLS()
            ->onProgress(function ($percentage) {
                event(new EncodingProgressUpdated($percentage)); // method 1
                $this->media->processed_percentage = $percentage; // method 2
                $this->media->save();
            })
            ->setSegmentLength(1)
            ->addFormat($lowBitrate, function($media) {
                    $media->addFilter(function ($filters) {
                        $filters->resize(new \FFMpeg\Coordinate\Dimension(416, 234));
                    });
                })
            ->toDisk('medias')
            ->save($this->uid.'/'.$this->uid.'.m3u8');

        $this->media->media_filename = $this->uid.'.m3u8';
        $this->media->save();
    }

onProgress function doesnt sent event and with method 2, $percentage is not sent to my database. I cant retrive also $percentage outside the function. This code inside the function: global $percentage doesnt pass $percentage value outside.

How can I retrieve $percentage, send it to an event or to my database ?

MP4 to WebM - Encoding Failed

Hello,

I've been attempting to convert MP4 videos to WebM, but am having issues. When I try this with native FFMpeg it works fine, but fails when using this Laravel plugin.
Here is a snippet of my code:

    $webm_format = new FFMpeg\Format\Video\WebM();
    $video->save($webm_format, '/var/www/html/laravel/storage/'.$webm_target_name);

And here is my stack trace:

#0 [internal function]: FFMpeg\Media\Video->save(Object(FFMpeg\Format\Video\WebM), '/var/www/html/l...')
#1 /var/www/html/laravel/vendor/pbmedia/laravel-ffmpeg/src/Media.php(107): call_user_func_array(Array, Array)
#2 /var/www/html/laravel/app/Jobs/TranscodeProcess.php(80): Pbmedia\LaravelFFMpeg\Media->__call('save', Array)
#3 [internal function]: App\Jobs\TranscodeProcess->handle()
#4 /var/www/html/laravel/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(29): call_user_func_array(Array, Array)
#5 /var/www/html/laravel/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(87): Illuminate\Container\BoundMethod::Illuminate\Container\{closure}()
#6 /var/www/html/laravel/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(31): Illuminate\Container\BoundMethod::callBoundMethod(Object(Illuminate\Foundation\Application), Array, Object(Closure))
#7 /var/www/html/laravel/vendor/laravel/framework/src/Illuminate/Container/Container.php(524): Illuminate\Container\BoundMethod::call(Object(Illuminate\Foundation\Application), Array, Array, NULL)
#8 /var/www/html/laravel/vendor/laravel/framework/src/Illuminate/Bus/Dispatcher.php(94): Illuminate\Container\Container->call(Array)
#9 /var/www/html/laravel/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(114): Illuminate\Bus\Dispatcher->Illuminate\Bus\{closure}(Object(App\Jobs\TranscodeProcess))
#10 /var/www/html/laravel/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(102): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(App\Jobs\TranscodeProcess))
#11 /var/www/html/laravel/vendor/laravel/framework/src/Illuminate/Bus/Dispatcher.php(98): Illuminate\Pipeline\Pipeline->then(Object(Closure))
#12 /var/www/html/laravel/vendor/laravel/framework/src/Illuminate/Queue/CallQueuedHandler.php(42): Illuminate\Bus\Dispatcher->dispatchNow(Object(App\Jobs\TranscodeProcess), false)
#13 /var/www/html/laravel/vendor/laravel/framework/src/Illuminate/Queue/Jobs/Job.php(69): Illuminate\Queue\CallQueuedHandler->call(Object(Illuminate\Queue\Jobs\DatabaseJob), Array)
#14 /var/www/html/laravel/vendor/laravel/framework/src/Illuminate/Queue/Worker.php(291): Illuminate\Queue\Jobs\Job->fire()
#15 /var/www/html/laravel/vendor/laravel/framework/src/Illuminate/Queue/Worker.php(258): Illuminate\Queue\Worker->process('database', Object(Illuminate\Queue\Jobs\DatabaseJob), Object(Illuminate\Queue\WorkerOptions))
#16 /var/www/html/laravel/vendor/laravel/framework/src/Illuminate/Queue/Worker.php(110): Illuminate\Queue\Worker->runJob(Object(Illuminate\Queue\Jobs\DatabaseJob), 'database', Object(Illuminate\Queue\WorkerOptions))
#17 /var/www/html/laravel/vendor/laravel/framework/src/Illuminate/Queue/Console/WorkCommand.php(100): Illuminate\Queue\Worker->daemon('database', 'default', Object(Illuminate\Queue\WorkerOptions))
#18 /var/www/html/laravel/vendor/laravel/framework/src/Illuminate/Queue/Console/WorkCommand.php(83): Illuminate\Queue\Console\WorkCommand->runWorker('database', 'default')
#19 [internal function]: Illuminate\Queue\Console\WorkCommand->fire()
#20 /var/www/html/laravel/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(29): call_user_func_array(Array, Array)
#21 /var/www/html/laravel/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(87): Illuminate\Container\BoundMethod::Illuminate\Container\{closure}()
#22 /var/www/html/laravel/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(31): Illuminate\Container\BoundMethod::callBoundMethod(Object(Illuminate\Foundation\Application), Array, Object(Closure))
#23 /var/www/html/laravel/vendor/laravel/framework/src/Illuminate/Container/Container.php(524): Illuminate\Container\BoundMethod::call(Object(Illuminate\Foundation\Application), Array, Array, NULL)
#24 /var/www/html/laravel/vendor/laravel/framework/src/Illuminate/Console/Command.php(182): Illuminate\Container\Container->call(Array)
#25 /var/www/html/laravel/vendor/symfony/console/Command/Command.php(265): Illuminate\Console\Command->execute(Object(Symfony\Component\Console\Input\ArgvInput), Object(Illuminate\Console\OutputStyle))
#26 /var/www/html/laravel/vendor/laravel/framework/src/Illuminate/Console/Command.php(167): Symfony\Component\Console\Command\Command->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Illuminate\Console\OutputStyle))
#27 /var/www/html/laravel/vendor/symfony/console/Application.php(826): Illuminate\Console\Command->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#28 /var/www/html/laravel/vendor/symfony/console/Application.php(189): Symfony\Component\Console\Application->doRunCommand(Object(Illuminate\Queue\Console\WorkCommand), Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#29 /var/www/html/laravel/vendor/symfony/console/Application.php(120): Symfony\Component\Console\Application->doRun(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#30 /var/www/html/laravel/vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php(123): Symfony\Component\Console\Application->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#31 /var/www/html/laravel/artisan(35): Illuminate\Foundation\Console\Kernel->handle(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#32 {main}1

Right before this I am doing an X264 encoding with audio codec of "libfdk_aac", and it works fine.

I have also noticed this does not happen with all videos. (Works with videos originating from iPhones, but not Androids)

Let me know if there's more information I can provide.

Help is greatly appreciated.

Fatal Error!

Hi there,
First of all great library!
I use use Pbmedia\LaravelFFMpeg\FFMpeg; in my controller and use:

$lowBitrate = (new X264)->setKiloBitrate(250);
$midBitrate = (new X264)->setKiloBitrate(500);
$highBitrate = (new X264)->setKiloBitrate(1000);
FFMpeg::fromDisk('videos')
->open('steve_howe.mp4') ->exportForHLS() ->setSegmentLength(10) // optional ->addFormat($lowBitrate) ->addFormat($midBitrate) ->addFormat($highBitrate) ->save('adaptive_steve.m3u8');

in my method and then I got an error:
ErrorException in mainController.php line 118: Non-static method Pbmedia\LaravelFFMpeg\FFMpeg::fromDisk() should not be called statically

In other hands, when I use use FFMpeg\FFMpeg; it says:
FatalThrowableError in mainController.php line 118: Call to undefined method FFMpeg\FFMpeg::fromDisk()

where'd I go wrong?

Unable to Probe video

Each time I try to encode, I get a Runtime error message unable to probe <video path>. This for instance gives that error:

$lowBitrateFormat  = (new X264('libmp3lame', 'libx264'))->setKiloBitrate(500);
$midBitrateFormat  = (new X264('libmp3lame', 'libx264'))->setKiloBitrate(1500);
$highBitrateFormat = (new X264('libmp3lame', 'libx264'))->setKiloBitrate(3000);
        
FFMpeg::fromDisk('server')
    ->open('videos/'.$this->filename)
    ->exportForHLS()
    ->toDisk('streamable_videos')
    ->addFormat($lowBitrateFormat)
    ->addFormat($midBitrateFormat)
    ->addFormat($highBitrateFormat)
    ->save('test.m3u8');

Any idea why? I even changed the folder permissions to 777 just in case, but still have the same problem. I'm using version ^1.3.

Can't convert to any format but only webm works

hi, i have implemented larval-ffmpeg in my larval 5.1 project, I have this problem, when I change the config:
$lowBitrateFormat = (new FFMpeg\Format\Video\WebM())->setKiloBitrate(500);

to:
$lowBitrateFormat = (new FFMpeg\Format\Video\X264())->setKiloBitrate(500);

then it won't convert anything and throws this 2 errors in the log file:

ffmpeg failed to execute command '/usr/local/bin/ffmpeg' '-y' '-i' '/Applications/AMPPS/www/project/storage/converted_videos/video3.mp4' '-threads' '2' '-vcodec' 'libx264' '-acodec' 'libfaac' '-b:v' '500k' '-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=960:540 [out]' '-pass' '1' '-passlogfile' '/var/folders/78/z6v380yd7x187xwrqx88fng80000gn/T/ffmpeg-passes59ee68f1f35cf9g3c7/pass-59ee68f1f3702' '/private/var/folders/78/z6v380yd7x187xwrqx88fng80000gn/T/laravel-ffmpeg3frg3f.mp4' --

Alchemy\BinaryDriver\Exception\ExecutionFailureException: ffmpeg failed to execute command '/usr/local/bin/ffmpeg' '-y' '-i' '/Applications/AMPPS/www/project/storage/converted_videos/video3.mp4' '-threads' '2' '-vcodec' 'libx264' '-acodec' 'libfaac' '-b:v' '500k' '-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=960:540 [out]' '-pass' '1' '-passlogfile' '/var/folders/78/z6v380yd7x187xwrqx88fng80000gn/T/ffmpeg-passes59ee68f1f35cf9g3c7/pass-59ee68f1f3702' '/private/var/folders/78/z6v380yd7x187xwrqx88fng80000gn/T/laravel-ffmpeg3frg3f.mp4' in /Applications/AMPPS/www/project/vendor/alchemy/binary-driver/src/Alchemy/BinaryDriver/ProcessRunner.php:100 | Stack -- | --
 
Can you please help me?

Unable to Probe Video from AWS S3

Hey all,

I've been trying to set up Laravel FFMpeg to work directly with S3 videos, but having trouble having FFMpeg open the file on S3.

Here is a snippet from my code:

public function transcodeVideo(Request $request)
    {
        $name = "test1.webm";
        $s3 = Storage::disk('s3');
        $file_path = $this->video_path . '/' . $name;
        $exists = $s3->exists($name);

        if ($exists) {
            $video = FFMpeg::fromDisk('s3')->open($name);

            dd("opened");
        }

        dd($exists);
    }

I've placed the same video on both the local machine and the S3 bucket.

However, when I run this code and use FFMpeg::fromDisk('s3') instead of FFMpeg::fromDisk('local'), FFMpeg will not find the file. The S3 configuration is set up correctly for use by Storage/filesystem for Laravel since it does find the file in the $exists call.

I have not done anything special to set up FFMpeg to run alongside S3. Did I potentially miss a process?

Also, here is the error it throws:

ExecutionFailureException in ProcessRunner.php line 100:
ffprobe failed to execute command '/usr/bin/ffprobe' 'test1.webm' '-show_streams' '-print_format' 'json'

RuntimeException in FFProbe.php line 244:
Unable to probe test1.webm

From the command here it looks as if there is nothing being done to handle that the file is on S3 and not the local machine, but I have no clue.

Here is my Filesystems disk setup:

's3' => [
            'driver' => 's3',
            'key' => env('AWS_KEY'),
            'secret' => env('AWS_SECRET'),
            'region' => env('AWS_REGION'),
            'bucket' => env('AWS_BUCKET'),
        ]

Any help would be greatly appreciated.

How to convert audio to video ?

I often run this command line to convert audio to video for uploading to YouTube.

ffmpeg -v quiet -loop 1 -r 1 -i "cover.jpg" -i "audio.mp3" -c:a copy -shortest "video.avi"

How to do that with your library ?
Many thanks.

Can't make public the exported video to S3

Hi! I'm using your library and it works fine! But now I'm trying to use it with S3.
When I upload a file to S3 I do:
\Storage::putFile('videos', $request->file('file'), 'public')

I mean, I have to declare it as public to allow my users to see the video.

If I use your library, I don't know how to declare it as public.

What I do is:

FFMpeg::fromDisk('s3')
            ->open($filename)
            ->addFilter($watermarkFilter)
            ->export()
            ->toDisk('s3')
            ->inFormat(new X264('libmp3lame'))
            ->save($savedFilename);

Can you help me, please?

Laravel not clipping my video

Hi! I am trying to clip video. Log says that everything is successful, i got blank screen but my video had 9 seconds and it had again 9 seconds.
here's code:

FFMpeg::fromDisk('public')
    ->open('/uploads/videos/' .$video->file_name)
    ->filters()
    ->clip(FFMpeg\Coordinate\TimeCode::fromSeconds(2), FFMpeg\Coordinate\TimeCode::fromSeconds(2))
    ->synchronize();

What should I do?

A non-numeric value encountered - AbstractProgressListener

When encoding uploaded videos i always run into an error exception:

#Code used

`
$lowBitrate = (new X264('libmp3lame'))->setKiloBitrate(250);
$midBitrate = (new X264('libmp3lame'))->setKiloBitrate(500);
$highBitrate = (new X264('libmp3lame'))->setKiloBitrate(1000);

FFMpeg::fromDisk('public')->open($video)->exportForHLS()
    ->setSegmentLength(10)
    ->addFormat($lowBitrate)
    ->addFormat($midBitrate)
    ->addFormat($highBitrate)
    ->save($filename . '.m3u8');

`

#Stack Crawl

[2017-02-02 12:47:39] local.INFO: ffmpeg running command '/usr/local/bin/ffmpeg' '-y' '-i' '/Users/oj/code/kinklink/storage/app/public/users/1/upload/p3Anee5RoWmd-1.mp4' '-map' '0' '-flags' '-global_header' '-f' 'segment' '-segment_format' 'mpeg_ts' '-segment_list' '/Users/oj/code/kinklink/storage/app/public/users/1/content/p3Anee5RoWmd-1_250.m3u8' '-segment_time' '10' '-threads' '12' '-vcodec' 'libx264' '-acodec' 'libmp3lame' '-b:v' '250k' '-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' '/var/folders/g_/b9xjq9yx6859bxwchm6tqp0c0000gr/T/ffmpeg-passes58932a6b4a6acfitu5/pass-58932a6b4a77e' '/content/p3Anee5RoWmd-1_250_%05d.ts' [2017-02-02 12:47:40] local.ERROR: ErrorException: A non-numeric value encountered in /Users/oj/code/kinklink/vendor/php-ffmpeg/php-ffmpeg/src/FFMpeg/Format/ProgressListener/AbstractProgressListener.php:182 Stack trace: #0 /Users/oj/code/kinklink/vendor/php-ffmpeg/php-ffmpeg/src/FFMpeg/Format/ProgressListener/AbstractProgressListener.php(182): Illuminate\Foundation\Bootstrap\HandleExceptions->handleError(2, 'A non-numeric v...', '/Users/oj/code/...', 182, Array) #1 /Users/oj/code/kinklink/vendor/php-ffmpeg/php-ffmpeg/src/FFMpeg/Format/ProgressListener/AbstractProgressListener.php(136): FFMpeg\Format\ProgressListener\AbstractProgressListener->parseProgress('frame= 659 fps...') #2 /Users/oj/code/kinklink/vendor/alchemy/binary-driver/src/Alchemy/BinaryDriver/ProcessRunner.php(90): FFMpeg\Format\ProgressListener\AbstractProgressListener->handle('err', 'frame= 659 fps...') #3 [internal function]: Alchemy\BinaryDriver\ProcessRunner->Alchemy\BinaryDriver\{closure}('err', 'frame= 659 fps...') #4 /Users/oj/code/kinklink/vendor/symfony/process/Process.php(1345): call_user_func(Object(Closure), 'err', 'frame= 659 fps...') #5 /Users/oj/code/kinklink/vendor/symfony/process/Process.php(1450): Symfony\Component\Process\Process->Symfony\Component\Process\{closure}('err', 'frame= 659 fps...')

Thanks a lot for looking into the problem...

Compatibility issue with php-ffmpeg ^0.8 while installing

I started with a fresh Laravel install, added the required packages through composer and then tried to composer require pbmedia/laravel-ffmpeg.

The error message I get is

Using version ^1.1 for pbmedia/laravel-ffmpeg
./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)
Your requirements could not be resolved to an installable set of packages.

  Problem 1
    - pbmedia/laravel-ffmpeg 1.1.3 requires php-ffmpeg/php-ffmpeg ^0.6 -> satisfiable by php-ffmpeg/php-ffmpeg[0.6.0, 0.6.1] but these conflict with your requirements or minimum-stability.
    - pbmedia/laravel-ffmpeg 1.1.2 requires php-ffmpeg/php-ffmpeg ^0.6 -> satisfiable by php-ffmpeg/php-ffmpeg[0.6.0, 0.6.1] but these conflict with your requirements or minimum-stability.
    - pbmedia/laravel-ffmpeg 1.1.1 requires php-ffmpeg/php-ffmpeg ^0.6 -> satisfiable by php-ffmpeg/php-ffmpeg[0.6.0, 0.6.1] but these conflict with your requirements or minimum-stability.
    - pbmedia/laravel-ffmpeg 1.1.0 requires php-ffmpeg/php-ffmpeg ^0.6 -> satisfiable by php-ffmpeg/php-ffmpeg[0.6.0, 0.6.1] but these conflict with your requirements or minimum-stability.
    - Installation request for pbmedia/laravel-ffmpeg ^1.1 -> satisfiable by pbmedia/laravel-ffmpeg[1.1.0, 1.1.1, 1.1.2, 1.1.3].

As you can see in my composer.json file, everything seems to be included right.

"require": {
        "php": ">=5.6.4",
        "intervention/image": "^2.3",
        "laracasts/flash": "^2.0",
        "laravel/framework": "5.4.*",
        "laravel/socialite": "^3.0",
        "laravel/tinker": "~1.0",
        "laravelcollective/html": "5.*",
        "league/flysystem": "^1.0",
        "php-ffmpeg/php-ffmpeg": "^0.8.0",
        "phpoffice/phpexcel": "1.8.1",
        "rtconner/laravel-likeable": "~1.2",
        "rtconner/laravel-tagging": "~2.2",
        "yajra/laravel-datatables-oracle": "~6.0"
    },

Any help would be highly appreciated!

Transcoding Progressbar Implementation?

Thank you very much for this very nice package, it is really a great example of Laravel usage!

Q: What would be your recommendation for implementing a progressbar for the transcoding? Do exist any similar Laravel packages / examples that show how to do this in a "Laravel way"?

Thanks for your attention!

Customfilter single quote

I try to set some Text using a custom filter:

$customFilter = new CustomFilter("drawtext=\"fontfile=/usr/local/fonts/whitrabt.ttf: text='My Text': fontcolor=black: fontsize=24: box=1: [email protected]: boxborderw=5: x=(w-text_w)/2: y=(h-text_h)/2\"");

The problematic part is: text='My Text'

This always converts in the ffmpeg command to text=\'\"My Text\"\'

Well that is not working of course, I tried with all kinds of tricks to get around this problem, like

text=\'My Text\'
text=\\'My Text\\'
text=\\\'My Text\\\'
a.s.o. wrapped the whole thing different a.s.o.

Well the result is always different but somehow always a additional \" appear where they shouldn’t.

I bet that you are doing something too clever in your code to clean the filter line before inserting it to the command line, that causes the problem.

In the end it should result in:

text=\'My Text\'

inside the ffmpg command line, because the whole $filter is wrapped in ' already. Do you have a hint for me, or do you think you can fix that?

process remote url's ?

I want to confirm that, is there any way around that I can give a remote url to the ffmpeg object and it will then download the file in the specified format. Something like that:

FFMpeg::fromDisk('remoteURL')
    ->open('www.someyrl.com/sdfsd/sdsd/sd/ds/yesterday.mp3')
    ->export()
    ->toDisk('converted_songs')
    ->inFormat(new \FFMpeg\Format\Audio\Flac)
    ->save('yesterday.flac');

If so then what will be the syntax for that I mean fromDisk or fromFileStorage and what argument to provide this.
One last question, is .flac format supported?

Path is wrong

I by pass method fromDisk then it gave me the default path
but I used direct path from php file upload where /tmp/phpSLe9Ds something like that
but the object give me the laravel path /storage/app/tmp/phpSq8NxI which is not correct path it should be /tmp/phpSq8NxI

Problems with watermark filter

Hello,

I would like to add a watermark on a video, why should I add ->format() before saving? is it possible to keep the original format of the input video?
When I choose WebM the video get cropped to less than 1s.
How can I change the time of appearing and disappearing of the watermark? Should I create a custom filter?

Thank you.

Non-static method Pbmedia\LaravelFFMpeg\FFMpeg::fromDisk() should not be called statically

Hi there, thank you for creating this package.
I've just installed it on a Laravel 5.4, and this is the error I get:
Non-static method Pbmedia\LaravelFFMpeg\FFMpeg::fromDisk() should not be called statically

this is my code:

use Illuminate\Support\Facades\Storage;

public function upload()
    {
        $file = request()->file('gif');
        $name = time() . '.gif';

        $file->storeAs('gifs', $name);

        FFMpeg::fromDisk('local')
                    ->open('gifs/' . $name)
                    ->export()
                    ->inFormat(new \FFMpeg\Format\Video\X264)
                    ->save('export-x264.mp4');

        return back();
    }

Non Static Method Errors

Non-static method Pbmedia\LaravelFFMpeg\FFMpeg::fromDisk() should not be called statically
FFMpeg::fromDisk('local_root')->open($uploadedFile->getRealPath())
->addFilter(function ($filters) {
$filters->resize(new \FFMpeg\Coordinate\Dimension(640, 480));
})
->export()
->toDisk('s3')
->inFormat(new \FFMpeg\Format\Video\WMV)
->save('users/videos/'.$filename.".wmv")
// export to Amazon S3, converted in X264
->export()
->inFormat(new \FFMpeg\Format\Video\X264)
->save('users/videos/'.$filename.".mp4")
->export()
->inFormat(new \FFMpeg\Format\Video\WebM)
->save('users/videos/'.$filename.".webm")
;

is there any other config??my server give a 500error?

i composer it to my server,and chenge the config path,,but it can not run fine!!

<?php

namespace App\Http\Controllers;


use Pbmedia\LaravelFFMpeg\FFMpeg;

class ConvController extends Controller
{
    //
    public function conv2mp3()
    {
        FFMpeg::fromDisk('videos')
            ->open('beeen.Mp4')
            ->export()
            ->toDisk('converted_videos')
            ->inFormat(new \FFMpeg\Format\Audio\Mp3)
            ->save('beeen.Mp3');

    }
}

Implement HLS with a key

Hi,
Is there any way to implement HLS with a key using this library?
My ffmpeg command is here:

ffmpeg -y -i demo.mp4 -hls_time 9 -hls_key_info_file enc.keyinfo -hls_segment_filename "segmentedfile%d.ts" video.m3u8

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.