简体   繁体   English

ffmpeg剪辑音频间隔,包括开始和结束时间

[英]ffmpeg clip audio interval with starting and end time

I am trying to clip an MP3 between two starting points, like starting at 10 seconds and ending at 16 seconds (time interval of 6 seconds). 我试图在两个起始点之间剪辑MP3,例如从10秒开始到16秒结束(时间间隔为6秒)。

I am using this command: 我正在使用此命令:

ffmpeg -ss 10 -i input.mp3 -t 6 output.mp3

The resulting output.mp3 contains the 6 seconds that I specified followed by 8 or 9 seconds of empty audio. 结果output.mp3包含我指定的6秒,然后是8或9秒的空音频。 Is there something wrong with my command? 我的命令有问题吗?

Edit: 编辑:

ffmpeg -ss 10 -t 6 -i input.mp3 output.mp3 says -t is not an input option, keeping it for the next output; consider fixing your command line. ffmpeg -ss 10 -t 6 -i input.mp3 output.mp3表示-t is not an input option, keeping it for the next output; consider fixing your command line. -t is not an input option, keeping it for the next output; consider fixing your command line. and gives me a file that's got 8 seconds of audio starting from 10s and then some 9 or 10 seconds of silence. 并给我一个文件,从10秒开始有8秒的音频,然后是9或10秒的静音。

ffmpeg -ss 10 -to 16 -i input.mp3 output.mp3 produces a file that is twice the length of the original - basically the same audio file repeated again.\\ ffmpeg -ss 10 -to 16 -i input.mp3 output.mp3生成一个长度是原始文件长度两倍的文件 - 基本上重复相同的音频文件。

Testing the output: 测试输出:

I used Quicktime and it has silent audio at the end. 我使用Quicktime,最后它有静音。 The description of the output file in finder says like 14 seconds. finder中输出文件的描述就像14秒。 When I use VLC, it plays for the correct 6 seconds and stops, even though its duration in the file browser in VLC says 14. My MPlayer doesn't work properly. 当我使用VLC时,它会播放正确的6秒并停止,即使它在VLC文件浏览器中的持续时间为14.我的MPlayer无法正常工作。 I also did the preview audio in Finder, and it plays the 6 seconds properly and then stops. 我也在Finder中做了预览音频,它正常播放6秒然后停止。 But the round seeker bar of the MP3 didn't reach the end. 但是MP3的圆形导引杆还没有到达终点。 And it also says 14 seconds instead of 6. 它还说14秒而不是6秒。

My goal is to stream this 6 second file through a REST API to the front end. 我的目标是通过REST API将这个6秒文件传输到前端。 I want the user to be able to download this file properly. 我希望用户能够正确下载此文件。 Ideally it won't have inconsistent metadata (14 seconds instead of 6). 理想情况下,它不会有不一致的元数据(14秒而不是6秒)。

For me both 对我而言

ffmpeg -ss 10 -t 6 -i input.mp3 output.mp3

or 要么

ffmpeg -ss 10 -i input.mp3 -t 6 output.mp3

work OK, just 6 seconds of audio. 工作正常,只需6秒的音频。 Here's the mplayer output (last line): 这是mplayer输出(最后一行):

A:   5.8 (05.7) of 6.0 (06.0)  0.5%

Also

ffmpeg -ss 10 -to 16 -i input.mp3 output.mp3

work the same way. 以同样的方式工作。 I use ffmpeg version 1.2.4 . 我使用ffmpeg version 1.2.4 I guess your ffmpeg is somehow "broken" or the input file is somehow (report a bug in either case). 我猜你的ffmpeg以某种方式“破坏”或输入文件以某种方式(在任何一种情况下报告错误)。

You may try the other answer with mp3cut from portforwardpodcast or 您可以尝试与mp3cut对方回答从portforwardpodcast

sox input.mp3 output.mp3 trim 10 6

ffmpeg - Trim audio file without re-encoding ffmpeg - 无需重新编码即可修剪音频文件

Use ffmpeg to trim an audio file without re-encoding it. 使用ffmpeg修剪音频文件而不重新编码。

Trim starting from 10 seconds and end at 16 seconds (total time 6 seconds) 修剪从10秒开始,以16秒结束(总时间6秒)

ffmpeg -i input.mp3 -ss 10 -t 6 -acodec copy output.mp3

Trim from 00:02:54.583 to the end of the file 从00:02:54.583修剪到文件末尾

ffmpeg -i input.mp3 -ss 00:02:54.583 -acodec copy output.mp3

Trim from 00:02:54.583 for 5 minutes (300 seconds) 从00:02:54.583修剪5分钟(300秒)

ffmpeg -i input.mp3 -ss 00:02:54.583 -t 300 -acodec copy output.mp3

I've had great success with both CBR and VBR mp3 files using mp3cut. 我使用mp3cut获得了CBR和VBR mp3文件的巨大成功。

mp3cut -o output.mp3 -t 00:10-00:16 input.mp3

http://manpages.ubuntu.com/manpages/lucid/man1/mp3cut.1.html http://manpages.ubuntu.com/manpages/lucid/man1/mp3cut.1.html

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM