Save Slow Video with ffmpeg on Android Devices
I want to save video in slow motion through android app. I tried to convert the video to slow motion by changing the frame rate.
I used the following commands, the first command dumps 30fps from the video to the temp directory, and then the second command uses those images to create a video at a reduced or higher frame rate, and then I delete all images from the temp directory.
ffmpeg -i input_file.mp4 -r 30/1 img%03d.png
ffmpeg -framerate 15/1 -i img%03d.png -r 30 -pix_fmt yuv420p out4.mp4
But this is a very slow operation. This happens forever, even for small videos.
I even tried to change the PTS (presentation time stamp) of the video, but it doesn't work as expected on Android phones using this command:
ffmpeg -i input.mkv -filter:v "setpts=2.0*PTS" output.mkv
as suggested here: https://trac.ffmpeg.org/wiki/How%20to%20speed%20up%20/%20slow%20down%20a%20video
Can someone suggest me how I can do this quickly. Do I need to save the frames in a temporary directory, can I pipe the result of the ffmpeg process to another ffmpeg process running concurrently using some method.
Is there any other ffmpeg command to save video in slow motion?
source to share
You just need to use below command to create slow motion video using ffmpeg -
String[] complexCommand = {"-y", "-i", inputFileAbsolutePath, "-filter_complex", "[0:v]setpts=2.0*PTS[v];[0:a]atempo=0.5[a]", "-map", "[v]", "-map", "[a]", "-b:v", "2097k", "-r", "60", "-vcodec", "mpeg4", outputFileAbsolutePath};
Check this post on my blog for a complete tutorial
source to share