从图像创建视频会为某些图像格式生成黑屏视频 [英] Creating video from images produces black screen video for certain image formats

查看:88
本文介绍了从图像创建视频会为某些图像格式生成黑屏视频的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用以下命令从图像创建视频.该命令对大多数图像都适用,但是对于png图像,无法播放创建的视频,而我只会出现黑屏.

I am using below command to create video from images.The command works fine for most images but for png images the video created cannot be played and I just get a black screen.

 String[]  command = new String[]{"-y", "-f", "concat", "-safe", "0", "-i", src.getAbsolutePath(), "-vsync", "vfr", "-vf", "scale=1280:720:force_original_aspect_ratio=decrease,pad=1280:720:(ow-iw)/2:(oh-ih)/2", dest.getAbsolutePath()};

此处目标文件路径为mp4格式.我的命令怎么了?

Here destination file path has mp4 format.. Whats wrong with my command?

推荐答案

添加 format = yuv420p .当给RGB输入和输出MP4格式时,ffmpeg会选择一种与许多播放器不兼容的像素格式.

Add format=yuv420p. When given RGB input and output as MP4, ffmpeg chooses a pixel format not compatible with a lot of players.

使用

 String[]  command = new String[]{"-y", "-f", "concat", "-safe", "0", "-i", src.getAbsolutePath(), "-vsync", "vfr", "-vf", "scale=1280:720:force_original_aspect_ratio=decrease,pad=1280:720:(ow-iw)/2:(oh-ih)/2,format=yuv420p", dest.getAbsolutePath()};

这篇关于从图像创建视频会为某些图像格式生成黑屏视频的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