سلام من از کتابخانه ffmpeg برای تبدیل و واترمارک فایلها استفاده میکنم
if (pathinfo(storage_path('/public/files/' . $replaced), PATHINFO_EXTENSION) <> 'pdf' and pathinfo(storage_path('/public/files/' . $replaced), PATHINFO_EXTENSION) <> 'pptx' ){
set_time_limit(0);
$ffmpeg = FFMpeg::create([
'ffmpeg.binaries' => '/usr/bin/ffmpeg',
'ffprobe.binaries' => '/usr/bin/ffprobe',
'timeout' => 0, // The timeout for the underlying process
//'ffmpeg.threads' => 12, // The number of threads that FFMpeg should use
]);
$video_frame = $ffmpeg->open(Storage::path('public/files' . '/' . $replaced));
$watermark =storage_path('app/public/thumbs/logo_w.png');
$ffmpeg->getFFMpegDriver()->listen(new \Alchemy\BinaryDriver\Listeners\DebugListener());
$ffmpeg->getFFMpegDriver()->on('debug', function ($message) {
echo $message."\n";
});
$format_file = new X264('libmp3lame', 'libx264');
$format_file->setAudioCodec("libmp3lame", "libx264");
$st_point=substr($replaced,0,strlen($replaced)-3);
if(substr($st_point,strlen($st_point)-1,1)=="."){
$replaced_new=substr($replaced,0,strlen($replaced)-3).'mp4';
}
elseif(substr($st_point,strlen($st_point)-1,1)<>"."){
$replaced_new=substr($replaced,0,strlen($replaced)-4).'mp4';
}
$storage_path = storage_path('app/public/files/' . $replaced_new);
$storage_path1 = storage_path('app/public/files/' . $replaced);
$video_frame->save($format_file, $storage_path);
if((Storage::exists('public/files' . '/' . $replaced)) and (pathinfo(storage_path('/public/files/' . $replaced), PATHINFO_EXTENSION) <> 'mp4'))
{
Storage::delete(Storage::path('public/files' . '/' . $replaced));
unlink(Storage::path('public/files' . '/' . $replaced));
}
$replaced=$replaced_new;
}
این کدش برای بعضی از فایلها درست کار میکنه و برای بعضی خطا میده
ERROR] ffmpeg version 2.8.15 Copyright (c) 2000-2018 the FFmpeg developers [ERROR] built with gcc 4.8.5 (GCC) 20150623 (Red Hat 4.8.5-36) [ERROR] configuration: --prefix=/usr --bindir=/usr/bin --datadir=/usr/share/ffmpeg --incdir=/usr/include/ffmpeg --libdir=/usr/lib64 --mandir=/usr/share/man --arch=x86_64 --optflags='-O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic' --extra-ldflags='-Wl,-z,relro ' --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libvo-amrwbenc --enable-version3 --enable-bzlib --disable-crystalhd --enable-gnutls --enable-ladspa --enable-libass --enable-libcdio --enable-libdc1394 --enable-libfdk-aac --enable-nonfree --disable-indev=jack --enable-libfreetype --enable-libgsm --enable-libmp3lame --enable-openal --enable-libopenjpeg --enable-libopus --enable-libpulse --enable-libschroedinger --enable-libsoxr --enable-libspeex --enable-libtheora --enable-libvorbis --enable-libv4l2 --enable-libx264 --enable-libx265 --enable-libxvid --enable-x11grab --enable-avfilter --enable-avresample --enable-postproc --enable-pthreads --disable-static --enable-shared --enable-gpl --disable-debug --disable-stripping --shlibdir=/usr/lib64 --enable-runtime-cpudetect [ERROR] [ERROR] libavutil 54. 31.100 / 54. 31.100 [ERROR] libavcodec 56. 60.100 / 56. 60.100 [ERROR] libavformat 56. 40.101 / 56. 40.101 [ERROR] libavdevice 56. 4.100 / 56. 4.100 [ERROR] libavfilter 5. 40.101 / 5. 40.101 [ERROR] libavresample 2. 1. 0 / 2. 1. 0 [ERROR] libswscale 3. 1.101 / 3. 1.101 [ERROR] libswresample 1. 2.101 / 1. 2.101 [ERROR] libpostproc 53. 3.100 / 53. 3.100 [ERROR] Input #0, matroska,webm, from '/home/mediseenir/public_html/laravel/storage/app/public/files/file_name-62593686716.webm': [ERROR] Metadata: [ERROR] encoder : Chrome [ERROR] Duration: N/A, start: 0.000000, bitrate: N/A [ERROR] Stream #0:0(eng): Audio: opus, 48000 Hz, stereo, fltp (default) [ERROR] Stream #0:1(eng): Video: vp8, yuv420p, 1600x792, SAR 1:1 DAR 200:99, 60 tbr, 1k tbn, 1k tbc (default) [ERROR] Metadata: [ERROR] alpha_mode : 1 [ERROR] [libx264 @ 0x1f2dd40] using SAR=1/1 [ERROR] [libx264 @ 0x1f2dd40] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX [ERROR] [libx264 @ 0x1f2dd40] profile Main, level 4.2 [ERROR] [libx264 @ 0x1f2dd40] 264 - core 142 r2495 6a301b6 - H.264/MPEG-4 AVC codec - Copyleft 2003-2014 - http://www.videolan.org/x264.html - options: cabac=1 ref=1 deblock=1:0:0 analyse=0x1:0 me=dia subme=2 psy=1 psy_rd=1.00:0.00 mixed_ref=0 me_range=16 chroma_me=1 trellis=0 8x8dct=0 cqm=0 deadzone=21,11 fast_pskip=1 chroma_qp_offset=0 threads=6 lookahead_threads=2 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=2 keyint=250 keyint_min=25 scenecut=40 intra_refresh=0 rc_lookahead=40 rc=abr mbtree=1 bitrate=1000 ratetol=1.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 ip_ratio=1.41 aq=1:1.00 [ERROR] Output #0, mp4, to '/home/mediseenir/public_html/laravel/storage/app/public/files/file_name-62593686716.mp4': [ERROR] Metadata: [ERROR] encoder : Lavf56.40.101 [ERROR] Stream #0:0(eng): Video: h264 (libx264) ([33][0][0][0] / 0x0021), yuv420p, 1600x792 [SAR 1:1 DAR 200:99], q=-1--1, pass 1, 1000 kb/s, 60 fps, 15360 tbn, 60 tbc (default) [ERROR] Metadata: [ERROR] alpha_mode : 1 [ERROR] encoder : Lavc56.60.100 libx264 [ERROR] Stream #0:1(eng): Audio: mp3 (libmp3lame) (i[0][0][0] / 0x0069), 48000 Hz, stereo, fltp, 128 kb/s (default) [ERROR] Metadata: [ERROR] encoder : Lavc56.60.100 libmp3lame [ERROR] Stream mapping: [ERROR] Stream #0:1 -> #0:0 (vp8 (native) -> h264 (libx264)) [ERROR] Stream #0:0 -> #0:1 (opus (native) -> mp3 (libmp3lame)) [ERROR] Press [q] to stop, [?] for help [ERROR] [ERROR] frame= 104 fps=0.0 q=35.0 size= 73kB time=00:00:03.62 bitrate= 165.0kbits/s dup=81 drop=0 [ERROR] frame= 219 fps=166 q=25.0 size= 201kB time=00:00:05.35 bitrate= 308.1kbits/s dup=192 drop=0 [ERROR] frame= 325 fps=173 q=22.0 size= 404kB time=00:00:05.54 bitrate= 597.1kbits/s dup=294 drop=0 [ERROR] frame= 410 fps=172 q=19.0 size= 446kB time=00:00:08.46 bitrate= 431.3kbits/s dup=360 drop=0 [ERROR] frame= 524 fps=174 q=17.0 size= 508kB time=00:00:10.03 bitrate= 414.6kbits/s dup=469 drop=0 [ERROR] frame= 603 fps=172 q=16.0 size= 719kB time=00:00:12.62 bitrate= 466.7kbits/s dup=544 drop=0 [ERROR] frame= 710 fps=175 q=15.0 size= 788kB time=00:00:13.82 bitrate= 467.1kbits/s dup=648 drop=0 [ERROR] frame= 830 fps=175 q=14.0 size= 1036kB time=00:00:15.38 bitrate= 551.6kbits/s dup=764 drop=0 [ERROR] frame= 919 fps=175 q=13.0 size= 1080kB time=00:00:16.70 bitrate= 529.4kbits/s dup=850 drop=0 [ERROR] frame= 1015 fps=175 q=12.0 size= 1230kB time=00:00:18.74 bitrate= 537.5kbits/s dup=940 drop=0 [ERROR] frame= 1129 fps=172 q=12.0 size= 1556kB time=00:00:20.78 bitrate= 613.2kbits/s dup=1051 drop=0 [ERROR] frame= 1249 fps=173 q=11.0 size= 1653kB time=00:00:22.75 bitrate= 595.0kbits/s dup=1167 drop=0 [ERROR] frame= 1368 fps=170 q=10.0 size= 1940kB time=00:00:24.74 bitrate= 642.1kbits/s dup=1282 drop=0 [ERROR] frame= 1487 fps=171 q=10.0 size= 1994kB time=00:00:26.71 bitrate= 611.5kbits/s dup=1397 drop=0 [ERROR] frame= 1609 fps=170 q=9.0 size= 2268kB time=00:00:28.75 bitrate= 646.1kbits/s dup=1514 drop=0 [ERROR] frame= 1729 fps=171 q=9.0 size= 2315kB time=00:00:29.78 bitrate= 636.7kbits/s dup=1631 drop=0 [ERROR] frame= 1848 fps=169 q=9.0 size= 2856kB time=00:00:32.78 bitrate= 713.6kbits/s dup=1745 drop=0 [ERROR] frame= 1969 fps=168 q=8.0 size= 3190kB time=00:00:33.79 bitrate= 773.3kbits/s dup=1862 drop=0 [ERROR] frame= 2091 fps=167 q=8.0 size= 3552kB time=00:00:36.74 bitrate= 791.9kbits/s dup=1977 drop=0 [ERROR] frame= 2210 fps=169 q=8.0 size= 3700kB time=00:00:38.78 bitrate= 781.5kbits/s dup=2093 drop=0 [ERROR] frame= 2329 fps=171 q=7.0 size= 4037kB time=00:00:40.75 bitrate= 811.4kbits/s dup=2208 drop=0 [ERROR] frame= 2449 fps=173 q=7.0 size= 4088kB time=00:00:42.79 bitrate= 782.6kbits/s dup=2324 drop=0 [ERROR] frame= 2570 fps=174 q=7.0 size= 4376kB time=00:00:43.94 bitrate= 815.7kbits/s dup=2441 drop=0 [ERROR] frame= 2690 fps=176 q=6.0 size= 4426kB time=00:00:45.43 bitrate= 798.0kbits/s dup=2555 drop=0 [ERROR] frame= 2810 fps=177 q=6.0 size= 4757kB time=00:00:47.66 bitrate= 817.6kbits/s dup=2668 drop=0 [ERROR] frame= 2915 fps=178 q=6.0 size= 5148kB time=00:00:49.82 bitrate= 846.5kbits/s dup=2766 drop=0 [ERROR] frame= 3039 fps=178 q=6.0 size= 5553kB time=00:00:52.82 bitrate= 861.2kbits/s dup=2885 drop=0 [ERROR] frame= 3170 fps=179 q=6.0 size= 5950kB time=00:00:54.62 bitrate= 892.3kbits/s dup=3012 drop=0 [ERROR] frame= 3279 fps=180 q=6.0 size= 6208kB time=00:00:55.62 bitrate= 914.2kbits/s dup=3117 drop=0 [ERROR] frame= 3383 fps=181 q=6.0 size= 6564kB time=00:00:56.47 bitrate= 952.1kbits/s dup=3207 drop=0 [ERROR] frame= 3471 fps=181 q=5.0 size= 6735kB time=00:01:00.26 bitrate= 915.4kbits/s dup=3284 drop=0 [ERROR] frame= 3584 fps=181 q=5.0 size= 7095kB time=00:01:01.34 bitrate= 947.5kbits/s dup=3394 drop=0 [ERROR] frame= 3703 fps=182 q=5.0 size= 7176kB time=00:01:01.74 bitrate= 952.0kbits/s dup=3499 drop=0 [ERROR] frame= 3821 fps=182 q=7.0 size= 7925kB time=00:01:05.18 bitrate= 996.0kbits/s dup=3608 drop=0 [ERROR] frame= 3950 fps=183 q=6.0 size= 8095kB time=00:01:07.10 bitrate= 988.3kbits/s dup=3732 drop=0 [ERROR] frame= 4071 fps=184 q=8.0 size= 8618kB
time=00:01:08.71 bitrate=1027.5kbits/s dup=3842 drop=0 [ERROR] frame= 4160 fps=184 q=9
اینم خطاش