如何在 PHP 中对视频进行编码并将该编码的视频保存在文件中,然后解码并将其保存在数据库中


how to encode video in php and save that encoded video in a file and then decode and save it in a database

我使用 html 在 Php 中编码了一个视频,现在我想解码并将其保存在 php 中。但是我不知道如何保存编码的视频以及如何获取它以进行解码。请帮助我,我在这里附加我的代码

<html>
  <video controls>
    <source type="video/mp4" src="<?php echo getEncodedVideoString('mp4','add.mp4');?>">
  </video>
</html> 
<?php
  include("connect.php");
  function getEncodedVideoString($type, $file) {
    $filename= 'data:video/' . $type . ';base64,' . base64_encode(file_get_contents($file));
    echo $filename;
?>

刚刚看到你的问题... :)您缺少一个大括号}

echo $filename; <---- Why echo $filename??? 

请改用这个:

function getEncodedVideoString($type, $file) {
    return 'data:video/' . $type . ';base64,' . base64_encode(file_get_contents($file));
}`