当前位置: 动力学知识库 > 问答 > 编程问答 >

python - Extracting a video from the network traffic and writting it to a file

问题描述:

The objective: download the videos being streamed from any website (not just youtube).

To do that, Python could monitor the network traffic, isolate the video stream, and then write that stream to a file.

I have two questions:

  • Is this doable in Python?
  • How to isolate (identify) the packets that belong to the video stream?

网友答案:

The objective is to download videos being streamed from any website.

Ok, so first thing is there are many different ways video is streamed over the internet. Some sites use Http Live Streaming, some use RTMP, multicast UDP, etc.. so your application is going to need to be versitile in handling different streaming protocols.

Python could monitor the network traffic. Perhaps tcpdump could be called from python and you could listen on a specific interface which the video traffic is flowing.

Then after you save the capture parse the capture file for specific types of packets. You will need to research how to assemble the packets from the capture to recreate the video stream.

I would pick one website and see if you can automate the downloading of the video and then once that is working pick other sites which use different streaming protocols and add that functionality to your application one at a time.

分享给朋友:
您可能感兴趣的文章:
随机阅读: