用ffmpeg分割.flac文件会截断音频,但没有文件长度

发布于 01-19 05:45 字数 647 浏览 5 评论 0原文

我正在尝试将Twitter Spaces Audio(.TS)文件放入我可以在OSX上轻松编辑的格式。

到目前为止

for i in *.ts;
do name=`echo "$i" | cut -d'.' -f1`
echo "$name"
ffmpeg -i "$i" -sample_fmt s16 -ar 41000 "${name}.flac"
done

​ 由于大多数文件大约需要7个小时,因此我选择的编辑无法在一个文件中处理那么多音频。

因此,我环顾四周,能够找到此命令将文件分割为3小时长的部分。

ffmpeg -i space-1OdKrBealBqKX_0.flac -map 0 -f segment -segment_time 10800 -c copy space-1OdKrBealBqKX_0__%03d.flac

这有效,但是每个文件在末尾包含与原始文件一样多的空 /无声空间。与将有助于编辑这些文件的团队共享的问题将是一个问题,因为每个文件都具有原始文件的长度和文件大小。有很多文件。 音频段和命名确实有效。

如何将文件的实际长度截断到音频段?

警告:我不是这些问题的专家,我只是设法进行了Google并走了这么远,因此,如果有人知道并想提供非常感谢的工作代码!

I am trying to get Twitter spaces audio (.ts) files into a format I can easily edit, on OSX.

So far I was able to convert the files in bulk to .flac with this:

for i in *.ts;
do name=`echo "$i" | cut -d'.' -f1`
echo "$name"
ffmpeg -i "$i" -sample_fmt s16 -ar 41000 "${name}.flac"
done

That worked, and reduced the file sizes somewhat, but..
Because most of the files are around 7 hours long, my editor of choice cannot process that much audio in one file.

So I looked around and was able to find this command to segment the files into 3hr long sections.

ffmpeg -i space-1OdKrBealBqKX_0.flac -map 0 -f segment -segment_time 10800 -c copy space-1OdKrBealBqKX_0__%03d.flac

This works, but each file contains as much empty / silent space at the end as the orginal file. That's going to be a problem for sharing with a team that will help edit these files, as each file has the original file's length and file size. There are a lot of files.
The audio segments and naming did work though.

How to truncate the actual length of the file to the audio segment?

Caveat: I am no expert on any of these matters, I just managed to google and get this far, so if someone knows and wants to provide working code that would be very much appreciated!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

萌︼了一个春2025-01-26 05:45:48

FLAC 文件包含流持续时间的元数据。当流复制时,ffmpeg 无法覆盖该元数据,因此它会被保留。

您的解决方法是在原始步骤中进行分段。

ffmpeg -i "$i" -sample_fmt s16 -ar 44100 -f segment -segment_time 10800 "${name}__%03d.flac"

FLAC files contain metadata of stream duration. When streamcopying, ffmpeg cannot overwrite that metadata, so it is retained.

Your workaround is to segment in the original step.

ffmpeg -i "$i" -sample_fmt s16 -ar 44100 -f segment -segment_time 10800 "${name}__%03d.flac"
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文