下载mp3的最后30秒 [英] Download last 30 seconds of an mp3

查看:139
本文介绍了下载mp3的最后30秒的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以只下载最近30秒的mp3?还是有必要下载整个事情,并在事后裁剪?我将通过http下载,即我有文件的URL,但是它是。

Is it possible to download only the last 30 seconds of an mp3? Or is it necessary to download the whole thing and crop it after the fact? I would be downloading via http, i.e. I have the URL of the file but that's it.

推荐答案

不,这是不可能的...至少不知道一些更多的信息。

No, it is not possible... at least not without knowing some more information first.

这里真正的问题是确定最后30秒是什么字节偏移量。这是一个知道的产品:

The real problem here is determining at what byte offset the last 30 seconds is. This is a product of knowing:


  • 采样率

  • 位深度(每个样本) li>
  • #个频道

  • CBR或VBR

  • 比特率

  • Sample Rate
  • Bit Depth (per sample)
  • # of Channels
  • CBR or VBR
  • Bit Rate

即使如此,您也不会用VBR MP3文件获得,即使是CBR,谁知道ID3和其他垃圾在文件的开头有多大。即使你知道所有这一切,仍然有一些变异性,因为你有点水库的问题。

Even then, you're not going to get that with a VBR MP3 file, and even with CBR, who knows how big the ID3 and other crap at the beginning of the file is. Even if you know all of that, there is still some variability, as you have the problem of the bit reservoir.

唯一的方法是下载整个文件并使用诸如FFMPEG之类的工具找出正确的偏移量。然后,如果你想播放它,你需要添加相应的标题,并确保你正在修剪符合条件的框架,或者自己修复该位图。

The only way to know would be to download the whole file and use a tool such as FFMPEG to find out the right offset. Then if you want to play it, you'll want to add the appropriate headers, and make sure you are trimming on an eligible frame, or fix the bit reservoir yourself.

现在,如果这些都可以提前服务器端,那么是的,您可以从服务器请求偏移量,然后从那里下载。至于如何下载它,你的问题是非常不完整的,没有提到你使用什么协议,所以我不能帮助你。

Now, if this could all be figured out server-side ahead of time, then yes, you could request the offset from the server, and then download from there. As for how to download it, your question is very incomplete and didn't mention what protocol you were using, so I cannot help you there.

这篇关于下载mp3的最后30秒的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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