doulan0297 2017-12-14 09:24
浏览 115
已采纳

从gif转换的mp4没有在网络浏览器中显示

I am trying to convert animated GIFs to MP4 files using ffmpeg. Only this convert GIF to MP4:

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

And I can play it in my pc when download it from server, but it's didn't want to pay in browser. Browser returns me this error: enter image description here

After that GIF to MP4 converor I get one image for thumbnail image and that is works fine:

exec("ffmpeg -i " . $destinationPath . $video . ".mp4 -ss  00:00:01.000 -vframes 1 ".storage_path().$folderNameThumb."/media.png");

and it's shows me a valid frame of GIF. Can anybody help me how to fix this problem with video?

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

Here is what I get from one MP4 file (run 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

Because I use Laravel this is method for return media:

public function getGifImage(Media $media)
{
    $path = storage_path() . '/uploads/gif/' . $media->content;
    if (file_exists($path)) {
        return response()->download($path, null, [], null);
    }
}
  • 写回答

1条回答 默认 最新

  • doushi6932 2017-12-16 15:52
    关注

    Web browsers, at this time, can only decode H.264 video within MP4s. Your ffmpeg binary does not have libx264 linked, so it's defaulting to the internal MPEG-4 Part 2 video codec.

    Get a recent git binary with libx264 for your platform from

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

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

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

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 保护模式-系统加载-段寄存器