Creating video from images produces black screen video for certain image formats [duplicate]

落花浮王杯 提交于 2020-01-30 08:19:36

问题


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()};

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


回答1:


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

Use

 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()};


来源:https://stackoverflow.com/questions/50597344/creating-video-from-images-produces-black-screen-video-for-certain-image-formats

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!