python script to record online live streaming videos

后端 未结 3 1007
生来不讨喜
生来不讨喜 2021-02-01 10:56

i am developing a script to download online live streaming videos.

My Script:

print \"Recording video...\"
response = urllib2.urlopen(\"streaming onlin         


        
3条回答
  •  无人共我
    2021-02-01 11:28

    I don't think there is any way of doing that without constantly analysing the video, which will be way to costly. So you could take a guess of how many MB you need and once done check it's long enough. If it's too long, just cut it. Instead of guessing you could also build up some statistics of how much you need to retrieve. You could also replace the while True with:

    start_time_in_seconds = time.time()
    time_limit = 10
    while time.time() - start_time_in_seconds < time_limit:
        ...
    

    This should give you at least 10 seconds of video, unless connecting takes too much time (less then 10 seconds then) or server sends more for buffering (but that's unlikely for live streams).

提交回复
热议问题