Answers.Body: <p>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.</p>
  
  <p>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 <code>concat</code> everything into one stream.</p>
  
  <p>I have omitted some specific text options and image file names for the sake of brevity.</p>
  
  <pre><code>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] \
          drawtext=fontsize=500:fontcolor=white:text=foo:x=(w-text_w)/2:y=(h-text_h-line_h)/2,
          fade=in:0:48 \
      [intro]; \
      [1:v] \
          drawtext=fontsize=500:fontcolor=white:text=foo:x=(w-text_w)/2:y=(h-text_h-line_h)/2,
          fade=out:20:60 \
      [outro]; \
      [intro][2:v][outro] \
          concat=n=3:v=1:a=0
      [outv] \
      " \
      -map "[outv]" -c:v libx264 -pix_fmt yuv420p -crf 16 out.mp4
  </code></pre>
  
  <p>The <code>-t 5</code> sets the duration of the intro/outro directly.</p>
  
  <p>You can replace the input <code>-framerate</code> 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.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-08-06T09:49:08.960Z
Answers.Text: Can just use `-loop 1 -framerate 24 -t 5 -i intro.png` instead of fps/trim filters.
Answers.UserDisplayName: Gyan
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-08-06T08:52:04.220Z
Answers.LastActivityDate: 2018-08-06T09:51:48.060Z
Answers.LastEditDate: 2018-08-06T09:51:48.060Z
Answers.UserDisplayName: slhck
Body: <p>I am creating timelapse from PNG single frames.</p>
  
  <p>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 <code>concat</code> 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. </p>
  
  <p>What do I have to do to fix this?</p>
  
  <pre><code>Header
  ------
  /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
  
  Trailer
  --------
  /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
  </code></pre>
  
Tags: <ffmpeg>
Title: FFmpeg concat creating time jumps
UserDisplayName: Gert Gottschalk
ThreadText: # FFmpeg concat creating time jumps
  
  (Asked by: username_0 on 2018-08-05)
  
  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?
  
  ```
  Header
  ------
  /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
  
  Trailer
  --------
  /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
  
  ```
  
  **Tags:** ffmpeg
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2018-08-06. Score: 1
  
  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] \
          drawtext=fontsize=500:fontcolor=white:text=foo:x=(w-text_w)/2:y=(h-text_h-line_h)/2,
          fade=in:0:48 \
      [intro]; \
      [1:v] \
          drawtext=fontsize=500:fontcolor=white:text=foo:x=(w-text_w)/2:y=(h-text_h-line_h)/2,
          fade=out:20:60 \
      [outro]; \
      [intro][2:v][outro] \
          concat=n=3:v=1:a=0
      [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.
  
  > **Comments:**
  > **username_2**: Can just use `-loop 1 -framerate 24 -t 5 -i intro.png` instead of fps/trim filters.  
  
  ---
  
  