Saturday, July 29, 2023

Ffmpeg vIdeo edit example for FB reels

ffmpeg

1. Go to directory.

cd ~/Videos/20230816-imsa

2. Generate cut/trim script.

ls V*.mp4 | sed 's/^/ffmpeg -i /; s/$/ -ss 00 -to 05 -c copy o.mp4/'

3. Edit the cut/trim script.

ffmpeg -i VID_20230816_060307.mp4 -ss  0 -to  6 -c copy o1.mp4
ffmpeg -i VID_20230816_060551.mp4 -ss 15 -to 22 -c copy o2.mp4
ffmpeg -i VID_20230816_060635.mp4 -ss  3 -to 23 -c copy o3.mp4
ffmpeg -i VID_20230816_060635.mp4 -ss  6 -to 10 -c copy o0.mp4 #fb reels thumbnail
ffmpeg -i VID_20230816_060758.mp4 -ss  8 -to 20 -c copy o4.mp4
ffmpeg -i VID_20230816_061349.mp4 -ss 1:44 -to 2:0 -c copy o5.mp4
ffmpeg -i VID_20230816_061821.mp4 -ss  0 -to 25 -c copy o7.mp4

4. Generate the concat list.

ls o*.mp4 | sed 's/^/file /' > list.txt

5. Edit concat list.

file o0.mp4
file o1.mp4
file o2.mp4
file o3.mp4
file o4.mp4
file o5.mp4
file o7.mp4

6. Execute concat.

ffmpeg -f concat -i list.txt -c copy o.mp4

7. Create title file.

cat << EOF > title.txt
2023/08/16
Bagong pisa
EOF

8. Generate the final script.

vid-vlog-reels.sh o.mp4  title.txt  reels.mp4

9. Final cript.

ffmpeg -t 90 -i o.mp4 \
  -filter_complex "
    [0:v]scale=-2:1920
      ,drawtext=enable='between(t,1,6)' \
        :fontsize=96 \
        :fontfile=/usr/share/fonts/truetype/dejavu/DejaVuSans-Bold.ttf :fontcolor=white@0.99 \
        :textfile=title.txt :x=(w-text_w)/2 :y=h/100 \
        :shadowcolor=black :shadowx=4 :shadowy=4  \
      ,drawtext=enable='between(t,1,89)'   \
        :fontsize=76 \
        :fontfile=/usr/share/fonts/truetype/dejavu/DejaVuSans-Bold.ttf :fontcolor=white@1.0 \
        :text='©TotsPo' \
        :box=1 :boxcolor=black@0.5 :x=(w-text_w)-text_h/2: y=(h-1.5*text_h)  \
      [v]    
" -map [v] \
  -map 0:a -c:a copy \
  -preset veryfast \
  -movflags faststart \
-y reels.mp4
echo
ls -lh reels.mp4
See output video.

No comments:

Post a Comment