写视频文件,同时播放它 [英] Writing video file and simultaneously playing it

查看:121
本文介绍了写视频文件,同时播放它的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我有趣的项目,我下载来自YouTube的视频文件,并写入到本地磁盘上的文件。同时我想打它。我们的目标是缓存本地磁盘上的文件,这样,当我想再次看视频,应用程序可以在本地播放,从而节省带宽。

In my fun project, I'm downloading video file from youtube, and writing to a file on local disk. Simultaneously I want to play it. The objective is to cache the file on local disk, so that when I want to see the video again, the app can play it locally, thereby saving bandwidth.

我用的Python 3.3.1 PyQt4中/声子 LibVLC 。到目前为止,我能够做以下事情:

I'm using Python 3.3.1, PyQt4/Phonon and LibVLC. So far, I'm able to do the following things:


  • 由于一个YouTube的的网址,我可以下载视频文件的然后的同时使用PyQt4中/声子和LibVLC,独立播放。它不是的

  • Given a youtube watch url, I can download the video file and then play it using both PyQt4/Phonon and LibVLC, independently. It is not streaming.

由于LibVLC支持流,我能够发挥流通过给定的URL。

Since LibVLC supports streaming, I'm able to play the given url through streaming.

二是非常接近我想要做的,但由于它不保存磁盘上的文件,下次我不能在本地播放同一视频。

The second is very close to what I want to do, but since it doesn't save the file on disk, next time I cannot play the same video locally.

我正在寻找一些指引,如何从这里着手。特别是,如何从它仍然被写入一个不完整的文件播放视频。

I'm looking for some guidelines as to how to proceed from here. In particular, how to play a video from an incomplete file which is still being written into.

我与任何API(即没有工作),只要它是完全没问题:

I'm completely fine with any API (that does the job) as long as it is:


  • 的Python 3.3.1(preferably)

  • C

  • C ++

和我正在寻找替代办法还,如果我目前的做法是不正确,或使问题更加困难比实际的。

And I'm looking for alternative approaches also, if my current approach is not correct or makes the problem more difficult than it actually is.

推荐答案

VLC支持不完整文件的播放,所以如果你是为一个位非阻塞I / O和/或并行code,你应该可以开始下载并有足够量已经写入之后,使用LibVLC开始播放。根据使用什么COM pression算法,您可能需要足够的缓冲区,这样总有几个留在缓冲区中的数据秒 - 如果我没有记错,一些比较现代化的算法记录三角洲和索引信息的前进落后的。

VLC supports playback of incomplete files, so if you're up for a bit of non-blocking I/O and/or parallel code, you should be able to start the download and after a sufficient amount has been written, use LibVLC to start playback. Depending on what compression algorithm is used, you may need to buffer enough so that there's always several seconds of data left in the buffer -- if I recall correctly, some of the more modern algorithms record deltas and index information going forward and backward.

您可能会得到一些警告/错误消息/例外,但我不会认为他们是致命的 - 让播放质量是你的指导

You may get a few warnings / error messages / Exceptions, but I would not assume that they're fatal -- let the playback quality be your guide!

这是有点类似一些从上面的意见建议,也涉及到了很多的东西@abarnert说,在​​较小程度上与一些在@StackedCrooked交流。

This is somewhat similar to some of the suggestions from the comments above, and is also related to a lot of what @abarnert said, to a lesser extent some of the exchange with @StackedCrooked.

这篇关于写视频文件,同时播放它的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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