I am creating timelapse from PNG single frames.

Using the first and last frame as stills I create a header and a trailer with a text and a fade filter. In the end I use concat to put all parts together. What I see happen is that in the final video there is a jump between the end of the main body and the trailer. It seems as if the concat process has cut away some frames (at the end) from the main body. That makes the transition from the main body to the trailer look very bad.

What do I have to do to fix this?

/home/tools/bin/ffmpeg -loop 1 -i Timelapse_1080/IMG_7255.png -c:v libx264 -vf drawtext="fontsize=60:fontcolor=yellow:fontfile=/usr/share/fonts/truetype/freefont/FreeSans.ttf:textfile=./Scripts/header_text.txt:x=(w-text_w)/2:y=(h-text_h-line_h)/2" -t 5 -pix_fmt yuv420p  -crf 16 -r 24 -y ./Video/header_txt.mp4
/home/tools/bin/ffmpeg -i ./Video/header_txt.mp4 -vf fade=in:0:48 -crf 16 -r 24 -y ./Video/header_txt_fade.mp4

Timlapse body
/home/tools/bin/ffmpeg -start_number 7255 -i Timelapse_1080/IMG_%04d.png -pix_fmt yuv420p  -crf 16 -r 24 -y ./Video/body.mp4

/home/tools/bin/ffmpeg -loop 1 -i Timelapse_1080/IMG_7490.png -c:v libx264 -t 6 -pix_fmt yuv420p -crf 16 -r 24 -y ./Video/trailer.mp4
/home/tools/bin/ffmpeg -i ./Video/trailer.mp4 -vf fade=out:20:60 -crf 16 -y ./Video/trailer_fade.mp4

Concat all together
/home/tools/bin/ffmpeg -safe 0 -f concat -i ./scripts/ffmpeg_concat_all.txt -c copy -y ./Video/Timelapse_crf16_24fps.mp4

There's no need to work with individual files; you can put everything into one ffmpeg command. This is also much faster and will result in better quality.

Define your three inputs (intro image, outro image, and the image sequence), then create individual filters to draw the text, trim the intro/outro clips, and run the fade filters. Finally concat everything into one stream.

I have omitted some specific text options and image file names for the sake of brevity.

ffmpeg \
    -y \
    -loop 1 -framerate 24 -t 5 -i intro.png \
    -loop 1 -framerate 24 -t 5 -i outro.png \
    -start_number 1 -framerate 1 -i frame-%04d.png \
    -filter_complex " \
    [0:v] \
        fade=in:0:48 \
    [intro]; \
    [1:v] \
        fade=out:20:60 \
    [outro]; \
    [intro][2:v][outro] \
    [outv] \
    " \
    -map "[outv]" -c:v libx264 -pix_fmt yuv420p -crf 16 out.mp4

The -t 5 sets the duration of the intro/outro directly.

You can replace the input -framerate parameters with the desired frame rates of the intro and outro, and also change it in order to set the slideshow speed. That is, if you want one image every second, use 1, if you want one every two seconds, use 0.5, etc.

  • Can just use -loop 1 -framerate 24 -t 5 -i intro.png instead of fps/trim filters. – Gyan Aug 6 '18 at 9:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.