Artifacts in WMP after speed-up and fps change - ffmpeg

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

Related

Cross device h264 compatible html5 video

I'm trying to serve a large video of timelapses generated from a series of images.
Using FFmpeg I have encoded the video as an h264 mp4.
ffmpeg -framerate 24 -i "/app/download/%d.jpeg" -c:v libx264 -crf 23 -preset fast -tune animation -report -vf "format=yuv420p" -y /app/output.mp4
I'm running into compatibility issues where the videos are not playable on iOS (safari) as well as on Windows (all browsers except chrome). Where I'm getting the following error:
Error Code: NS_ERROR_DOM_MEDIA_FATAL_ERR (0x806e0005) Details: mozilla::MediaResult __cdecl mozilla::WMFVideoMFTManager::ValidateVideoInfo(void): Can't decode H.264 stream because its resolution is out of the maximum limitation
See the full FFmpeg log here: https://pastebin.com/QUEPh3q2
I'm just looking for some resource or knowledge of how to encode my media for maximum compatibility while still preserving high quality and resolution.
Problem:
Which options I should be using in FFmpeg to maximize compatibility?
From comments: "My videos are maximally of size 4056x3040 or 3040x4056".
I don't have Apple device(s) but you might be hitting some image size limitation on Windows.
Firefox uses the built-in Windows H264 decoder where the maximum height is 2304.
Replace the old command:
ffmpeg -framerate 24 -i "/app/download/%d.jpeg" -c:v libx264 -crf 23 -preset fast -tune animation -report -vf "format=yuv420p" -y /app/output.mp4
With this new one:
ffmpeg -framerate 24 -i "/app/download/%d.jpeg" -vf scale=3069:2300,setsar=1:1 -c:v libx264 -pix_fmt yuv420p -profile:v high -crf 23 -preset fast -movflags +faststart -report -y /app/output.mp4
The above command changes the size to 3069x2300 (within Windows resolution limits) but I recommend a smaller size like 1441x1080 for maximum device / O.S / browser compatibility.
I would leave out -tune animation, add it back if its removal affects your specific image quality.
Now added is +faststart which allows the MP4 header to be at front of file (usually is placed last at back) meaning playback can begin without first downloading all videos just to reach header data (which has the decoder settings needed to begin playback).
I think your bigger issue will be trying to send 4056x3040 video over mobile networks. You're going to have lots of stalling and poor playback over many types of connections that cannot support the bandwidth you'll need. Nor does a mobile device have a big enough screen to actually playback the video dimensions you would be sending.
I'd suggest you look at HLS streaming - and adaptive bitrates. That way, you can create your huge version, a 1080p version, a 720p version (etc.) the video player will deliver the correctly sized video to the device - no wasted data/pixels, fewer stalls, and it still looks great.

ffmpeg scale down video dynamically (squeeze-back) or zoompan out to smaller than original

I have 2 videos, I'm trying to overlay one on top of the other, and have it shrink down in an animated fashion until it appears like a picture-in-picture setup. Then, after a few seconds it should scale back up.
This is what I am trying to achieve (these would be videos, not images):
This is the closest I've been able to get, but, crucially, zoompanning "out" (as opposed to "in") does not appear to work; so, of course, this does not work:
ffmpeg -i bg.mov -i top.mov -filter_complex "[0:v]zoompan=z='pzoom-0.1':d=1, setpts=PTS-STARTPTS[top]; [1:v]setpts=PTS-STARTPTS+2/TB, scale=1920x1080, format=yuva420p,colorchannelmixer=aa=1.0[bottom]; [top][bottom]overlay=shortest=0" -vcodec libx264 out.mp4
Is this achievable with ffmpeg?
Use the scale filter with animation, available since v4.3.
Here's something to get you started. This will expand the top layer from 480 px height to 1080 height in 2 seconds and then back to 480 px in 2 seconds.
ffmpeg -i bg.mov -i top.mov -filter_complex "[0:v]scale=1920x1080,setpts=PTS-STARTPTS[bg]; [1:v]setpts=PTS-STARTPTS+2/TB, scale=-1:'480+600*abs(sin((t-2)*2*PI/8))':eval=frame[top]; [bg][top]overlay" -vcodec libx264 out.mp4

How to remove ffmpeg artifacts in the output timelapse video?

