获取 BrightCove 视频的 URL 以供下载和流式传输

Posted

技术标签:

【中文标题】获取 BrightCove 视频的 URL 以供下载和流式传输【英文标题】:Get URL of BrightCove video for download and Stream 【发布时间】:2016-04-08 08:17:44 【问题描述】:

我正在创建一个 android 应用程序,我想在其中播放以及从 BrightCove 下载视频,现在问题是 BrightCove 有自己的播放器,即 com.brightcove.player.view.BrightcoveExoPlayerVideoView 我无法使用。我必须在 Android Native MediaPlayer 中播放视频。

我已经检查了所有的文档,他们只是一次又一次地提供这样的东西

  EventEmitter eventEmitter = brightcoveVideoView.getEventEmitter();
    Catalog catalog = new Catalog(eventEmitter, getString(R.string.account), getString(R.string.policy));

    catalog.findVideoByID(getString(R.string.videoId), new VideoListener() 

      // Add the video found to the queue with add().
      // Start playback of the video with start().
      @Override
        public void onVideo(Video video) 
          brightcoveVideoView.add(video);
          brightcoveVideoView.start(); 
        

      @Override
        public void onError(String s) 
          throw new RuntimeException(s);
        
    );

我怎样才能获得播放和下载的确切网址?

当使用 servercalls/API_tester 在 BrightCove 上搜索视频时,它会返回一些 this

"id": 1520880903001, "name": "Space-Galaxy", "adKeys": null, "shortDescription": "用作访问视频内容的示例 媒体 API -- 不要删除", "longDescription": null, "creationDate": "1332264917716", "publishedDate": "1332264917716", “lastModifiedDate”:“1441607273772”,“linkURL”: "http://support.brightcove.com/en/docs/accessing-video-content-media-api", "linkText": "使用媒体 API 访问视频内容", "tags": [ "newtag" ], "videoStillURL": "http://brightcove.vo.llnwd.net/e1/pd/57838016001/57838016001_1520916808001_vs-1520911645001.jpg?pubId=57838016001", “缩略图网址”: "http://brightcove.vo.llnwd.net/e1/pd/57838016001/57838016001_1520916809001_th-1520911645001.jpg?pubId=57838016001", “referenceId”:“1520880903001”,“长度”:20000,“经济学”: “AD_SUPPORTED”,“playsTotal”:102,“playsTrailingWeek”:0, “FLVURL”: “rtmp://brightcove.fcod.llnwd.net/a500/e1/uds/rtmp/ondemand/&mp4:57838016001/57838016001_1520916807001_Space-Galaxy.mp4&1460095200000&a99dcabb0f88cdf8d21b3a5778da8e06” “演绎”:[ “仅音频”:错误, “controllerType”:“默认”, "displayName": "Space-Galaxy.mp4", “编码率”:800000, “框架高度”:360, “框架宽度”:640, “身份证”:1520959065001, “referenceId”:空, “远程流名称”:空, “remoteUrl”:空, “大小”:1829449, “上传时间戳米利斯”:1332267195355, “网址”:“rtmp://brightcove.fcod.llnwd.net/a500/e1/uds/rtmp/ondemand/&mp4:57838016001/57838016001_1520959065001_Space-Galaxy.mp4&1460095200000&a99dcabb0f88cdf8d021b3a5778” "videoCodec": "H264", "videoContainer": "MP4", “视频时长”:20000 , “仅音频”:错误, “controllerType”:“默认”, "displayName": "Space-Galaxy.mp4", “编码率”:1800000, “框架高度”:720, “框架宽度”:1280, “身份证”:1520962209001, “referenceId”:空, “远程流名称”:空, “remoteUrl”:空, “尺寸”:4265519, “上传时间戳米利斯”:1332267361480, “网址”:“rtmp://brightcove.fcod.llnwd.net/a500/e1/uds/rtmp/ondemand/&mp4:57838016001/57838016001_1520962209001_Space-Galaxy.mp4&1460095200000&a99dcabb0f88cdf8d021b3a5778” "videoCodec": "H264", "videoContainer": "MP4", “视频时长”:20000 , “仅音频”:错误, “controllerType”:“默认”, "displayName": "Space-Galaxy.mp4", “编码率”:1200000, “框架高度”:404, “框架宽度”:720, “身份证”:1520962169001, “referenceId”:空, “远程流名称”:空, “remoteUrl”:空, “大小”:2777863, “上传时间戳米利斯”:1332267330633, “网址”:“rtmp://brightcove.fcod.llnwd.net/a500/e1/uds/rtmp/ondemand/&mp4:57838016001/57838016001_1520962169001_Space-Galaxy.mp4&1460095200000&a99dcabb0f88cdf8d021b3a5778” "videoCodec": "H264", "videoContainer": "MP4", “视频时长”:20000 , “仅音频”:错误, “controllerType”:“默认”, "displayName": "Space-Galaxy.mp4", “编码率”:314758, “框架高度”:224, “框架宽度”:400, “身份证”:1520959023001, “referenceId”:空, “远程流名称”:空, “remoteUrl”:空, “尺寸”:690193, “上传时间戳米利斯”:1332267165343, “url”:“rtmp://brightcove.fcod.llnwd.net/a500/e1/uds/rtmp/ondemand/&mp4:57838016001/57838016001_1520959023001_Space-Galaxy.mp4&1460095200000&a99dcabb0f88cdf8d021b3a5778” "videoCodec": "H264", "videoContainer": "MP4", “视频时长”:20000 , “仅音频”:错误, “controllerType”:“默认”, "displayName": "Space-Galaxy.mp4", “编码率”:500000, “框架高度”:268, “框架宽度”:480, “身份证”:1520916807001, “referenceId”:空, “远程流名称”:空, “remoteUrl”:空, “大小”:1126642, “上传时间戳米利斯”:1332265138822, “网址”:“rtmp://brightcove.fcod.llnwd.net/a500/e1/uds/rtmp/ondemand/&mp4:57838016001/57838016001_1520916807001_Space-Galaxy.mp4&1460095200000&a99dcabb0f88cdf8d021b3a5778” "videoCodec": "H264", "videoContainer": "MP4", “视频时长”:20000 , “仅音频”:错误, “controllerType”:“默认”, "displayName": "Space-Galaxy.mp4", “编码率”:129761, “框架高度”:224, “框架宽度”:400, “身份证”:1520953533001, “referenceId”:空, “远程流名称”:空, “remoteUrl”:空, “大小”:227983, “上传时间戳米利斯”:1332266955420, “网址”:“rtmp://brightcove.fcod.llnwd.net/a500/e1/uds/rtmp/ondemand/&mp4:57838016001/57838016001_1520953533001_Space-Galaxy.mp4&1460095200000&a99dcabb0f88cdf8d021b3a5778” "videoCodec": "H264", "videoContainer": "MP4", “视频时长”:20134 ], "FLVFullLength": “仅音频”:错误, “controllerType”:“默认”, "displayName": "Space-Galaxy.mp4", “编码率”:500000, “框架高度”:268, “框架宽度”:480, “身份证”:1520916807001, “referenceId”:空, “远程流名称”:空, “remoteUrl”:空, “大小”:1126642, “上传时间戳米利斯”:1332265138822, “网址”:“rtmp://brightcove.fcod.llnwd.net/a500/e1/uds/rtmp/ondemand/&mp4:57838016001/57838016001_1520916807001_Space-Galaxy.mp4&1460095200000&a99dcabb0f88cdf8d021b3a5778” "videoCodec": "H264", "videoContainer": "MP4", “videoDuration”:20000 ,“videoFullLength”: “仅音频”:错误, “controllerType”:“默认”, "displayName": "Space-Galaxy.mp4", “编码率”:500000, “框架高度”:268, “框架宽度”:480, “身份证”:1520916807001, “referenceId”:空, “远程流名称”:空, “remoteUrl”:空, “大小”:1126642, “上传时间戳米利斯”:1332265138822, “网址”:“rtmp://brightcove.fcod.llnwd.net/a500/e1/uds/rtmp/ondemand/&mp4:57838016001/57838016001_1520916807001_Space-Galaxy.mp4&1460095200000&a99dcabb0f88cdf8d021b3a5778” "videoCodec": "H264", "videoContainer": "MP4", “视频持续时间”:20000

