Created
September 4, 2019 11:30
-
-
Save cuu/1011367bb34d55d965ce30f9b2fdf03e to your computer and use it in GitHub Desktop.
微信小视频切割脚本
This file contains 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 | |
FILENAME=${1} | |
MIN_FRAGMENT_LENGTH=300 | |
if [ ! -f "${FILENAME}" ]; then | |
echo "FILE NOT FOUND: $FILENAME" | |
exit 1 | |
fi | |
if [ ${2} ]; then | |
TARGET=$2 | |
else | |
TARGET="/tmp" | |
fi | |
TIME=`ffprobe -i "${FILENAME}" -show_entries format=duration -of csv="p=0" 2>/dev/null | awk '{print int($1+0.5)}'` | |
if [ ${TIME} > ${MIN_FRAGMENT_LENGTH} ]; then | |
FNAME=0 | |
for ((OFFSET = 0; OFFSET < ${TIME}; OFFSET=OFFSET+${MIN_FRAGMENT_LENGTH})) | |
do | |
TARGET_FILE="${TARGET}/${FNAME}.mp4" | |
ffmpeg -i "${FILENAME}" -c copy -ss ${OFFSET} -to $((OFFSET + $MIN_FRAGMENT_LENGTH)) -y "${TARGET_FILE}" 2>/dev/null | |
echo $TARGET_FILE CREATED | |
FNAME=$((FNAME+1)) | |
done | |
else | |
echo "NO NEED TO CUT" | |
fi | |
open ${TARGET} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
众所周知,微信对传输视频有5分钟限制,利用 ffmpeg 裁切视频, 以利于发车 - . -