Commit 8794e1cd authored by a.sujatanagarjuna's avatar a.sujatanagarjuna

Upload python script to encode media

parent 48dbd72b
import base64
import sys
filename = sys.argv[1]
print("Encoding "+ filename)
with open(filename, "rb") as media_file:
encoded_media = base64.b64encode(media_file.read())
print(len(encoded_media), type(encoded_media), encoded_media[:10])
extension = filename.split(".")[-1]
html_comp = "<"+("video" if extension == "mp4" else "img")+" src='"+("data:video/mp4;" if extension == "mp4" else "data:image/jpg;")+" base64, "+encoded_media.decode("ascii")+"'>"
with open(filename+".o66.html", "w") as blockfile:
blockfile.write("<html>"+html_comp+"</html>")
blockfile.close()
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment