有没有人使用MLT(Media Loving Toolkit)框架和PHP。是否有一个启动材料或代码示例,我可以参考MLT - PHP API集成
答案 0 :(得分:2)
您可以使用MLT库和我的课程。您可以从此链接https://github.com/1fer/mlt
下载它要在服务器上安装此熔解库,请使用以下命令:
sudo apt install melt
看看文档如何使用它,例如,使用以下代码加入剪辑:
require __DIR__ . '/vendor/autoload.php';
$videoProcessing = new Andchir\VideoProcessing([
'melt_path' => '/usr/bin/melt',
'session_start' => true
]);
// Join clips
$videoProcessing
->setProfile('hdv_720_25p')
->addOption(['joinClips' => [
$rootPath . '/uploads/tmp/Social.mp4',
$rootPath . '/uploads/tmp/Dog.mp4',
$rootPath . '/uploads/tmp/Swans.mp4'
]])
->setOutputVideoOptions($rootPath . '/uploads/tmp/out1.mp4');
// Black color and fade transition
$videoProcessing
->setProfile('hdv_720_25p')
->addOption(['inputSource' => [
'colour:black', ['out' => 24],
$rootPath . '/uploads/tmp/Dog.mp4'
]])
->addOption(['mix' => 25])
->addOption(['mixer' => 'luma'])
->addOption(['inputSource' => [
'colour:black', ['out' => 24]
]])
->addOption(['mix' => 25])
->addOption(['mixer' => 'luma'])
->setOutputVideoOptions($rootPath . '/uploads/tmp/out2.mp4');
// Join clips with transition
$videoProcessing
->setProfile('hdv_720_25p')
->addOption(['inputSource' => [
$rootPath . '/uploads/tmp/Swans.mp4',
$rootPath . '/uploads/tmp/Dog.mp4'
]])
->addOption(['mix' => 25])
->addOption(['mixer' => 'luma'])
->setOutputVideoOptions($rootPath . '/uploads/tmp/out3.mp4');
// Cut clips and join with transition
$videoProcessing
->setProfile('hdv_720_25p')
->addOption(['inputSource' => [
$rootPath . '/uploads/tmp/Social.mp4', ['in' => 200, 'out' => 275]
]])
->addOption(['inputSource' => [
$rootPath . '/uploads/tmp/Dog.mp4', ['in' => 50, 'out' => 125]
]])
->addReadyMadeTransition('fade', 25)
->addOption(['inputSource' => [
$rootPath . '/uploads/tmp/Swans.mp4', ['in' => 50, 'out' => 125]
]])
->addReadyMadeTransition('shiftRightIn', 25, [
'width' => 1280,
'height' => 720
])
->setOutputVideoOptions($rootPath . '/uploads/tmp/out4.mp4');
// Add background audio with delay
$videoProcessing
->setProfile('hdv_720_25p')
->addOption(['inputSource' => [
$rootPath . '/uploads/tmp/Swans.mp4', ['in' => 50, 'out' => 125]
]])
->disableAudio()
->addOption(['inputSource' => [
$rootPath . '/uploads/tmp/Dog.mp4', ['in' => 50, 'out' => 200]
]])
->addReadyMadeTransition('shiftLeftIn', 25)
->addBackgroundAudio($rootPath . '/uploads/tmp/Reformat.mp3', ['in' => 0, 'out' => 150, 'delay' => 50])
->setOutputVideoOptions($rootPath . '/uploads/tmp/out7.mp4');
// Add watermark
$videoProcessing
->setProfile('hdv_720_25p')
->addOption(['inputSource' => [
$rootPath . '/uploads/tmp/Swans.mp4', ['in' => 50, 'out' => 125]
]])
->addOption(['inputSource' => [
$rootPath . '/uploads/tmp/Dog.mp4', ['in' => 50, 'out' => 200]
]])
->addWatermark($rootPath . '/uploads/tmp/SampleLogo.png', false, [
'distort' => 1
])
->addReadyMadeTransition('shiftLeftIn', 25)
->setOutputVideoOptions($rootPath . '/uploads/tmp/out8.mp4');
// Add text overlay
$videoProcessing
->setProfile('hdv_720_25p')
->addOption(['inputSource' => [
$rootPath . '/uploads/tmp/Swans.mp4', ['out' => 120]
]])
->addTextOverlay('This is my best video', true, [
'fgcolour' => '#004fed',
'olcolour' => '#fff200',
'outline' => 3,
'pad' => '50x0',
'size' => 80,
'weight' => 700,
'style' => 'italic',
'halign' => 'center',
'valign' => 'top',
'family' => 'Ubuntu'
])
->setOutputVideoOptions($rootPath . '/uploads/tmp/out10.mp4');
// Animated text
$videoProcessing
->setProfile('hdv_720_25p')
->addOption(['inputSource' => [
$rootPath . '/uploads/tmp/Swans.mp4', ['out' => 120]
]])
->addTextOverlay('This is my best video', true, [
'pad' => '50x0',
'size' => 80,
'halign' => 'center',
'valign' => 'top',
'family' => 'Ubuntu',
'slideFrom' => 'bottom',
'duration' => 50,
'inOpacity' => 0,
'outOpacity' => 100
])
->setOutputVideoOptions($rootPath . '/uploads/tmp/out11.mp4');
// Rendering
$videoProcessing
->setProfile('hdv_720_25p')
->addOption(['inputSource' => [
$rootPath . '/uploads/tmp/Swans.mp4', ['out' => 120]
]])
->disableAudio()
->addOption(['inputSource' => [
$rootPath . '/uploads/tmp/Dog.mp4', ['out' => 120]
]])
->addReadyMadeTransition('shiftLeftIn', 25)
->addBackgroundAudio($rootPath . '/uploads/tmp/Reformat.mp3', ['out' => 215])
->setOutputVideoOptions($rootPath . '/uploads/tmp/out.mp4');
// Start rendering in background
$progressLogPath = $videoProcessing->render();
// Rendering progress
$percent = $videoProcessing->getRenderingPercent();
您还可以制作一些滤镜效果,例如在Instagram中等等。在这里阅读更多: https://www.mltframework.org/plugins/PluginsFilters/
答案 1 :(得分:0)
我唯一能找到的Multimedia Conversion - Sub MLT Project位于MLT Projects Wiki page。不确定这是否是有用的信息,但也许它会帮助你。