Created
June 21, 2022 16:48
-
-
Save tarekeldeeb/11ba6656564ef2d62c664b91b5d98d0a to your computer and use it in GitHub Desktop.
thumb_me.sh
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# | |
# Add 1-Sec silent video with filename as a label | |
# This ensures the thumbnail has the filename included | |
# | |
# Parameters: | |
# - EXT: Video files extension | |
# - OFFSET: X,Y offset of the label | |
# - FPS: Frames per second, get by ffmpeg -i <file.ext> | |
# - SECONDS: Extra video length with Label | |
# | |
# Author: Tarek Eldeeb | |
# | |
EXT=mp4 | |
alias ffmpeg="ffmpeg -hide_banner -loglevel error" | |
find . -type f -iname "*.$EXT" -exec sh -c ' | |
X_OFFSET=250 | |
Y_OFFSET=150 | |
FPS=25 | |
SECONDS=1 | |
echo Opening: "$0" | |
file=`basename "$0"` | |
f="${file%.*}" | |
ffmpeg -i "$file" -vframes 1 -vf "drawtext=text=$f:fontcolor=white:fontsize=75:x=$X_OFFSET:y=$Y_OFFSET:" "$f.jpeg" | |
ffmpeg -loop 1 -framerate $FPS -i "$f.jpeg" -c:v libx264 -t $SECONDS -pix_fmt yuv420p "$f.1.mp4" | |
ffmpeg -i "$f.1.mp4" -c copy -bsf:v h264_mp4toannexb -f mpegts "$f.1.ts" && rm -f "$f.1.mp4" | |
ffmpeg -i "$file" -c copy -bsf:v h264_mp4toannexb -f mpegts "$f.ts" && rm -f "$file" | |
ffmpeg -i "concat:$f.1.ts|$f.ts" -c copy -bsf:a aac_adtstoasc "$file" | |
rm -f "$f.jpeg" "$f.1.ts" "$f.ts" | |
' {} ';' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment