失败后,浸出物含量找回视频和使用的base64编码PHP它

问题描述 投票:4回答:2

我曾尝试后,我得到的内容,然后我Base64编码,它要回我的视频(MP4),但我的视频仍无法播放。我曾与图像尝试下面的代码和它的作品。为什么它不与影片吗?

<?php
    $con=file_get_contents("kecak.mp4"); //kecak.mp4 work to play with <video> </video> tag
    $en=base64_encode($con);
    $binary_data='data:'.$mime.';base64,'. $en ;
?>

<video width="320" height="240" controls="controls">
    <source src="<?php echo $binary_data ?>" type="video/mp4" /> 
    Your browser does not support the video tag.
</video>
php html5 video base64 mp4
2个回答
1
投票

我相信这是对BASE64_ENCODE长度限制。当输入太长,不输出任何东西。我没有你的视频或它的细节进行测试,但我认为chunk_split可以帮助你在这里:http://nl.php.net/manual/en/function.chunk-split.php


0
投票
   // works for me
    $img_str = base64_encode(file_get_contents($filename)); // encode file
    header("Access-Control-Allow-Origin: *"); // allow all CORS // dev only
    header("Content-Type: text/plain"); // resp file header
    echo($img_str);  // echo base64 string
© www.soinside.com 2019 - 2024. All rights reserved.