简体   繁体   English

Android文件下载。 媒体URL不以文件名和类型结尾的问题

[英]Android file download. Media URLs that does not end with a filename and type, issue

I'm developing a download-anything app for Android and it works fine in most cases. 我正在为Android开发任何下载应用程序,并且在大多数情况下都可以正常运行。

I have come across sites that have URLs with a long hash signature (it seems) at the end of it. 我碰到过一些网址,网址的末尾带有长的哈希签名。 But the standard video app for Android, and my web browser is able to play it directly, streaming. 但是Android的标准视频应用程序以及我的网络浏览器都可以直接以流方式播放它。

I have no clue as to how to stream this to a file (progressive download?), which should be possible. 对于如何将其流式传输到文件(渐进式下载?),我一无所知。 The URL paramater after '?' “?”之后的网址参数 is used for something. 用于某事。 As Jessica pointed out the URL below is probably used for RTMP streams with rtmp://.... 正如Jessica指出的那样,以下URL可能用于带有rtmp://。的RTMP流。

URL example (host domain edited out): URL示例(已删除主机域):

 http://blush.im.54ca3830.919727.x.yesitisporn.com/videos/3gp/d/b/f/
      filthysite.com_dbf7f0a9c3913d4d0e09a36fe8ab3aba.mp4?e=1348368010&ri=1024&rs=85&h=c81c6707b13714ac65b651ba2939d94a

In the URL above there is a link to an mp4 video file. 在上面的URL中,有指向mp4视频文件的链接。 Trying to download it with this shorter URL does not work: http://blush.im.54ca3830.919727.x.yesitisporn.com/videos/3gp/d/b/f/ filthysite.com_dbf7f0a9c3913d4d0e09a36fe8ab3aba.mp4 . 尝试使用此较短的URL下载它不起作用: http://blush.im.54ca3830.919727.x.yesitisporn.com/videos/3gp/d/b/f/ filthysite.com_dbf7f0a9c3913d4d0e09a36fe8ab3aba.mp4 : http://blush.im.54ca3830.919727.x.yesitisporn.com/videos/3gp/d/b/f/ filthysite.com_dbf7f0a9c3913d4d0e09a36fe8ab3aba.mp4 Returns an empty document. 返回一个空文档。

Since popular video apps and browsers pick up these types of HTTP links just fine for playback; 由于流行的视频应用程序和浏览器会选择这些类型的HTTP链接,因此非常适合播放; there should be a standard way of getting the byte stream and write it to file. 应该有一种获取字节流并将其写入文件的标准方法。 Thanks for any help! 谢谢你的帮助!

In response to the question as originallly posed: It is quite common to add URL parameters, splitting the url from the parameters with a question-mark, and seperating the parameters with ampersands. 针对最初提出的问题:添加URL参数,用问号将URL与参数分开,并用&符号分隔参数是很常见的。 Take the substring on everything up to the first non-esecaped question-mark in the url, if a question-mark is present, otherwise use the entire string. 如果存在问号,则将所有内容的子字符串带到URL中第一个未分隔的问号之前,否则使用整个字符串。

Based on new feedback: Like I said in my comment, and as confirmed by your tests without the parameters, I think you're barking up the wrong tree to try to change the URL. 根据新的反馈:就像我在评论中说的那样,并且在没有参数的情况下进行了测试,我认为您是在树错误的树中尝试更改URL。 I would suspect the reason you can't save these specific streams is there is something different about the file format or server configuration that is different than the ones that work. 我怀疑您无法保存这些特定流的原因是文件格式或服务器配置与工作方式有所不同。 In particular, my first thought would be that perhaps those URLs are served by a Streaming Server (Example: Icecast ), and not a normal file-based HTTP server. 特别是,我首先想到的是,这些URL可能是由Streaming Server(例如: Icecast )提供的,而不是由基于文件的普通HTTP服务器提供的。 Advanatages of a streaming server include being able to on the fly serve different bandwidth versions of the streams, and instant seeking to any part of the file and so forth, but the downside for people trying to build download anything applications is those servers don't send the data as a single file, they send the data in chunks--trying not to get too crazy technical, basically, a chunk might have the first frame plus a bunch of diffs for what's on the video in the next several frames and the audio, repeat. 流服务器的优势包括能够即时提供不同带宽版本的流,即时搜索文件的任何部分等等,但是对于试图构建下载任何应用程序的人来说,不利之处在于那些服务器没有以单个文件的形式发送数据,然后以大块的形式发送数据。为了不使技术过于疯狂,基本上,一个大块可能具有第一帧,以及随后几帧中视频的差异。音频,重复。 As it does this it can throttle what quality to send depending on the latency it's seeing or the resolution of your screen, or resize what it sends if you resize the window and so forth. 这样做可以根据所看到的延迟或屏幕分辨率来限制要发送的质量,或者在调整窗口大小等情况下可以调整发送的质量。 This sort of streaming works particularly well for live events, but it is not without its advantages for recorded events as well--particularly random seeking. 这种流媒体对现场事件特别有效,但对于录制的事件(尤其是随机搜索)也并非​​没有优势。 To complicate the matter of capturing the data, some streaming servers actually transmit the video data via RTMP, RTSP, or MMS protocols instead of over HTTP. 使捕获数据的问题复杂化,一些流服务器实际上是通过RTMP,RTSP或MMS协议而不是通过HTTP传输视频数据。 HTTP Pseudo-streaming or straight HTTP downloads is going to be a lot easier to save than streaming via RTMP . HTTP伪流或直接HTTP下载将比通过RTMP流更容易保存。 Some streaming types you pretty much have to recreate the file from the individual packets or transcode it from what plays on the screen as it plays in real time. 您几乎必须使用某些流类型从单个数据包重新创建文件,或从屏幕上实时播放的内容中对其进行转码。 So you may need to spend some time learning about different streaming protocols to figure out the best way to save the specific stream you're looking at. 因此,您可能需要花一些时间来学习不同的流协议,以找出保存所需特定流的最佳方法。

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

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