我需要能够将.mp4转换为明文。我不是指语音,我是说把它转换成字符,然后再转换回来。我看了几个程序,但他们只转换演讲,我需要整个事情变成一个文本文件,或有字符是可复制到一个文本文件,并放回程序中,使其成为视频。我确实查看了其他讨论,但它们似乎并不适合。谢谢!
发布于 2017-08-11 06:35:59
尝试uu库:
import uu
uu.encode('video.mp4', 'video.txt')
uu.decode('video.txt', 'video-copy.mp4')发布于 2017-08-11 06:16:31
将文件读入明文
import base64
# Load this source file and strip the header. You can try removing .split('#end_pymotw_header')[1] from end.
initial_data = open("video.mp4", 'rt').read().split('#end_pymotw_header')[1]
encoded_data = base64.b64encode(initial_data)
num_initial = len(initial_data)
padding = { 0:0, 1:2, 2:1 }[num_initial % 3]
print '%d bytes before encoding' % num_initial
print 'Expect %d padding bytes' % padding
print '%d bytes after encoding' % len(encoded_data)
print
#print encoded_data
for i in xrange((len(encoded_data)/40)+1):
print encoded_data[i*40:(i+1)*40]正在写回mp4文件。
temp_path = tempfile.gettempdir()
video_binary_string = 'AAAAIGZ0eXBpc29tAAACAGlzb21p...' #it's base64.b64encode text
decoded_string = base64.b64decode(video_binary_string)
with open(temp_path+'/video.mp4', 'wb') as wfile:
wfile.write(decoded_string)单击here了解更多详细信息。
https://stackoverflow.com/questions/45623885
复制相似问题