[IPython-User] getting webm to run in ipynb
Dennis Daniels
dennisgdaniels@gmail....
Sun Nov 25 10:19:09 CST 2012
I'm using the notebook as my log book as I figure out how to use notebook.
I'm trying to get webm files to play directly in the browser. Five
different approaches. None worked.
Please advise re: webm playback in notebooks. Thank you.
Testing webm playback in ipynb.
Webm should run natively in Chrome... but no joy so far.
In [20]:
from IPython.core.display import HTML
video = open("/home/dennis/Videos/Webcam/2012-11-25-173506.webm, "rb").read()
video_encoded = video.encode("base64")
video_tag = '<video controls alt="test"
src="data:video/x-m4v;base64,{0}">'.format(video_encoded)
HTML(data=video_tag)
File "<ipython-input-20-54bdec7eda2e>", line 2 video =
open("/home/dennis/Videos/Webcam/2012-11-25-173506.webm, "rb").read()
^SyntaxError: invalid syntax
remove 'rb' see if that changes any thing...
In [27]:
from IPython.core.display import HTML
video = open("/home/dennis/Videos/Webcam/2012-11-25-173506.webm").read()
video_encoded = video.encode("base64")
video_tag = '<video controls alt="test"
src="data:video/x-m4v;base64,{0}">'.format(video_encoded)
HTML(data=video_tag)
---------------------------------------------------------------------------UnicodeDecodeError
Traceback (most recent call
last)<ipython-input-27-95a59987a12d> in <module>() 1 from
IPython.core.display import HTML----> 2 video =
open("/home/dennis/Videos/Webcam/2012-11-25-173506.webm").read()
3 video_encoded = video.encode("base64") 4 video_tag = '<video
controls alt="test"
src="data:video/x-m4v;base64,{0}">'.format(video_encoded) 5
HTML(data=video_tag)
/usr/lib/python3.2/codecs.py in decode(self, input, final) 298
# decode input (taking the buffer into account) 299 data
= self.buffer + input--> 300 (result, consumed) =
self._buffer_decode(data, self.errors, final) 301 # keep
undecoded input until the next call 302 self.buffer =
data[consumed:]
UnicodeDecodeError: 'utf-8' codec can't decode byte 0x82 in position
13: invalid start byte
Try again by changing base64 to base32 and setting video/webm
In [29]:
from IPython.core.display import HTML
video = open("/home/dennis/Videos/Webcam/2012-11-25-173506.webm").read()
video_encoded = video.encode("base32")
video_tag = '<video controls alt="test"
src="data:video/webm;base32,{0}">'.format(video_encoded)
HTML(data=video_tag)
---------------------------------------------------------------------------UnicodeDecodeError
Traceback (most recent call
last)<ipython-input-29-d05ae16c77cd> in <module>() 1 from
IPython.core.display import HTML----> 2 video =
open("/home/dennis/Videos/Webcam/2012-11-25-173506.webm").read()
3 video_encoded = video.encode("base32") 4 video_tag = '<video
controls alt="test"
src="data:video/webm;base32,{0}">'.format(video_encoded) 5
HTML(data=video_tag)
/usr/lib/python3.2/codecs.py in decode(self, input, final) 298
# decode input (taking the buffer into account) 299 data
= self.buffer + input--> 300 (result, consumed) =
self._buffer_decode(data, self.errors, final) 301 # keep
undecoded input until the next call 302 self.buffer =
data[consumed:]
UnicodeDecodeError: 'utf-8' codec can't decode byte 0x82 in position
13: invalid start byte
How about as just a raw html with video controls?
In [30]:
<video controls src="/home/dennis/Videos/Webcam/2012-11-25-173506.webm" />
File "<ipython-input-30-a6fa9b78cf3c>", line 1 <video controls
src="/home/dennis/Videos/Webcam/2012-11-25-173506.webm" />
^SyntaxError: invalid syntax
How about as video source?
In [31]:
<video src="/home/dennis/Videos/Webcam/2012-11-25-173506.webm" />
File "<ipython-input-31-cbbfa959575d>", line 1 <video
src="/home/dennis/Videos/Webcam/2012-11-25-173506.webm" />
^SyntaxError: invalid syntax
src webm <source src="muirbeach.webm"type='video/webm; codecs="vp8, vorbis"' >
In [34]:
<source src="/home/dennis/Videos/Webcam/2012-11-25-173506.webm" \
type='video/webm; codecs="vp8, vorbis"' >
File "<ipython-input-34-7a4abb88679d>", line 1 <source
src="/home/dennis/Videos/Webcam/2012-11-25-173506.webm" \
^SyntaxError: invalid syntax
lost and found:
0018586833669 (google)
GoogleTalk: dennisgdaniels
skype: dennisdaniels
0015047227525 (only emergencies)
EOF
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.scipy.org/pipermail/ipython-user/attachments/20121125/3071a7a2/attachment-0001.html
More information about the IPython-User
mailing list