Merge pull request #70 from internetarchive/skipDashManifest

skip remembering dash manifests
This commit is contained in:
Noah Levitt 2017-11-08 17:12:44 -08:00 committed by GitHub
commit a24fac0194
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 79 additions and 4 deletions

View File

@ -247,14 +247,18 @@ class BrozzlerWorker:
if not 'videos' in page:
page.videos = []
for txn in ydl_spy.transactions:
if (txn['response_headers'].get_content_type().startswith('video/')
content_type = txn['response_headers'].get_content_type()
if (content_type.startswith('video/')
# skip manifests of DASH segmented video -
# see https://github.com/internetarchive/brozzler/pull/70
and content_type != 'video/vnd.mpeg.dash.mpd'
and txn['method'] == 'GET'
and txn['status_code'] in (200, 206)):
video = {
'blame': 'youtube-dl',
'url': txn['url'],
'response_code': txn['status_code'],
'content-type': txn['response_headers'].get_content_type(),
'content-type': content_type,
}
if 'content-length' in txn['response_headers']:
video['content-length'] = int(
@ -390,6 +394,9 @@ class BrozzlerWorker:
and 'response' in chrome_msg['params']
and 'mimeType' in chrome_msg['params']['response']
and chrome_msg['params']['response'].get('mimeType', '').startswith('video/')
# skip manifests of DASH segmented video -
# see https://github.com/internetarchive/brozzler/pull/70
and chrome_msg['params']['response']['mimeType'] != 'video/vnd.mpeg.dash.mpd'
and chrome_msg['params']['response'].get('status') in (200, 206)):
video = {
'blame': 'browser',

View File

@ -7,9 +7,12 @@
videos are from
http://techslides.com/sample-webm-ogg-and-mp4-video-files-for-html5
-->
<video autoplay="" muted="" id="bgvid" loop="">
<video autoplay="" muted="" id="vid1" loop="">
<source src="small.webm" type="video/webm">
<source src="small.mp4" type="video/mp4">
</video>
<video autoplay="" muted="" id="vid2" loop="">
<source src="small.mpd">
</video>
</body>
</html>

View File

@ -0,0 +1,13 @@
Steps taken to create DASH.
```
$ brew reinstall -v ffmpeg --with-libvpx
$ ffmpeg -i small.webm -c:v vp9 -f webm -dash 1 -an -vf scale=280:160 -b:v 100k -dash 1 small-video_280x160_100k.webm
$ ffmpeg -i small.webm -c:v vp9 -f webm -dash 1 -an -vf scale=140:80 -b:v 25k -dash 1 small-video_140x80_25k.webm
$ ffmpeg -i small.webm -acodec copy -vn -dash 1 small-audio.webm
$ ffmpeg -f webm_dash_manifest -i small-video_280x160_100k.webm -f webm_dash_manifest -i small-video_140x80_25k.webm -f webm_dash_manifest -i small-audio.webm -c copy -map 0 -map 1 -map 2 -f webm_dash_manifest -adaptation_sets "id=0,streams=0,1 id=1,streams=2" small.mpd
```
Don't know if the output is really correct, but youtube-dl downloads the
small.mpd, small-audio.web and small-video_280x160_100k.webm. Browser doesn't
download anything though, not even small.mpd.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -0,0 +1,34 @@
<?xml version="1.0" encoding="UTF-8"?>
<MPD
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="urn:mpeg:DASH:schema:MPD:2011"
xsi:schemaLocation="urn:mpeg:DASH:schema:MPD:2011"
type="static"
mediaPresentationDuration="PT5.58S"
minBufferTime="PT1S"
profiles="urn:webm:dash:profile:webm-on-demand:2012">
<Period id="0" start="PT0S" duration="PT5.58S" >
<AdaptationSet id="0" mimeType="video/webm" codecs="vp9" bitstreamSwitching="true" subsegmentAlignment="true" subsegmentStartsWithSAP="1">
<Representation id="0" bandwidth="110196" width="280" height="160">
<BaseURL>small-video_280x160_100k.webm</BaseURL>
<SegmentBase indexRange="92680-92727">
<Initialization range="0-628" />
</SegmentBase>
</Representation>
<Representation id="1" bandwidth="33389" width="140" height="80">
<BaseURL>small-video_140x80_25k.webm</BaseURL>
<SegmentBase indexRange="28316-28362">
<Initialization range="0-627" />
</SegmentBase>
</Representation>
</AdaptationSet>
<AdaptationSet id="1" mimeType="audio/webm" codecs="vorbis" lang="eng" audioSamplingRate="48000" bitstreamSwitching="true" subsegmentAlignment="true" subsegmentStartsWithSAP="1">
<Representation id="2" bandwidth="113515">
<BaseURL>small-audio.webm</BaseURL>
<SegmentBase indexRange="101066-101113">
<Initialization range="0-4714" />
</SegmentBase>
</Representation>
</AdaptationSet>
</Period>
</MPD>

20
tests/test_brozzling.py Normal file → Executable file
View File

@ -48,6 +48,10 @@ WARCPROX_META_420 = {
@pytest.fixture(scope='module')
def httpd(request):
class RequestHandler(http.server.SimpleHTTPRequestHandler):
def __init__(self, *args, **kwargs):
self.extensions_map['.mpd'] = 'video/vnd.mpeg.dash.mpd'
http.server.SimpleHTTPRequestHandler.__init__(self, *args, **kwargs)
def do_GET(self):
if self.path == '/420':
self.send_response(420, 'Reached limit')
@ -155,7 +159,7 @@ def test_page_videos(httpd):
with brozzler.Browser(chrome_exe=chrome_exe) as browser:
worker.brozzle_page(browser, site, page)
assert page.videos
assert len(page.videos) == 2
assert len(page.videos) == 4
assert page.videos[0] == {
'blame': 'youtube-dl',
'response_code': 200,
@ -164,6 +168,20 @@ def test_page_videos(httpd):
'url': 'http://localhost:%s/site6/small.mp4' % httpd.server_port,
}
assert page.videos[1] == {
'blame': 'youtube-dl',
'content-length': 92728,
'content-type': 'video/webm',
'response_code': 200,
'url': 'http://localhost:%s/site6/small-video_280x160_100k.webm' % httpd.server_port
}
assert page.videos[2] == {
'blame': 'youtube-dl',
'content-length': 101114,
'content-type': 'video/webm',
'response_code': 200,
'url': 'http://localhost:%s/site6/small-audio.webm' % httpd.server_port
}
assert page.videos[3] == {
'blame': 'browser',
# 'response_code': 206,
# 'content-range': 'bytes 0-229454/229455',