I have been looking for a way to use ffmpeg to downscale some MPEG-4 (Base Media / Version 2) video files recorded with a variable frame rate, adding fade in/out effects at the head and tail of each clip.
Based on the answer provided here, I've been using the following command line to add a 2 second fade/out effect on to my clips:
ffmpeg -i VID_1.mp4 -sseof -2 -copyts -i VID_1.mp4 -lavfi "fade=out:s=0:d=2[tail];[tail]overlay,fade=in:s=0:d=2[overlay]; anullsrc,atrim=0:4[audiotail];[audiotail]acrossfade=d=2,afade=d=2[audio];[overlay]scale=640:-1[video]" -map "[video]" -map "[audio]" -vsync 2 -sws_flags gauss -c:v libx264 -crf 18 -preset slow -shortest -report -hide_banner VID_1_out.mp4
- I seem to get a lot of the following error lines in the report
cur_dts is invalid (this is harmless if it occurs once at the start per stream)
Is it normal?
In the resulting output video clip, the fade-in comes out less than 2 seconds (about 1 second), and there appears no fade out, just a black-out for the last four seconds. Where is my command line wrong?
The duration of the original clip is 24s640ms, the output file is longer by 2s022ms. Why additional 22 ms?
If I drop the
-vsync 2 option, the output clip frame rate becomes exactly the same as that of the source video file. This, however doesn't deal away with the above issues.