cut exact time range from mp3/ogg

不打扰是莪最后的温柔 提交于 2019-12-22 11:15:25

问题


I have a heap of audio files on a CDN. Those are mp3's and ogg vorbises, in parallel. Those files are each worth about one hour of playback. I need to extract arbitrary parts from those files: I am given a filename (I can choose if I use the mp3 or ogg version) and two timestamps and I need the audio exactly between the given time positions. I don't want to download the whole file, so I think of using the Range http header.

I have complete control over the audio files, so I encoded them in fixed bitrate, to be able to estimate which bytes I should reach for. However, both formats use frames (or pages in vorbis's case), which must be decoded atomically.

The program I write is in Perl. I tried downloading a part of the file where I believe the given window to be contained, and then using Audio::Mad and Ogg::Vorbis::Decoder to parse the audio file fragments. However, both seem to fail to process the fragments, and only succeed when I serve an integral file.

So my question is: How can I get an exact span of an audio file without downloading the whole thing?


回答1:


Answering "cut exact time range from mp3/ogg" - You can check out if the following fits Your needs:

ffmpeg -i InFile  -vn -acodec copy -ss 00:00:00 -t 00:01:32 -threads 0 OutFile

where ss - start time, t - duration. It cuts indeed - no re-compressions.



来源:https://stackoverflow.com/questions/10055996/cut-exact-time-range-from-mp3-ogg

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!