Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

no issue but how exactly i can use this lab. #560

Closed
rohitgaidhane opened this issue Aug 7, 2018 · 32 comments
Closed

no issue but how exactly i can use this lab. #560

rohitgaidhane opened this issue Aug 7, 2018 · 32 comments
Labels

Comments

@rohitgaidhane
Copy link

hi

how to use this lab. as i want to reduce video bit rate so the video uploaded by user will to loaded fastly.

@jens1o
Copy link
Member

jens1o commented Aug 7, 2018

https://github.com/PHP-FFMpeg/PHP-FFMpeg#manipulate-media
https://github.com/PHP-FFMpeg/PHP-FFMpeg#transcoding

I would have expected that you, at least, read the current docs.

@jens1o jens1o closed this as completed Aug 7, 2018
@jens1o jens1o added the question label Aug 7, 2018
@rohitgaidhane
Copy link
Author

this error occurs:

( ! ) Fatal error: Uncaught exception 'Alchemy\BinaryDriver\Exception\ExecutableNotFoundException' with message 'Executable not found, proposed : avprobe, ffprobe' in C:\wamp64\www\test\vendor\php-ffmpeg\php-ffmpeg\src\FFMpeg\Driver\FFProbeDriver.php on line 50

1 | 0.0016 | 241096 | {main}( ) | ...\index.php:0
2 | 0.0293 | 395288 | FFMpeg\FFMpeg::create( ) | ...\index.php:4
3 | 0.0306 | 444648 | FFMpeg\FFProbe::create( ) | ...\FFMpeg.php:117
4 | 0.0466 | 656872 | FFMpeg\Driver\FFProbeDriver::create( ) | ...\FFProbe.php:226
5 | 0.0513 | 683640 | Alchemy\BinaryDriver\AbstractBinary::load( ) | ...\FFProbeDriver.php:48

1 | 0.0016 | 241096 | {main}( ) | ...\index.php:0
2 | 0.0293 | 395288 | FFMpeg\FFMpeg::create( ) | ...\index.php:4
3 | 0.0306 | 444648 | FFMpeg\FFProbe::create( ) | ...\FFMpeg.php:117
4 | 0.0466 | 656872 | FFMpeg\Driver\FFProbeDriver::create( ) | ...\FFProbe.php:226

@rohitgaidhane
Copy link
Author

what does it means

@rohitgaidhane
Copy link
Author

i have installed lab using composer

@jens1o
Copy link
Member

jens1o commented Aug 7, 2018

You need to install ffmpeg, too.

@rohitgaidhane
Copy link
Author

ok. but how ?

@rohitgaidhane
Copy link
Author

i have installed ffmpeg using cli.but same issue occurs.

@jens1o
Copy link
Member

jens1o commented Aug 7, 2018

is it in your PATH?

@rohitgaidhane
Copy link
Author

yes

@jens1o
Copy link
Member

jens1o commented Aug 7, 2018

what happens when you execute ffmpeg in the same folder your php-files are in?

@rohitgaidhane
Copy link
Author

i m able to execute ffmpeg any where in my pc using cli but if i want to execute this using php so error ouccers

@jens1o
Copy link
Member

jens1o commented Aug 7, 2018

Can you ensure PHP has proper permission and may open new processes?

@rohitgaidhane
Copy link
Author

which permission can you plz explain?

@rohitgaidhane
Copy link
Author

now after some changes i am now able to take snaps of video but this error happning

Fatal error: Uncaught exception 'Alchemy\BinaryDriver\Exception\ExecutionFailureException' with message 'ffmpeg failed to execute command C:\wamp64\www\imgcomptest\ffmpeg\bin\ffmpeg.EXE -y -i rj.mp4 -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 256k -ac 2 -pass 1 -passlogfile "C:\WINDOWS\TEMP\ffmpeg-passes5b6962c4bdaf07tcpp/pass-5b6962c4be2a8" video.mp4' in C:\wamp64\www\test\vendor\php-ffmpeg\php-ffmpeg\src\FFMpeg\Media\AbstractVideo.php on line 106
( ! ) Alchemy\BinaryDriver\Exception\ExecutionFailureException: ffmpeg failed to execute command C:\wamp64\www\imgcomptest\ffmpeg\bin\ffmpeg.EXE -y -i rj.mp4 -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 256k -ac 2 -pass 1 -passlogfile "C:\WINDOWS\TEMP\ffmpeg-passes5b6962c4bdaf07tcpp/pass-5b6962c4be2a8" video.mp4 in C:\wamp64\www\test\vendor\alchemy\binary-driver\src\Alchemy\BinaryDriver\ProcessRunner.php on line 100
Call Stack

Time Memory Function Location

1 0.0016 240968 {main}( ) ...\index.php:0
2 0.5958 2078888 FFMpeg\Media\AbstractVideo->save( ) ...\index.php:31
3 0.6102 2513728 Alchemy\BinaryDriver\AbstractBinary->command( ) ...\AbstractVideo.php:96
4 0.6113 2516272 Alchemy\BinaryDriver\AbstractBinary->run( ) ...\AbstractBinary.php:137
5 0.6114 2517176 Alchemy\BinaryDriver\ProcessRunner->run( ) ...\AbstractBinary.php:209
6 1.0341 2534744 Alchemy\BinaryDriver\ProcessRunner->doExecutionFailure( ) ...\ProcessRunner.php:72
( ! ) FFMpeg\Exception\RuntimeException: Encoding failed in C:\wamp64\www\test\vendor\php-ffmpeg\php-ffmpeg\src\FFMpeg\Media\AbstractVideo.php on line 106
Call Stack

Time Memory Function Location

1 0.0016 240968 {main}( ) ...\index.php:0
2 0.5958 2078888 FFMpeg\Media\AbstractVideo->save( ) ...\index.php:31

@rohitgaidhane
Copy link
Author

rohitgaidhane commented Aug 7, 2018

`<?php

require 'vendor/autoload.php';

$ffmpeg = FFMpeg\FFMpeg::create();
$video = $ffmpeg->open('rj.mp4');
// $video
// ->filters()
// ->resize(new FFMpeg\Coordinate\Dimension(320, 240))
// ->synchronize();
// $video
// ->frame(FFMpeg\Coordinate\TimeCode::fromSeconds(10))
// ->save('frame.jpg');
// $video
// ->save(new FFMpeg\Format\Video\X264(), 'export-x264.mp4')
// ->save(new FFMpeg\Format\Video\WMV(), 'export-wmv.wmv')
// ->save(new FFMpeg\Format\Video\WebM(), 'export-webm.webm');

$format = new FFMpeg\Format\Video\X264();

$format->on('progress', function ($video, $format, $percentage) {
echo "$percentage % transcoded";
});

$format
->setKiloBitrate(1000)
->setAudioChannels(2)
->setAudioKiloBitrate(256);

$video->save($format, 'video.mp4');
?>`
this is my code

@rohitgaidhane
Copy link
Author

`

$currentPath = $_FILES['video']['tmp_name']; if(exec("ffmpeg -i tareaditi.mp4 -b 1500k -minrate 1000k -maxrate 1100k -bufsize 1835k aa112.mp4")) { echo "success"; } else{ echo "fail"; }

}
?>`
\

in this way its working

@jens1o
Copy link
Member

jens1o commented Aug 7, 2018

C:\wamp64\www\imgcomptest\ffmpeg\bin\ffmpeg.EXE -y -i rj.mp4 -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 256k -ac 2 video.mp4

Could you send us the output of this command?

@rohitgaidhane
Copy link
Author

C:\wamp64\www\imgcomptest>-y -i rj.mp4 -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 256k -ac 2 video.mp4 '-y' is not recognized as an internal or external command, operable program or batch file.

@jens1o
Copy link
Member

jens1o commented Aug 7, 2018

You need to run the full command.

@rohitgaidhane
Copy link
Author

