从mp3 / ogg切下确切的时间范围 [英] cut exact time range from mp3/ogg

查看:156
本文介绍了从mp3 / ogg切下确切的时间范围的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在CDN上有一堆音频文件。那些是mp3和ogg vorbises,并行。这些文件每个值约一小时播放。我需要从这些文件中提取任意部分:我给了一个文件名(我可以选择使用mp3或ogg版本)和两个时间戳,我需要在给定时间位置之间准确的音频。我不想下载整个文件,所以我想使用Range http标题。

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.

我完全控制了音频文件,因此我将它们编码为固定比特率,以便能够估计我应该达到的字节数。但是,两种格式都使用框架(或者vorbis的情况下的页面),必须以原子方式解码。

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.

我编写的程序是Perl。我尝试下载文件的一部分,我相信要包含的给定窗口,然后使用Audio :: Mad和Ogg :: Vorbis :: Decoder来解析音频文件片段。但是,两者似乎都无法处理碎片,只有在我提供整数文件时才会成功。

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?

推荐答案

回答从mp3 / ogg切下确切的时间范围 - 你可以查看一下以下适合您的需求:

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

其中ss - 开始时间,t - 持续时间。它确实减少了 - 没有重新压缩。

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

这篇关于从mp3 / ogg切下确切的时间范围的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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