问题
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