如何使用 ffmpeg 在 30 秒内从 smaller/larger 文件中提取 30 秒的音频

How can extract 30 seconds of audio from smaller/larger file on 30 seconds using ffmpeg

我尝试使用 ffmpeg 提取 30 秒的音频,它在示例文件大于 30 秒的情况下工作正常。但如果文件是 15 秒,那么它将 return 只有 15 秒。

这里显示我的代码

<?php
exec("/usr/bin/ffmpeg -ss 0 -i sample.mp3 -t 30 output.mp3");
?>

我想从 15 秒的示例文件中提取 30 秒的音频。

谢谢。

使用stream_loop.

ffmpeg -stream_loop -1 -ss 0 -i sample.mp3 -t 30 output.mp3

在我的快速测试中,输出时长是正确的,但是播放器显示的时长是错误的,