Closed daviidy closed 4 years ago
I've rewritten the package and support for concatenation is included. Could you test the v7
branch? Almost no breaking changes except for some filter stuff in HLS exports.
https://github.com/pascalbaljetmedia/laravel-ffmpeg/tree/v7
composer require "pbmedia/laravel-ffmpeg:v7.x-dev"
<?php
// without transcoding
FFMpeg::fromDisk('local')
->open(['video.mp4', 'video2.mp4'])
->export()
->concatWithoutTranscoding()
->save('concat.mp4');
// with transcoding
FFMpeg::fromDisk('local')
->open(['video.mp4', 'video2.mp4'])
->export()
->inFormat(new X264)
->concatWithTranscoding($hasVideo = true, $hasAudio = true)
->save('concat.mp4');
I tested the concatenation without transcoding. No error, but it only outputs one video. it does not put the two videos side by side. When I try with transcoding, I get the error "Encoding failed"
Sorry, the concatenation works. I wanted rather to stack two or more videos horizontally.
Here is the code:
$tab = ['video1.mp4', 'video2.mp4']; FFMpeg::fromDisk('local') ->open($tab) ->export() ->addFilter('[0:v][1:v]', 'hstack', '[v]') // $in, $parameters, $out ->addFormatOutputMapping(new X264, Media::make('local', 'stacked_video.mp4'), ['0:a', '[v]']) ->save();
But i get the error
Can you share the full log? https://flareapp.io/docs/ignition-for-laravel/sharing-errors
Here is the log:
ffmpeg failed to execute command C:\FFmpeg\bin\ffmpeg.EXE -y -threads "" -i C:\Users\DELL\Documents\workspace\repetbox\storage\app\video1.mp4 -i C:\Users\DELL\Documents\workspace\repetbox\storage\app\video2.mp4 -filter_complex [0:v][1:v]hstack[v] -map 0:a -map [v] -vcodec libx264 -b:v 1000k -acodec libfaac -b:a 128k C:\Users\DELL\Documents\workspace\repetbox\storage\app\stacked_video.mp4: Error in GnuTLS initialization: Failed to acquire random data.
ffmpeg version 4.2.2 Copyright (c) 2000-2019 the FFmpeg developers
built with gcc 9.2.1 (GCC) 20200122
configuration: --enable-gpl --enable-version3 --enable-sdl2 --enable-fontconfig --enable-gnutls --enable-iconv --enable-libass --enable-libdav1d --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 --enable-libopenmpt
libavutil 56. 31.100 / 56. 31.100
libavcodec 58. 54.100 / 58. 54.100
libavformat 58. 29.100 / 58. 29.100
libavdevice 58. 8.100 / 58. 8.100
libavfilter 7. 57.100 / 7. 57.100
libswscale 5. 5.100 / 5. 5.100
libswresample 3. 5.100 / 3. 5.100
libpostproc 55. 5.100 / 55. 5.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'C:\Users\DELL\Documents\workspace\repetbox\storage\app\video1.mp4':
Metadata:
major_brand : isom
minor_version : 512
compatible_brands: isomiso2avc1mp41
encoder : Lavf57.37.101
Duration: 00:00:16.42, start: 0.000000, bitrate: 2350 kb/s
Stream #0:0(und): Video: h264 (Constrained Baseline) (avc1 / 0x31637661), yuv420p, 720x720 [SAR 1:1 DAR 1:1], 2230 kb/s, 25 fps, 25 tbr, 12800 tbn, 50 tbc (default)
Metadata:
handler_name : VideoHandler
Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 117 kb/s (default)
Metadata:
handler_name : SoundHandler
Input #1, mov,mp4,m4a,3gp,3g2,mj2, from 'C:\Users\DELL\Documents\workspace\repetbox\storage\app\video2.mp4':
Metadata:
major_brand : isom
minor_version : 512
compatible_brands: isomiso2avc1mp41
encoder : Lavf57.37.101
Duration: 00:00:17.06, start: 0.000000, bitrate: 2557 kb/s
Stream #1:0(und): Video: h264 (Constrained Baseline) (avc1 / 0x31637661), yuv420p, 720x720 [SAR 1:1 DAR 1:1], 2426 kb/s, 25 fps, 25 tbr, 12800 tbn, 50 tbc (default)
Metadata:
handler_name : VideoHandler
Stream #1:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 128 kb/s (default)
Metadata:
handler_name : SoundHandler
Unknown encoder 'libfaac'
i changed the codec like that:
$tab = ['video1.mp4', 'video2.mp4'];
FFMpeg::fromDisk('local')
->open($tab)
->export()
->addFilter('[0:v][1:v]', 'hstack', '[v]') // $in, $parameters, $out
->addFormatOutputMapping(new X264('libmp3lame', 'libx264'), Media::make('local', 'stacked_video.mp4'), ['0:a', '[v]'])
->save();
But i get the same error. And in the debug there is a error message: Error while opening decoder for input stream #0:0 : Invalid argument
Stream mapping:
Stream #0:0 (h264) -> hstack:input0 (graph 0)
Stream #1:0 (h264) -> hstack:input1 (graph 0)
Stream #0:1 -> #0:0 (aac (native) -> mp3 (libmp3lame))
hstack (graph 0) -> Stream #0:1 (libx264)
Error while opening decoder for input stream #0:0 : Invalid argument
Hello, it works now. i just had to run php artisan config:clear
and php artisan cache:clear
That's awesome, thanks for sharing!
Hello, I want to concatenate many videos with ffmpeg. I'm using Laravel 7.7.1 and i'm running on PHP 7.4 Here is my code
`public function joinVideos(Recording $recording) { $disk = FFMpeg::fromDisk('public'); $video1 = $disk->open('video1.mp4'); $video2 = $disk->open('video2.mp4'); $output = $disk->open('test.mp4');
But i'm getting this error:
Unable to probe C:\Users\DELL\Documents\workspace\repetbox\storage\app/public\test.mp4
I've already put the right paths to ffmpeg and ffprobe binaries