ffmpeg convert a series of images to video - with crossfade or any other transition between every two frames

谁说胖子不能爱 提交于 2019-12-06 04:50:36

问题


I am currently able to convert a series of images to video, but I do also need to add transitions / animation in between them.

String[] ffmpegCommand = {"/data/data/mypackage/app_bin/ffmpeg", "-y",
"-qscale", "1", "-r", "" + framerate, "-i", "/data/data/mypackage/app_ipImg/image%3d.jpg",
"-t", "" + (((total_images) * delay_of_each_frame_in_seconds) + 4), //"-s",heightwidth,
"-vcodec", "libx264", "-s", "640x480",
 Environment.getExternalStorageDirectory() + "/photo_directory/myVideo.mp4"};

The above command is working for me to create video from image series

But

Now, I do want to add fade or other transition / animation to be displayed in final video before each of the frames.

I googled a lot, but didn't find any solution to this trouble, yet.

Please suggest me the way.

Thanks in advance.


回答1:


Two approaches

1) Create a video for each image/slide and add the fade-in fade-out to each one, then add the videos together. This link explains how to create a fade effect for images.

2) Use the a mixture of filters along with the -loop option as explained in this link.




回答2:


I would suggest you to find more information about Frame Blending or Motion interpolation.

This is for example used in timelapse videos to smooth the render.

  • To blend frames, use ffmpeg with the tblend filter. For example the following command can help : ffmpeg -i {input} -vf "tblend=average,framestep=2,setpts=0.50*PTS" -r {srcfps} -{encoding parameters} {output}. Replace {input} by your input file, {output} by the name of the output file, {srcfps} by your source frames per second, and -{encoding parameters} the parameters you tell ffmpeg to output. You could also add minterpolate filter to the filter stack to add some motion blur.

  • To generate new frames based on motion, the Butterflow project can help : https://github.com/dthpham/butterflow

    Features

    Makes motion interpolated videos (increase a video's frame rate by rendering intermediate frames based on motion, uses a combination of pixel-warping and blending).

    Makes smooth motion videos (simple blending between frames).

    Leverages interpolated frames to make fluid slow motion videos.



来源:https://stackoverflow.com/questions/29845019/ffmpeg-convert-a-series-of-images-to-video-with-crossfade-or-any-other-transit

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