gpt4 book ai didi

php - 从 gif 转换的 mp4 未在 Web 浏览器中显示

转载 作者:行者123 更新时间:2023-12-04 23:14:58 26 4
gpt4 key购买 nike

我正在尝试使用 ffmpeg 将动画 GIF 转换为 MP4 文件。只有这样才能将 GIF 转换为 MP4:

  exec('ffmpeg -i ' . $destinationPath . $filename . ' -movflags faststart -pix_fmt yuv420p -vf "scale=trunc(iw/2)*2:trunc(ih/2)*2" ' . $destinationPath . $newFilename);

从服务器下载时我可以在我的电脑上播放它,但它不想在浏览器中付费。浏览器向我返回此错误:
enter image description here

在 GIF to MP4 converor 之后,我得到一张缩略图图像,效果很好:
exec("ffmpeg -i " . $destinationPath . $video . ".mp4 -ss  00:00:01.000 -vframes 1 ".storage_path().$folderNameThumb."/media.png");

它向我展示了一个有效的 GIF 帧。谁能帮我解决这个视频问题?
ffprobe output
ffprobe version 2.8.13 Copyright (c) 2007-2017 the FFmpeg developers built with gcc 4.8.5 (GCC) 20150623 (Red Hat 4.8.5-16)
configuration:
libavutil 54. 31.100 / 54. 31.100
libavcodec 56. 60.100 / 56. 60.100
libavformat 56. 40.101 / 56. 40.101
libavdevice 56. 4.100 / 56. 4.100
libavfilter 5. 40.101 / 5. 40.101
libswscale 3. 1.101 / 3. 1.101
libswresample 1. 2.101 / 1. 2.101

这是我从一个 MP4 文件中得到的(运行 ffprobe filename.mp4):
 Metadata:
major_brand : isom
minor_version : 512
compatible_brands: isomiso2mp41
encoder : Lavf56.40.101
Duration: 00:00:02.16, start: 0.000000, bitrate: 593 kb/s
Stream #0:0(und): Video: mpeg4 (Simple Profile) (mp4v / 0x7634706D), yuv420p, 500x312 [SAR 1:1 DAR 125:78], 589 kb/s, 8.33 fps, 8.33 tbr, 12800 tbn, 25 tbc (default)
Metadata:
handler_name : VideoHandler

因为我使用 Laravel,所以这是返回媒体的方法:
public function getGifImage(Media $media)
{
$path = storage_path() . '/uploads/gif/' . $media->content;
if (file_exists($path)) {
return response()->download($path, null, [], null);
}
}

最佳答案

目前,Web 浏览器只能解码 MP4 中的 H.264 视频。您的 ffmpeg 二进制文件没有链接 libx264,因此它默认为内部 MPEG-4 Part 2 视频编解码器。

为您的平台获取最新的带有 libx264 的 git 二进制文件:

Linux:http://johnvansickle.com/ffmpeg/

window :http://ffmpeg.zeranoe.com/builds/

Mac OS X:http://evermeet.cx/ffmpeg/ ,
http://ffmpeg.zeranoe.com/builds/

关于php - 从 gif 转换的 mp4 未在 Web 浏览器中显示,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47809849/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com