chatchai_j icon

watermark.sh

chatchai_j | PRO | 06/27/22 04:45:12 PM UTC (Edited) | 0 ⭐ | 415 👁️ | Never ⏰ | []
Bash |

960 B

|

None

|

0 👍

/

0 👎

#!/bin/sh
 
# SRCDIR = "F:\\2022-06-21" -- Windows Folder
# DSTDIR = "E:\\2022-06-21" -- Windows Folder
 
SRCDIR="${HOME}/F/2022-06-21"
DSTDIR="${HOME}/E/2022-06-21"
 
FFMPEG="/usr/bin/ffmpeg"
 
## Note: Not sure about the '\,' in these string, you might have to change from '\,' to '\\,' or maybe just ','
## to get the correct "qoute"
 
FILTERGRAPH="drawtext=text='Uploaded to XYZ.net':fontfile=arial-bold.ttf:y=line_h-10:x=w-mod(max(t\,0)*(w+tw)/30\,(w+tw)):fontcolor=ffffff:fontsize=20:shadowx=2:shadowy=2:enable=lt(mod(t\,300)\,30)" 
 
[ ! -x "${FFMPEG}" ] && echo "Can't find ${FFMPEG}" && exit
 
# if destination directory is not exist, then create it.
[ ! -d "${DSTDIR}" ] && mkdir -p ${DSTDIR}
[ ! -d "${DSTDIR}" ] && echo "Failed to create directory '${DSTDIR}'" && exit
 
for MP4 in ${SRCDIR}/*.mp4; do
    DST=$(basename $MP4)
    echo "Watermarking from '$MP4' to '${DSTDIR}/$DST'"
    ${FFMPEG} -i "$MP4" -vf "${FILTERGRAPH}" -c:a copy ${DSTDIR}/${DST}
done
 

Comments