I used a number of jpeg files to create a timelapse video with ffmpeg. Individually they are visually ok.
These source images are captured by a mirrorless DSL camera in JPEG format.
If I upload the timelapsevideo to youtube, the video is clear and without any artifact: https://www.youtube.com/watch?v=Qs-1ahCrb0Y
However if I play the video file locally on MacOS in Photo or Quicktime apps or in iOS, there are artifacts in the video. Here are some of the examples:
1.
2.
This is the ffmpeg command I used to generate the video:
ffmpeg -framerate 30 -pattern_type glob -i "DSCF*.JPG" -pix_fmt yuv420p -profile baseline output.mp4
What additional parameter I can use to remove those artifacts?
Edit:
File info
The video plays without issue in VLC.
The H.264 codec standard defines levels. The level represents the resources required by a decoder to smoothly process a stream. Usually, levels are only pertinent for hardware players. However, some software players may have been designed with a level ceiling. Apparently, that's the case with Apple's players.
Your video's frame size is 6000x4000 for which the player has to support level 6.0, which is a recent addition to the standard (~2 years). I suggest you halve the resolution,
ffmpeg -framerate 30 -pattern_type glob -i "DSCF*.JPG" -vf scale=iw/2:ih/2,format=yuv420p -profile baseline out.mp4

ffmpeg record screen file formats

Good day,
I'm currently writing a bash script which records the screen under certain conditions. The problem is that only avi works as a file extension for recording the screen. This script is going to be used on an Raspberry Pi and currently I get on a decent virtual machine only 10-20 fps (goal would be around 30 fps). I think .avi is not suited for my project. But .mpeg and .mp4 are not working for recording. I tried recording with .avi and then converting it in .mp4, but I have limited memory and .avi ist just too big in size. I use currently the following command:
ffmpeg -f x11grab -y -r 30 -s 960x750 -i :0.0+0,100 -vcodec huffyuv ./Videos/out_$now.avi
//$now is the current date and time
So I wanted to know if I need some special packages from ffmpeg to record with for example .mp4 or if there are other file formats available for ffmpeg screen recording.
Edit:
I found that the codec libx264 for mp4 works, but the fps drop until they hit5 fps, which is definetly too low. The recorded video appeared like being a fast forward version of the recorded screen.
With mpeg4 for mpeg I reached over 30 fps, but the video qualitywas very bad.
It appears that even my big avi-files look like being played fast forward. Is there something I do wrong?
Is there a good middle way, where I get a decend video quality, good fps (20+) and a file which isn't too big?
Edit 2:
I tried recording it with .avi and converting it afterwards. Just converting with ffmpeg -i test.avi -c:a aac -b:a 128k -c:v libx264 -crf 23 output.mp4
resulted in the same framedrops as if I was recording with .mp4. But when I cut a littlebit of the beginning of the video and named the outputfile .mp4, the size became much smaller. But when I started the cutting at 0:00:00 (so tried just converting), it just changed the file format without converting it (so the size stayed the same). Any ideas?

ffmpeg output doesn't play on multiple devices

I have read the other stackoverflow posts regarding this topic so I am fairly certain this is not exact duplicate.
ffmpeg exports a video that seems to only play on select players. I want to export a video that plays on iphone/mac/general players. I have seen the suggestions for the -pix_fmt yuv420p tag but this does not seem to work anymore - I read that Mac has since changed their systems that makes it not compatible anymore.
I am running:
ffmpeg -start_number 1 -framerate 4 -pix_fmt yuv420p -i screen%01d.png output.mp4
This all works fine and I can see the video by doing:
ffplay output.mp4
But I would like to be able to transfer this to mobile or general playback, any way to do this, ideally using ffmpeg? I'd rather not use two tools to do 1 job.
Works on gmail
Doesn't work on QuickTime Player
Doesn't work on Flip Player
Doesn't work on iPhone
Order of options is important. It should be,
ffmpeg -start_number 1 -framerate 4 -i screen%01d.png -pix_fmt yuv420p output.mp4
Now pix_fmt is set as an output option. Originally, it was trying to force the input format, but since PNGs are images with metadata and not raw pixel data, th eoption had no effect. Additionally, for web use, it's good to also set -movflags +faststart as an output option.
Note that old versions of VLC couldn't play videos with framerate < 6. Could possibly be an issue with a few other players as well. Add -r 8 as an output option to avoid that.

Resources