FFMpeg getting too high fps - ffmpeg

Actual fps of video is 25 but keep getting 90 fps from ffmpeg.
I'm not sure why it is detecting wrong framerate and if I set 'fps=40', fps is even getting higher.
This is my code of ffmpeg below :
var cmd = ffmpeg()
.input(data.img_path)
.format('mp4')
.videoCodec('libx264')
.audioBitrate('48k')
.audioChannels(2)
.outputOptions('-movflags', 'frag_keyframe')
.videoBitrate('1024k')
Is there any way to fix this?

Related

Video frame extraction using ffmpeg

I am stuck at a problem of frame extraction using ffmpeg. I am pointing out a given frame duration in video editors like filmora and shotkut (both coherent upto 2 places of milliseconds) and then I am using that duration in ffmpeg to extract all the frames at the native framerate. However, I don't get the perfect coherence when I see the first frame extracted and the corresponding image in editors(vlc, wondershare, filmora all same) both are different.
Please find an example of the command below :
ffmpeg -i "/mnt/sda1/Downloaded_Videos/25mm_Videos/24-12_21/0840.mp4" -ss 00:09:50.18 -to 00:10:49.22 /mnt/sda1/ExtractedFrames/25mm/24Dec_test/frame%5d_0r_0840_00095018_00095018.png
The extracted frame frame_0_0r_0840_00095018_00095018.png is different from the image or frame loaded in editors and vlc player when going to timestamp : 00:09:50.18.
Thanks for the valuable comment #Gyan. The framecount does the trick for ex.
00:00:10:20 -> signifies the 20th frame of the 10th second in the video
whereas
00:00:10.20 -> signifies the frame at the 200th milli-second for the 10th second of the video.
Conversion : Know the video fps : 00:00:10:20 = 00:00:10.(20 * 1000)/fps

Artifacts in WMP after speed-up and fps change

Trying to convert a 1 hour video with 0.02 fps, to a very short one (100 times speed-up) with somethinglike 10 fps to include in a powerpoint presentation.
I did this :
ffmpeg - input.mp4 -filter:v "setpts=0.01*PTS" -r 10 output.mp4
Works great, play nicely with VLC or SMPlayer (which I believe use ffmpeg libraries for decoding). But if played with Windows Media Player, or inserted in a powerpoint presentation, this gives a lot of artifacts...the video is almost not watchable.
Is there a way to make this watchable in powerpoint (i'm guessing the problem lies down with the video renderer used in powerpoint...)
Answering my own question after i figured it out:
ffmpeg -i input.mp4 -vf "setpts=0.01*PTS,fps=fps=1:round=near" -vcodec libx264 -profile:v baseline -level 3.0 -an out.mp4
This command will speed-up my input video 100 times, change fps from the 0.2 fps to 1fps.
I figured that specifying the profile for x264 encoder fixed my issues with windowsmedia player and powerpoint.
Apllies on Win 7, Windows MediaPlayer 12, PowerPoint 2013

ffmpeg GIF to WebM decoding issue

I'm trying to convert GIF files into WebM (ffmpeg, libvpx) and getting some strange ffmpeg behaviour.
ffmpeg is installed on my mac from MacPorts.
Converting with:
ffmpeg -i srcFilename.gif -b:v 600K -qmin 0 -qmax 50 -crf 5 destFilename.webm
if my GIF file has some frame(s) with 1-2s duration somewhere in the middle of animation like this, conversion result is fine - it's playing with the "pause" in the middle.
But if I have GIF like this with "pause" in the last frame, ffmpeg decodes it without a delay.
Have no idea why, spent some time reading ffmpeg manual, trying different conversion options with no success.
Any ideas? Thanks in advance!
I wrote an email to GIF decoder author and he answered me that he knows about this issue. It's located somewhere deep inside of ffmpeg and he has no idea how to fix it right now.
So, I'm using "dirty hack" in my project - just adding copy of last frame with zero delay to GIF file before encoding.

VLC RTP network-caching

I am streaming from my android phone's camera to my computer using RTP. I am using VLC to receive the stream. I am also using a hand written .sdp file to view the stream in VLC. When I was doing this over RTSP I could uses the command line -> vlc "rtsp://224.1.1.1:8086" --network-caching=0 to remove the 1000ms caching that would remove the delay. So now I am using -> myTest.sdp --network-caching=0 but it seems to have no affect. I have tried increasing it to 10 seconds, still no affect. It also seems that if I lower the quality of the video it will have more of a delay. What do I need to do to remove any kind of caching / buffering and always just show the latest frame as it comes in?
I couldn't make VLC to have a delay less than 1 ms. So switching to ffplay with this parameters solved the problem:
ffplay.exe rtsp://224.1.1.1:8086 -fflags nobuffer -flags low_delay -avioflags direct -fflags discardcorrupt

Get frame rate of AVI using AVFoundation

How can I get the approximate frame rate of an AVI video using AVFoundation ?
Getting nominalFrameRate from an AVAssetTrack gives a result of 0.0 but the same code works fine on any mov file I try.
In my experience, AVI files don't really work with AV Foundation. QuickTime may be the answer, however.

Resources