ffmpeg修剪mp3文件时不准确 [英] ffmpeg being inprecise when trimming mp3 files

查看:74
本文介绍了ffmpeg修剪mp3文件时不准确的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用ffmpeg修剪某些mp3,而无需重新编码.我使用的命令是
ffmpeg -i"inputfile.mp3" -t 00:00:12.414 -c复制out.mp3
但是,out.mp3的长度为12.460s,当我在Audacity中加载文件时,我可以看到它是在错误的位置而不是12.414s处剪切的.

I want to use ffmpeg to trim some mp3s without re-encoding. The command I used was
ffmpeg -i "inputfile.mp3" -t 00:00:12.414 -c copy out.mp3
However, out.mp3 has a length of 12.460s, and when I load the file in Audacity I can see that it was cut at the wrong spot, and not at 12.414s.

这是为什么?我在Google上搜索了一下,并尝试了其他一些命令,例如 ffmpeg -i"inputfile.mp3" -ss 0 -to 00:00:12.414 -c copy out.mp3 (有趣的是,它的长度不同12.434s),但永远无法获得正确的毫秒数.

Why is this? I googled a bit and tried some other commands like ffmpeg -i "inputfile.mp3" -ss 0 -to 00:00:12.414 -c copy out.mp3 (which interestingly results in a different length of 12.434s) but could never get the milliseconds to be cut right.

PS.我不确定SO是否合适,因为它在技术上与编程无关,但是我在ffmpeg上发现的用于修剪音频文件的大多数东西都是stackoverflow问题,例如.G. ffmpeg以毫秒精度修剪视频

PS. I wasn't sure whether SO was the right place to ask since it isn't technically programming related, however most of the stuff I found on ffmpeg for trimming audio files were stackoverflow questions, e. g. ffmpeg trimming videos with millisecond precision

推荐答案

您无法以这种精确度修整MP3(也是最有损的编解码器输出).在编码过程中添加了一个MP3帧左右的填充.(另请参见: https://wiki.hydrogenaud.io/index.php?title=Gapless ,以及完成这项工作所需的所有技巧.)

You can't trim MP3 (nor most lossy codec output) with that level of precision. An MP3 frame or so of padding is added during encoding. (See also: https://wiki.hydrogenaud.io/index.php?title=Gapless, and all the hacks required to make this work.)

如果需要精确定时,请使用WAV中未压缩的东西(例如PCM)或FLAC等无损压缩.

If you need precision timing, use something uncompressed like PCM in WAV, or a lossless compression like FLAC.

这篇关于ffmpeg修剪mp3文件时不准确的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