'Merge video with base64
I am merging videos in python.(ffmpeg,moviepy)
But it is very slow.
So, I am trying to encode a 1.mp4 file and a 2.mp4 file using base64 and combine them.
I have the code below.
import base64
with open('1.mp4', "rb") as videoFile:
text = base64.b64encode(videoFile.read())
with open("2.mp4", "rb") as videoFile:
texts = base64.b64encode(videoFile.read())
fh = open("dfghhffdssdf.mp4", "wb")
fh.write(base64.b64decode(text+texts))
fh.close()
I tried running the code and the video didn't merge. So I created a new code like below.
import base64
with open('1.mp4', "rb") as videoFile:
text = base64.b64encode(videoFile.read())
with open("2.mp4", "rb") as videoFile:
texts = base64.b64encode(videoFile.read())
text = str(text).replace("=","") + str(texts)
fh = open("dfghhffdssdf.mp4", "wb")
fh.write(base64.b64decode(text+texts))
fh.close()
Then, the following error is displayed.
can only concatenate str (not "bytes") to str
Therefore, if you replace the "text" variable with bytes with the bytes function, you will get the following error: string argument without an encoding
What should I do?
If that's not possible, please tell me how to quickly merge video files.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
