Comments (15)
i use this mpd. produce an error: Server returned 403 Forbidden (access denied)
from ksplayer.
the URL will expire after some time due to bilibili limit, can you try below script to create a test server locally?
save the code as bilimdp.py and run it with "python3 bilimpd.py", test url will be: "http://127.0.0.1/test"
from ksplayer.
This page contains the following errors:
error on line 6 at column 333: EntityRef: expecting ';'
Below is a rendering of the page up to the first error.
from ksplayer.
so sorry, fixed the code
earlier missed the 2nd replace in ".replace('http:', 'https:').replace('&', '&')" when I convert this code from js to python
from ksplayer.
Unable to parse '/Users/kingslay/Library/Developer/Xcode/DerivedData/Demo-atfnkhqcmxsbaxhiuyrjxwhemsfx/Build/Products/Debug-maccatalyst/demo-iOS.app/Contents/Resources/1.mpd' - missing root node
from ksplayer.
Oh..you are saving the mpd as local file? I didn’t test local file, I was playing URL http://127.0.0.1/test directly, and it works fine.
Thanks for your time! let me try save as local file as well
from ksplayer.
但我直接用 http://127.0.0.1/test 播放报错
KSPlayer: MEPlayerItem.swift:88 init(url:options:) | HTTP error 403 Forbidden
KSPlayer: MEPlayerItem.swift:88 init(url:options:) | Failed to open fragment of playlist 0
from ksplayer.
但我直接用 http://127.0.0.1/test 播放报错
KSPlayer: MEPlayerItem.swift:88 init(url:options:) | HTTP error 403 Forbidden
KSPlayer: MEPlayerItem.swift:88 init(url:options:) | Failed to open fragment of playlist 0
有点奇怪。。我测试了存成本地文件和直接用url都没有错误
我先把这个问题关掉了,让我再研究下,多谢!
from ksplayer.
@wanwe 你可以试着把videoAdaptable的默认值改成是false。看下是不是因为多码率切换导致的问题。
from ksplayer.
@kingslay 多谢!
from ksplayer.
不好意思,重开一下这个issue
我发现:
- 用hardware decoder的时候会报错误-8969(simulator)不知道是不是这个原因,看不明白。。哈哈
- 不用hardwae decoder的时候报上面的NAL错误,差不多同一个时间点上,看起来上相关的?
- videoAdaptable=false也不行
我试着用以前的版本试了一下,有同样的问题(同一个视频)。可能以前的时候看的别的视频都比较短,这种错误出现的几率低?
KSPlayerTime 1158.4547165532879 of 4079.0
KSPlayer: MEPlayerItemTrack.swift:312 doDecode(packet:) | Decoder did Failed : Error Domain=KSPlayerErrorDomain Code=11 "avcodec can't receive video frame" UserInfo={NSLocalizedDescription=avcodec can't receive video frame, NSUnderlyingError=0x60000187f0f0 {Error Domain=FFmpegDomain Code=-8969 "Error number -8969 occurred" UserInfo={NSLocalizedDescription=Error number -8969 occurred}}}
KSPlayer: MEPlayerItem.swift:87 init(url:options:) | detected 4 logical cores
KSPlayer: MEPlayerItem.swift:87 init(url:options:) | nal_unit_type: 7(SPS), nal_ref_idc: 3
KSPlayer: MEPlayerItem.swift:87 init(url:options:) | nal_unit_type: 8(PPS), nal_ref_idc: 3
KSPlayer: MEPlayerItemTrack.swift:315 doDecode(packet:) | VideoCodec switch to software decompression
KSPlayerTime 1158.9539455782312 of 4079.0
KSPlayerTime 4079.0 of 4079.0
KSPlayer: KSPlayerLayer.swift:100 state | playerStateDidChange - playedToTheEnd
KSPlayerState playedToTheEnd
KSPlayer true
KSPlayer error: nil
你可以再试一下这个code吗? 会自动生成bilibili_test.mpd文件,我的测试的时候, 播放没问题。
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Fri Apr 24 09:07:45 2020
@author: meow
"""
from flask import Flask, request, send_from_directory
from flask import render_template
from flask import request, jsonify, Response
import requests
import json
from lxml import etree
import os
requests.packages.urllib3.disable_warnings()
headers = {
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3970.5 Safari/537.36',
'Referer': 'https://www.bilibili.com/'
}
app = Flask(__name__, static_url_path='')
app.config['DEBUG'] = False
app.config['SEND_FILE_MAX_AGE_DEFAULT'] = 0
def GetBiliVideo(homeurl,num,session=requests.session()):
print(homeurl)
#print("=======videoinforms")
res = session.get(url=homeurl, headers=headers, verify=False)
html = etree.HTML(res.content)
#print(res.content)
videoinforms = res.content #
videoinforms = str(html.xpath('//head/script[3]/text()')[0])[20:]
print(videoinforms)
videojson = json.loads(videoinforms)
return GenMPD(videojson)
def GenMPD(resp):
dash = resp['data']['dash']
video = dash['video'][0]
audio = dash['audio'][0]
mpd_template=f"""<MPD profiles="urn:hbbtv:dash:profile:isoff-live:2012,urn:mpeg:dash:profile:isoff-live:2011" type="static" xmlns="urn:mpeg:dash:schema:mpd:2011" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:mpeg:DASH:schema:MPD:2011 DASH-MPD.xsd" minBufferTime="PT{dash['minBufferTime']}S" mediaPresentationDuration="PT{resp['data']['timelength']/1000}S">
<BaseURL>./</BaseURL>
<Period>
<AdaptationSet mimeType="video/mp4" contentType="video" subsegmentAlignment="true" subsegmentStartsWithSAP="1">
<SegmentTemplate duration="{dash['duration']}" media="{video['baseUrl'].replace('http:', 'https:').replace('&', '&')}" startNumber="1"/>
<Representation id="bilibili_{video['id']}" codecs="{video['codecs']}" bandwidth="{video['bandwidth']}" width="{video['width']}" height="{video['height']}" frameRate="{video['frameRate']}" sar="1:1"/>
</AdaptationSet>
<AdaptationSet mimeType="audio/mp4" contentType="audio" subsegmentAlignment="true" subsegmentStartsWithSAP="1">
<Accessibility schemeIdUri="urn:tva:metadata:cs:AudioPurposeCS:2007" value="6"/>
<Role schemeIdUri="urn:mpeg:dash:role:2011" value="main"/>
<SegmentTemplate duration="{dash['duration']}" media="{audio['baseUrl'].replace('http:', 'https:').replace('&', '&')}" startNumber="1"/>
<Representation id="bbb_a64k" codecs="{audio['codecs']}" bandwidth="{audio['bandwidth']}">
<AudioChannelConfiguration schemeIdUri="urn:mpeg:dash:23003:3:audio_channel_configuration:2011" value="2"/>
</Representation>
</AdaptationSet>
</Period>
</MPD>
"""
return mpd_template
def test():
av="43149523"
p=6
url=f'https://www.bilibili.com/video/av{av}'
i=p
mpd = GetBiliVideo(url+'?p='+str(i),i)
#mpd = GetBiliVideo(url,i)
with open("bilibili_test.mpd", mode="w") as fp:
fp.write(mpd)
fp.flush()
print("saved to bilibili_test.mpd")
return mpd
if __name__ == "__main__":
test()
我的测试
if let url = URL(string: "/Users/wei/projects/bilibili_test.mpd") {
objects.append(KSPlayerResource(url: url, options: KSOptions(), name: "dash视频"))
}
大部分时候问题在4:006:00或者18:0021:00之间,不知道为什么不是每次都有。。。
from ksplayer.
你是用iPhone模拟器吗?我这边播放报错"Invalid data found when processing input"。我用其他的播放器例如 vlc也是无法播放这个mpd。你有改ffmpeg吗?
from ksplayer.
Iphone/Apple tv simulator 都试了,都没问题
ffmpeg是ksplayer自带的,我没动过
好奇怪啊,你可以把生成的mpd内容贴上来吗?看看和我的有啥不一样
from ksplayer.
<MPD profiles="urn:hbbtv:dash:profile:isoff-live:2012,urn:mpeg:dash:profile:isoff-live:2011" type="static" xmlns="urn:mpeg:dash:schema:mpd:2011" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:mpeg:DASH:schema:MPD:2011 DASH-MPD.xsd" minBufferTime="PT1.5S" mediaPresentationDuration="PT4079.815S">
<BaseURL>./</BaseURL>
<Period>
<AdaptationSet mimeType="video/mp4" contentType="video" subsegmentAlignment="true" subsegmentStartsWithSAP="1">
<SegmentTemplate duration="4080" media="https://cn-zjhz3-wasu-bcache-01.bilivideo.com/upgcxcode/26/11/75641126/75641126-1-30064.m4s?e=ig8euxZM2rNcNbdlhoNvNC8BqJIzNbfqXBvEqxTEto8BTrNvN0GvT90W5JZMkX_YN0MvXg8gNEV4NC8xNEV4N03eN0B5tZlqNxTEto8BTrNvNeZVuJ10Kj_g2UB02J0mN0B5tZlqNCNEto8BTrNvNC7MTX502C8f2jmMQJ6mqF2fka1mqx6gqj0eN0B599M=&uipk=5&nbs=1&deadline=1593930405&gen=playurl&os=bcache&oi=3664551470&trid=ab7ab543945740e6a8d5f2751a748dc9u&platform=pc&upsig=a1112ca227aebab51f7f67a2150cd0fd&uparams=e,uipk,nbs,deadline,gen,os,oi,trid,platform&cdnid=20008&mid=0&orderid=0,3&agrr=0&logo=80000000" startNumber="1"/>
<Representation id="bilibili_64" codecs="avc1.64001F" bandwidth="751460" width="1280" height="720" frameRate="25" sar="1:1"/>
</AdaptationSet>
<AdaptationSet mimeType="audio/mp4" contentType="audio" subsegmentAlignment="true" subsegmentStartsWithSAP="1">
<Accessibility schemeIdUri="urn:tva:metadata:cs:AudioPurposeCS:2007" value="6"/>
<Role schemeIdUri="urn:mpeg:dash:role:2011" value="main"/>
<SegmentTemplate duration="4080" media="https://upos-sz-mirrorhw.bilivideo.com/upgcxcode/26/11/75641126/75641126-1-30280.m4s?e=ig8euxZM2rNcNbdlhoNvNC8BqJIzNbfqXBvEqxTEto8BTrNvN0GvT90W5JZMkX_YN0MvXg8gNEV4NC8xNEV4N03eN0B5tZlqNxTEto8BTrNvNeZVuJ10Kj_g2UB02J0mN0B5tZlqNCNEto8BTrNvNC7MTX502C8f2jmMQJ6mqF2fka1mqx6gqj0eN0B599M=&uipk=5&nbs=1&deadline=1593930405&gen=playurl&os=hwbv&oi=3664551470&trid=ab7ab543945740e6a8d5f2751a748dc9u&platform=pc&upsig=10414594be8e99e57058e5ad29ce44ad&uparams=e,uipk,nbs,deadline,gen,os,oi,trid,platform&mid=0&orderid=0,3&agrr=0&logo=80000000" startNumber="1"/>
<Representation id="bbb_a64k" codecs="mp4a.40.2" bandwidth="127138">
<AudioChannelConfiguration schemeIdUri="urn:mpeg:dash:23003:3:audio_channel_configuration:2011" value="2"/>
</Representation>
</AdaptationSet>
</Period>
</MPD>
from ksplayer.
神了。。我用你的iphone/appletv可以打开这个mpd,但是直接用ffplay播放就会有这个错误"Invalid data found when processing input“。。不知道什么魔法
我用ffplay吓测了一下,貌似和网络有关,这也解释了为啥同一个视频有时候有问题有时候没问题。。就是不知道为什么在浏览器里播放或者vlc播放的时候为什么一直没问题,难道可以在ffmpeg外面做什么错误处理或者自动跳过这一帧啥的?
from ksplayer.
Related Issues (20)
- 无法显示cc隐藏字幕
- Fullscreen button
- Demo App HOT 4
- 25 / 30 FPS streams stutter HOT 28
- 某些视频播放时会崩溃 HOT 3
- tvOS 端播放时卡顿会是什么原因? HOT 6
- OpenSSL and KSME Crash on tvOS HOT 10
- Slider and SwiftUI
- 在播放一个广播音频时,会一直在buffering HOT 4
- 请问有什么方式可以设置一个默认的播放速度 类似默认的播放开始位置一样 谢谢 HOT 4
- 音频是使用native原生解码吗? HOT 4
- Potentially Incorrect Uses of "available" HOT 2
- SOS,播放器播放过程中,视频流自己创建了新的控件 HOT 3
- Pauses when playing m3u8 HOT 2
- SPM无法添加 HOT 2
- How to set `subtitleDelay` now? HOT 1
- Testing new OpenSSL initialization - results and first crashes HOT 11
- 画面比例会影响pip功能
- 能否删掉默认的 User-Agent: ksplayer? HOT 1
- 如何设置字幕的 UA? HOT 10
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ksplayer.