spacepaste

  1.  
  2. # tested with: https://www.shutterstock.com/video/clip-3885476
  3. TMP=.
  4. SRC=countdown.mp4
  5. DST=output.mp4
  6. FREEZE_S=10
  7. cd "$TMP"
  8. # get last frame
  9. NFRAMES=`ffprobe -show_streams "$SRC" 2> /dev/null | grep nb_frames | head -1 | cut -d \= -f 2`
  10. let "LAST_FRAME = $NFRAMES - 1"
  11. ffmpeg -i $SRC -vf select=\'eq\(n,$LAST_FRAME\) -vframes 1 LAST_FRAME.jpg
  12. # make last-frame-frozen video
  13. FRAMERATE=$(ffprobe -v 0 -of csv=p=0 -select_streams 0 -show_entries stream=r_frame_rate "$SRC")
  14. ffmpeg -loop 1 -framerate 1 -i LAST_FRAME.png -r "$FRAMERATE" -t "$FREEZE_S" -pix_fmt yuv420p LAST_FRAME.mp4
  15. # Produces list.txt like this:
  16. # file foo.mp4
  17. # file 'bar with spaces.mp4'
  18. printf "file %q\n" "$SRC" LAST_FRAME.mp4 > list.txt
  19. # concatenate
  20. ffmpeg -y -f concat -safe 0 -i list.txt -c copy "$DST" # green-screen for LAST_FRAME.mp4 duration
  21. # Alternative:
  22. # ffmpeg -i "concat:$SRC|LAST_FRAME.mp4" -c:a copy -c:v copy "$DST" # <-- no LAST_FRAME.mp4
  23.