duanhun3273 2013-05-23 18:20
浏览 260

使用PHP下载视频文件

If you download an Youtube video using Internet Download Manager(IDM) you get the actual download url from properties>address and the url looks like following.

http://r8---sn-o097zne6.c.youtube.com/videoplayback?cp=U0hVTlFMVF9GU0NONV9JRlhFOk12VEU5YTJHQ0hS&expire=1369116419&fexp=934400%2C912519%2C930806%2C914010%2C916625%2C910822%2C924605%2C901208%2C929123%2C929915%2C929906%2C925714%2C929919%2C929119%2C931202%2C932802%2C928017%2C912518%2C911416%2C906906%2C904476%2C919373%2C906836%2C933701%2C900345%2C926403%2C912711%2C929606%2C910075%2C906098&id=16e6330cce76eecc&ip=74.115.0.148&ipbits=8&itag=22&key=yt1&ms=au&mt=1369093406&mv=m&newshard=yes&ratebypass=yes&signature=602A934CA39B8ECB2B324F56A280332ED5679A8B.2D2BF1C7A3E8B2139A4566198AFD3A3BAEEAC47F&source=youtube&sparams=cp%2Cid%2Cip%2Cipbits%2Citag%2Cratebypass%2Csource%2Cupn%2Cexpire&sver=3&upn=89uxLgRVS_U&cpn=8pfKhlVRglcZw_W9

if I put the following code in a file and click "Save As" the video starts downloading.

<a href="$link">Download Video</a> // $link = the above link

Now I have a file called video.php. What I am trying to do is when I will run the video.php file my code will start downloading the video from the url (like above url) automatically. Is this even possible? If then could you please tell me how to do that?

I have tried to download using PHP but the page keeps loading and loading and does not show anying. The code I tried is following:

 $ch = curl_init ($link); // $link = the above link
 curl_setopt ($ch, CURLOPT_RETURNTRANSFER, true);
 curl_exec ($ch);
  • 写回答

1条回答 默认 最新

  • dongyongyin5339 2013-05-23 19:19
    关注

    Since direct connection to videos on port 80 is forbidden you would need to use some other way. I can imagine using some kind of background RTMP streamer on port 554 which is usually open, since is used for Flash video as default.

    RTMPDump can do the job -> http://rtmpdump.mplayerhq.hu/

    评论

报告相同问题?

悬赏问题

  • ¥15 关于smbclient 库的使用
  • ¥15 微信小程序协议怎么写
  • ¥15 c语言怎么用printf(“\b \b”)与getch()实现黑框里写入与删除?
  • ¥20 怎么用dlib库的算法识别小麦病虫害
  • ¥15 华为ensp模拟器中S5700交换机在配置过程中老是反复重启
  • ¥15 java写代码遇到问题,求帮助
  • ¥15 uniapp uview http 如何实现统一的请求异常信息提示?
  • ¥15 有了解d3和topogram.js库的吗?有偿请教
  • ¥100 任意维数的K均值聚类
  • ¥15 stamps做sbas-insar,时序沉降图怎么画