它有一些链接,如

rtmp://brightcove.fcod.llnwd.net/a500/e1/uds/rtmp/ondemand/&mp4:57838016001/57838016001_1520959023001_Space-Galaxy.mp4&1460095200000&a99dcabb0f88cdf8d26

但没有在 MediaPlayer 上播放任何东西。可能是因为rtmprmtp 我可能不得不使用 Vitamio 但我不能因为我被限制使用本机 MediaPlayer。

ios 上,我可以使用:BCOVPlaybackService 获取网址,但在 android 中没有这样的类。

谢谢

【问题讨论】:

【参考方案1】:

好的,这就是我获取 URL 的方式

 EventEmitter eventEmitter = player.getEventEmitter();
            Catalog catalog = new Catalog(eventEmitter, account, privacy);
            catalog.findVideoByID(video_brightcove_id, new VideoListener() 
                @Override
                public void onVideo(Video video) 

                    Map<DeliveryType, SourceCollection> map = video.getSourceCollections();
                    Set<DeliveryType> st = map.keySet();
                    SourceCollection sor = map.get(DeliveryType.valueOf("MP4"));
                    Set<Source> se = sor.getSources();
                    Object[] ar = se.toArray();
                    Source hp = (Source) ar[0];
                    Map<String, Object> ma = hp.getProperties();
                    String url = (String) ma.get("url");
               ////this is the video url 

                

                @Override
                public void onError(String s) 

                    Log.e("Error ", s);
                
            );

谢谢:)

【讨论】:

受 DRM 保护的内容会怎样?它是否还包含 MP4 的交付类型 不确定原因,但它包含 MP4 的交付类型。

以上是关于获取 BrightCove 视频的 URL 以供下载和流式传输的主要内容,如果未能解决你的问题,请参考以下文章

Cuda ffmpeg 上的视频解码器

javascript 触发Brightcove视频

Brightcove助力企业视频内容无缝直达中国

BRIGHTCOVE推出面向营销人员的BRIGHTCOVE营销工作室,以提高知名度和营收

Brightcove推出视频流媒体解决方案Communications Studio,提升内部传播能力

iOS:BrightCove 原生播放器在第二次播放相同的视频时抛出 `kBCOVPlaybackSessionLifecycleEventError`