C:\Users\Amrata Technologies .LAPTOP-SDM41ULD\Downloads>ffmpeg -y -i rj.mp4 -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 256k -ac 2 video.mp4 ffmpeg version N-91548-g481741ece0 Copyright (c) 2000-2018 the FFmpeg developers built with gcc 7.3.1 (GCC) 20180722 configuration: --enable-gpl --enable-version3 --enable-sdl2 --enable-bzlib --enable-fontconfig --enable-gnutls --enable-iconv --enable-libass --enable-libbluray --enable-libfreetype --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libtheora --enable-libtwolame --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxml2 --enable-libzimg --enable-lzma --enable-zlib --enable-gmp --enable-libvidstab --enable-libvorbis --enable-libvo-amrwbenc --enable-libmysofa --enable-libspeex --enable-libxvid --enable-libaom --enable-libmfx --enable-amf --enable-ffnvcodec --enable-cuvid --enable-d3d11va --enable-nvenc --enable-nvdec --enable-dxva2 --enable-avisynth libavutil 56. 18.102 / 56. 18.102 libavcodec 58. 22.100 / 58. 22.100 libavformat 58. 17.101 / 58. 17.101 libavdevice 58. 4.101 / 58. 4.101 libavfilter 7. 26.100 / 7. 26.100 libswscale 5. 2.100 / 5. 2.100 libswresample 3. 2.100 / 3. 2.100 libpostproc 55. 2.100 / 55. 2.100 Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'rj.mp4': Metadata: major_brand : mp42 minor_version : 0 compatible_brands: mp42mp41isomavc1 creation_time : 2018-08-01T06:27:02.000000Z Duration: 00:00:17.58, start: 0.000000, bitrate: 2555 kb/s Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p(tv, bt709), 1280x720, 2413 kb/s, 29.97 fps, 29.97 tbr, 30k tbn, 60k tbc (default) Metadata: creation_time : 2018-08-01T06:27:02.000000Z handler_name : L-SMASH Video Handler encoder : AVC Coding Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 137 kb/s (default) Metadata: creation_time : 2018-08-01T06:27:02.000000Z handler_name : L-SMASH Audio Handler Unknown encoder 'libfaac'

@jens1o
Copy link
Member

jens1o commented Aug 7, 2018

Unknown encoder 'libfaac'

Try using $format = new FFMpeg\Format\Video\X264('aac'); instead of $format = new FFMpeg\Format\Video\X264();

This issue will be resolved with 1.0.

@rohitgaidhane
Copy link
Author

ok i will try.thanks for response

@rohitgaidhane
Copy link
Author

thanks its working...
and one thing ,is this code work on my linux based vps hosting

@jens1o
Copy link
Member

jens1o commented Aug 7, 2018

That's something you need to try out yourself ;)

Please make sure that your hosting provider allows video encoding on shared-hosting machines ;)

@rohitgaidhane
Copy link
Author

okkkk.Thanks you help me lots on this.

@kavin-90
Copy link

kavin-90 commented Aug 8, 2018

to get rid of PATH issue insert FFMPEG , PHP, NGINX, APACHE,WAMP bin path into PATH list so no issue will return but after insert path into env you have to restart cmd to apply new changes xD

@rohitgaidhane
Copy link
Author

can you plz tell me how to reduce framerate?

@rohitgaidhane
Copy link
Author

as i found that reducing video size is not only thing i needed i also needed to reduce video framerate

@jens1o
Copy link
Member

jens1o commented Aug 8, 2018

Please read the README. Although the documentation is rather bad, it is there and describes exactly what you need! It is not possible for me to provide 1:1 support. Thanks!

@rohitgaidhane
Copy link
Author

i got this code but how to implement this ?

$video
->filters()
->resize($dimension, $mode, $useStandards)
->framerate($framerate, $gop)
->synchronize();

i m stucked here plz help me out there?

@jens1o
Copy link
Member

jens1o commented Aug 8, 2018

Please learn some basic PHP. lol.

@rohitgaidhane
Copy link
Author

ok..,thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants