【问题标题】:using PHP shell_exec and ffmpeg to merge 2 audio files使用 PHP shell_exec 和 ffmpeg 合并 2 个音频文件
【发布时间】:2016-01-24 09:32:26
【问题描述】:

我正在编写一个 php 脚本,该脚本将使用 ffmpeg 的 amix feature 和 $ 变量将两个音频文件混合为一个。它设置为自动将最终输出的持续时间调整为第一个输入持续时间。 (如 duration=first 所示)

当我运行这个脚本时,它不会创建 mixtest.mp3

mix.php:

<?php

$input1 = 'original.mp3'; // Original Track
$input2 = 'tagoverlay.mp3'; // Audio Tag Overlay
$output = 'mixtest.mp3';

shell_exec('ffmpeg -i ' . $input1 . ' -i ' . $input2 . ' -filter_complex amix=inputs=2:duration=first:dropout_transition=3 ' . $output . '');
echo 'Done';

?>

我已经在服务器上使用 ffmpeg 将 wav 转换为 mp3 并且效果很好。我也见过sox can do this as well with -m,我已经安装并尝试过了,由于某种原因它没有导出mixtest.mp3。

【问题讨论】:

    标签: php audio ffmpeg


    【解决方案1】:

    在弄乱并切换变量后,我让它工作了,可能是文件权限问题,我也摆脱了 dropout_transition,according to ffmpeg documentation 默认为 2:

        $file_path = 'beats/' . $timecode . '.' . $file_extn;
        $overlay = 'beats/tagoverlay.mp3';
        shell_exec('ffmpeg -i ' . $file_path . ' -i ' . $overlay . ' -filter_complex amix=inputs=2:duration=first beats/' . $timecode . 'tagged.mp3'); 
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2018-10-14
      • 1970-01-01
      • 1970-01-01
      • 2018-02-07
      • 2018-12-22
      • 2019-05-04
      相关资源
      最近更新 更多