title: How Do I Decode/Encode A Video To A Text File and then Back To Video?
body: <p>I want to take a video - take the video contents - and turn it into base64. Then, I want to take that text file - decode it from base64 - and then turn it back into a video. </p>
  
  <p>Currently, I have been able to turn the video into a text file, but when I try to convert it back into a video I get an empty text file instead of a video file.</p>
  
  <p>How do I fix this?</p>
  
  <pre><code>import base64
  
  
  
  with open("al.mp4", "rb") as videoFile:
      text = base64.b64encode(videoFile.read())
      print(text)
      file = open("textTest.txt", "wb") 
      file.write(text)
      file.close()
  
      fh = open("video.mp4", "wb")
      fh.write(base64.b64decode(str))
      fh.close()
  </code></pre>