Convert video to slow motion and fast forward like snapchat - android

I am trying to convert video file in slow motion or fast forward motion, just like snapchat. Tried mediacodec but didn't worked.
Can anyone tell me if there is any 3rd party library or something to accomplish my task.
Any help is highly appreciated.

You can use ffmpeg library for this
To double the speed of the video, you can use
ffmpeg -i input.mkv -filter:v "setpts=0.5*PTS" output.mkv
To slow down your video, you can use this comand
ffmpeg -i input.mkv -filter:v "setpts=2.0*PTS" output.mkv
For more details look into this link https://trac.ffmpeg.org/wiki/How%20to%20speed%20up%20/%20slow%20down%20a%20video

Related

ffmpeg: Video duration confused for some players on Android

I am using ffmpeg to scale down and compress videos to be used in Android app.
The original files are played with no problem and have no metadata issues. When I re-encode them however, the Android player is able to play them, but displays wrong durations. My app is in production and it is using official player implementations, so I wonder if there is a way to fix the corruption using ffmpeg or adding some metadata to the generated files. Hopefully that's possible, but if not - any other possible fixes will be highly appreciated :)
My ffmpeg command is complex, including scaling and encoding but I can confirm this issue is reproducible on my end with the simplest ffmpeg -i video.mp4 -c:v libx264 videogen.mp4 command.
I'm leaving links to the two files if that's helpful for reference.
video.mp4
videogen.mp4
Any ideas what could be causing this and how to fix it?
Player issues showcase:
video.mp4 (original)
videogen.mp4 (re-encoded)
After some testing I found out that the player was playing fine files with the following metadata:
major_brand=mp42
encoder=Lavf58.24.101
So I used ffmpeg -movflags use_metadata_tags to set the working metadata :)

Record video with overlay pager android

I am working on one of my app in android which have functionality to capture video with overlay view pager. I tried take snapshot of view of every moment and after that use frames to make video using opencv and ffmpeg plugin but still there is no success . I need solution that how can i achieve this thing .
Sorry for unclearness , i am new here.
Please guide me solution anyone .
Here is what i want to achive
Did you try ffmpeg -r 1/5 -start_number 2 -i img%03d.png -c:v libx264 -r 30 -pix_fmt yuv420p out.mp4?
I guess that's what you want.
I actually do this things with Blender 3D software but It's a little bit technical.

How crop and scale a video programmatically without ffmpeg

i would like to crop and scale a recorded video without the use of ffmpeg, is there any way?
I would avoid to use ffmpeg to not have compatibility problems.
Thanks guys
Ummm... try to use gstreamer instead of ffmpeg. BTW, what is wrong with ffmpeg?
For example, this is gstreamer conveyor
gst-launch v4l2src ! video/x-raw-yuv,width=640,height=480,framerate=15/1 ! aspectratiocrop aspect-ratio=16/9 ! \ ffmpegcolorspace ! xvimagesink
It takes video from the webcam, changes aspect, then shows output to user.

Video orientation using ffmpeg

How to get video orientation using ffmpeg? I am using ffmpeg on android.
It seems ffmpeg not taking care automatically, in android lower versions I could not find api, so trying using ffmpeg. In android there is metadataretriver but it's api level is 17.
Please suggest way for this.
Are you looking for the syntax of the transpose filter? For instance, to rotate the input by 90 degrees counter-clockwise:
ffmpeg -i input -vf "transpose=1" output
If not, could you detail your request a little bit more?

Adding audio to a video file

I'm trying to add a wav file as background to an mp4 video and have no idea where to start...I've tried looking in to the "Video Editor" API but found nothing useful...
Is it worth using ffmpeg in some form on device or is there a way I'm overlooking? (and if so are there any good tutorials for a noob?)
Thanks in advance...
Yes ffmpeg is good enough
ffmpeg -i in.mp4 -i in.wav -acodec <give your codec> -vcodec copy out.mp4
should do the trick and works for me.

Categories

Resources