Created
February 2, 2019 15:07
-
-
Save hoangdh/1397be6ed9964c8ec91fb3fd76cf9be0 to your computer and use it in GitHub Desktop.
Cutting video duration greater than 60 minutes using FFMPEG.
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 | |
dur=`ffprobe -v error -select_streams v:0 -show_entries stream=duration -of default=noprint_wrappers=1:nokey=1 "$1" | head -n 1` | |
## Chinh so phut o $parts, $t va 2 cau lenh cut | |
flag=`echo "$dur > 3600" | bc` | |
name=`echo $1 | tr '.' ' ' | awk {'print $1'}` | |
if [ $flag = "1" ] | |
then | |
parts=`echo $dur/3600 | bc` | |
for x in `seq 0 $parts` | |
do | |
t=`echo $x*3599 | bc` | |
PART=`echo $x+1 | bc` | |
if [ "$x" = "0" ] | |
then | |
ffmpeg -i "$1" -ss 0 -t 3599 -c copy "$name-part${PART}.mp4" | |
else | |
ffmpeg -i "$1" -ss $t -t 3599 -c copy "$name-part${PART}.mp4" | |
fi | |
done | |
clear | |
echo "Cutting has successfully!" | |
ls | grep $name | |
echo Done!!! | |
else | |
echo "Video mustn't cutting. $dur" | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment