[英]Base64 decode incomplete file between Python and PHP
I'm sending a video file encoded with base64 on python but when i recive the video and open it there's only an image of the file. 我正在发送一个在python上用base64编码的视频文件,但是当我接收视频并打开它时,只有该文件的图像。 So my guess is that probably is not decoding properly on php.
所以我的猜测是可能无法在php上正确解码。 Here is my php code for decoding and saving the video.
这是我的PHP代码,用于解码和保存视频。
$video_encode_string = request('video');
$video_decode = base64_decode($video_encode_string);
$path = public_path().'/video/'.$device->id.'/';
$date = new \DateTime('now');
$file = fopen($path.date_format($date, 'Y-m-d H:i:s').'.mp4','wb');
fwrite($file,$video_decode);
fclose($file);
As you can see I'm working on laravel. 如您所见,我正在研究laravel。 And here is my python code for coding and sending the file.
这是我用于编码和发送文件的python代码。
with open(completed_video,'rb') as f:
video = f.read()
encode_video = base64.b64encode(video)
json = {'ip_address': '10.10.10.110',
'date': time.strftime('%Y-%m-%d %H:%M:%S'),
'video': encode_video}
r = self.api.post(json,'createvideo')
a = r.json()
print(a)
I'm working with a Raspberry Pi and recording a video from a streaming video and then sending it and when i play the video with omxplayer it works perfectly on any type of video format. 我正在与Raspberry Pi一起工作,并从流式视频中录制视频,然后将其发送,当我使用omxplayer播放视频时,它可以完美地适用于任何类型的视频格式。 I'm actually wondering if it has to decode it in chunks
我实际上在想是否必须将其解码
尝试使用: $video_decode = base64_decode(base64_encode($video_encode_string));
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.