【问题标题】:Add image overlay for each millisecond the video using ffmpeg and php使用ffmpeg和php为视频每毫秒添加图像叠加层
【发布时间】:2016-10-21 00:49:18
【问题描述】:

我需要使用 php 和 ffmpeg 为视频帧的每一毫秒添加一个图像和不同的位置。 例如: 在第一秒,我在 X 位置添加一个图像,下一秒在 X 位置添加另一个图像。 如果直接在终端上使用该命令,则转换成功。但是在 PHP 中我遇到了困难。 在 php 中,使用以下命令:

<?php
shell_exec('C:\\ffmpeg\\bin\\ffmpeg.exe -i C:\\ffmpeg\\bin\\vid.mp4 -i C:\\ffmpeg\\bin\\1.png -filter_complex "[0:v][1:v] overlay=100:25:enable=\'between(t,1,1.5)\'"  C:\\ffmpeg\\bin\\output1.mp4');
sleep(20);
echo "1";
shell_exec('C:\\ffmpeg\\bin\\ffmpeg.exe -i C:\\ffmpeg\\bin\\output1.mp4 -i C:\\ffmpeg\\bin\\2.png -filter_complex "[0:v][1:v] overlay=10:25:enable=\'between(t,1.5,2)\'"  C:\\ffmpeg\\bin\\output2.mp4');
sleep(50);
echo "2";
shell_exec('C:\\ffmpeg\\bin\\ffmpeg.exe -i C:\\ffmpeg\\bin\\output2.mp4 -i C:\\ffmpeg\\bin\\3.png -filter_complex "[0:v][1:v] overlay=250:25:enable=\'between(t,2,2.5)\'"  C:\\ffmpeg\\bin\\output1.mp4');
sleep(20);
echo "3";
shell_exec('C:\\ffmpeg\\bin\\ffmpeg.exe -i C:\\ffmpeg\\bin\\output1.mp4 -i C:\\ffmpeg\\bin\\4.png -filter_complex "[0:v][1:v] overlay=300:25:enable=\'between(t,3,3.5)\'"  C:\\ffmpeg\\bin\\output2.mp4');
sleep(20);
echo "4";
shell_exec('C:\\ffmpeg\\bin\\ffmpeg.exe -i C:\\ffmpeg\\bin\\output2.mp4 -i C:\\ffmpeg\\bin\\5.png -filter_complex "[0:v][1:v] overlay=350:25:enable=\'between(t,4,4.5)\'"  C:\\ffmpeg\\bin\\output1.mp4');
sleep(70000);
shell_exec('C:\\ffmpeg\\bin\\ffmpeg.exe -i C:\\ffmpeg\\bin\\output1.mp4 -i C:\\ffmpeg\\bin\\1.png -filter_complex "[0:v][1:v] overlay=400:25:enable=\'between(t,5,5.5)\'"  C:\\ffmpeg\\bin\\output2.mp4');

我使用了睡眠功能(PHP),但它不起作用。 请,因为我对ffmpeg和php没有太多经验,你可以帮助我。

非常感谢。

【问题讨论】:

    标签: php windows video ffmpeg frame


    【解决方案1】:

    通过检查命令的输出进行故障排除。那应该会给你答案。

    exec('C:\\ffmpeg\\bin\\ffmpeg.exe -i C:\\ffmpeg\\bin\\vid.mp4 -i C:\\ffmpeg\\bin\\1.png -filter_complex "[0:v][1:v] overlay=100:25:enable=\'between(t,1,1.5)\'"  C:\\ffmpeg\\bin\\output1.mp4', $output);
    var_dump($output);
    

    【讨论】:

    • 这是答案还是评论?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-03-17
    • 2017-10-16
    • 2020-11-24
    • 2019-03-11
    • 1970-01-01
    相关资源
    最近更新 更多