【问题标题】:how to encode video in php and save that encoded video in a file and then decode and save it in a database如何在php中编码视频并将编码的视频保存在文件中,然后解码并将其保存在数据库中
【发布时间】:2013-09-13 08:11:04
【问题描述】:

我已经使用 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;
?>

【问题讨论】:

  • 视频>
  • 我在您的问题中添加了您的代码以提高可读性
  • @Diego C Nascimento:不,我只是想再次以 .mp4 格式对其进行解码,并且应该存储在现有数据库中的某个位置
  • 哦,那么请告诉我将编码视频存储在文件中的方法。
  • @Diego C Nascimento 很抱歉让您感到困惑,但实际上我的情况是我将从 android 应用程序获取编码视频,然后我必须解码该视频并存储在 myserver 上。出于虚拟目的,我试图对其进行编码,然后想要解码并将该视频存储在我的数据库中。希望您了解我的情况并给我积极的结果..

标签: php android html


【解决方案1】:

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

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

改用这个:

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

【讨论】:

    猜你喜欢
    • 2013-02-07
    • 2022-01-11
    • 1970-01-01
    • 2020-12-30
    • 1970-01-01
    • 2021-09-12
    • 1970-01-01
    • 2016-10-20
    • 1970-01-01
    相关资源
    最近更新 更多