【问题标题】:RTSP youtube linkRTSP youtube 链接
【发布时间】:2012-01-03 17:24:09
【问题描述】:

我已经遍及谷歌,但无法从 youtube 视频中获取 rtsp 链接,请提供 VIDEO_ID。

我对如何使用该 ID 并解析 google 以获取链接感到困惑。

感谢您的时间和精力。

【问题讨论】:

    标签: android youtube rtsp


    【解决方案1】:

    我发现了这个blog entry,也许它是一个起点。如果您继续关注<id> 链接,您将获得另一种格式,您应该可以在其中找到 rtsp 链接。

    编辑: 在浏览了 WarrenFaith 发布的内容之后。给他的道具

    这是获取 rtsp 链接的方式。

    1. 提出请求
    2. 为 3gp 内容解析该数据
      • 它还为您提供评级以及您可能想要的所有好东西。

    希望对大家有所帮助

    【讨论】:

    • "Q-GLuydiMe4" id不会通过这种方式打开
    • Q-GLuydiMe4 id不会通过这种方式打开?为什么会这样,你知道这个问题吗?
    • 是的,它运行良好,但 RTSP 不是由这个 id 生成的。我检查并发现应用程序控制类似于“此视频的联合发布受到限制”。这就是原因,但我需要对这件事进行排序。有没有办法在android中允许这个权限
    • 如果您使用 nintendo dsi 用户代理,视频将是 rtsp 视频的链接。但是它非常压缩
    • 此功能已被禁用
    【解决方案2】:
    Note:Working only android mobile(Not in Tablate)
    
    private class YourAsyncTask extends AsyncTask<Void, Void, Void>`enter code here`
        {
            ProgressDialog progressDialog;
    
            @Override
            protected void onPreExecute()
            {
                super.onPreExecute();
                progressDialog = ProgressDialog.show(AlertDetail.this, "", "Loading Video wait...", true);
            }
    
            @Override
            protected Void doInBackground(Void... params)
            {
                try
                {
                    String url = "http://www.youtube.com/watch?v=1FJHYqE0RDg";
                    videoUrl = getUrlVideoRTSP(url);
                    Log.e("Video url for playing=========>>>>>", videoUrl);
                }
                catch (Exception e)
                {
                    Log.e("Login Soap Calling in Exception", e.toString());
                }
                return null;
            }
    
            @Override
            protected void onPostExecute(Void result)
            {
                super.onPostExecute(result);
                progressDialog.dismiss();
    /*
                videoView.setVideoURI(Uri.parse("rtsp://v4.cache1.c.youtube.com/CiILENy73wIaGQk4RDShYkdS1BMYDSANFEgGUgZ2aWRlb3MM/0/0/0/video.3gp"));
                videoView.setMediaController(new MediaController(AlertDetail.this));
                videoView.requestFocus();
                videoView.start();*/            
                videoView.setVideoURI(Uri.parse(videoUrl));
                MediaController mc = new MediaController(AlertDetail.this);
                videoView.setMediaController(mc);
                videoView.requestFocus();
                videoView.start();          
                mc.show();
            }
    
        }
    
    public static String getUrlVideoRTSP(String urlYoutube)
        {
            try
            {
                String gdy = "http://gdata.youtube.com/feeds/api/videos/";
                DocumentBuilder documentBuilder = DocumentBuilderFactory.newInstance().newDocumentBuilder();
                String id = extractYoutubeId(urlYoutube);
                URL url = new URL(gdy + id);
                HttpURLConnection connection = (HttpURLConnection) url.openConnection();
                Document doc = documentBuilder.parse(connection.getInputStream());
                Element el = doc.getDocumentElement();
                NodeList list = el.getElementsByTagName("media:content");///media:content
                String cursor = urlYoutube;
                for (int i = 0; i < list.getLength(); i++)
                {
                    Node node = list.item(i);
                    if (node != null)
                    {
                        NamedNodeMap nodeMap = node.getAttributes();
                        HashMap<String, String> maps = new HashMap<String, String>();
                        for (int j = 0; j < nodeMap.getLength(); j++)
                        {
                            Attr att = (Attr) nodeMap.item(j);
                            maps.put(att.getName(), att.getValue());
                        }
                        if (maps.containsKey("yt:format"))
                        {
                            String f = maps.get("yt:format");
                            if (maps.containsKey("url"))
                            {
                                cursor = maps.get("url");
                            }
                            if (f.equals("1"))
                                return cursor;
                        }
                    }
                }
                return cursor;
            }
            catch (Exception ex)
            {
                Log.e("Get Url Video RTSP Exception======>>", ex.toString());
            }
            return urlYoutube;
    
        }
    
    protected static String extractYoutubeId(String url) throws MalformedURLException
        {
            String id = null;
            try
            {
                String query = new URL(url).getQuery();
                if (query != null)
                {
                    String[] param = query.split("&");
                    for (String row : param)
                    {
                        String[] param1 = row.split("=");
                        if (param1[0].equals("v"))
                        {
                            id = param1[1];
                        }
                    }
                }
                else
                {
                    if (url.contains("embed"))
                    {
                        id = url.substring(url.lastIndexOf("/") + 1);
                    }
                }
            }
            catch (Exception ex)
            {
                Log.e("Exception", ex.toString());
            }
            return id;
        }
    

    【讨论】:

      【解决方案3】:

      获取 rtsp 链接的简单方法应该可以轻松移植到任何平台。

      String video_id = "1FJHYqE0RDg";
      String gdata = "http://gdata.youtube.com/feeds/api/videos/";
      String youtube_response = Util.getUrlResponse(gdata+video_id); // just a simple HTTP GET
      String rtsp_link = "rtsp:"+ StringUtils.split(StringUtils.split(youtube_response, "rtsp:")[1], ".3gp")[0] + ".3gp";
      

      【讨论】:

      • "Q-GLuydiMe4" id不会通过这种方式打开。为什么?
      • Q-GLuydiMe4 id不会通过这种方式打开?你能解释一下吗?
      • 可能视频有其他限制。
      • 所以,在我们这边,我们不能播放这个视频,但这个限制不在 iOs 和其他安卓应用程序中。他们是如何使用这个东西的。我有点好奇这个???你知道如何解决吗?
      • 并非如此,我们只能看到 google 公开的内容。不知道为什么这个视频没有像其他视频一样显示 rtsp 链接。您可以更深入地探索 youtube api 以找到原因。
      【解决方案4】:

      如果您想获取 YOUTUBE RTSP 链接,则无需程序

      1. 转到 www.youtube.com

      2. 选择你想要的rtsp链接的视频......

      3. 转到该视频的网址.....

      4. 从 url 获取 id,即http://www.youtube.com/watch?v=6acRHWnfZAE (((id从“=”开始,一直到最后......在上面的例子中,6acRHWnfZAE是示例中视频的id

      5. 现在打开http://gdata.youtube.com/feeds/api/videos/,在此网址之后粘贴您的视频ID......

      6. 将打开一个页面

      7. 现在在该页面中搜索 media:content 至少会有 3 个 属性 一个是 HTTP n 另外两个是 rtsp (format 1 n format 6); 根据我的经验格式 1 仅适用于视频,,,, n 格式 6 适用于音频和视频

      【讨论】:

      • 来自 youtube 的回复:不再可用
      猜你喜欢
      • 2012-08-04
      • 2015-10-14
      • 1970-01-01
      • 2011-08-08
      • 1970-01-01
      • 2015-10-30
      • 1970-01-01
      • 1970-01-01
      • 2011-12-17
      相关资源
      最近更新 更多