본문 바로가기

Split file by minute using ffmpeg with shell script

web/etc by 낼스 2023. 6. 2.
```sh inc=5 if [ $# -lt 1 ] ; then echo "Usage: ff2 file_name sec loop_count" exit 1 elif [ $# -lt 2 ] ; then inc=5 else inc=$2 fi loop=5 if [ "$3" != "" ] ; then loop=$3 fi convertsecs() { ((h=${1}/3600)) ((m=(${1}%3600)/60)) ((s=${1}%60)) printf "%02d:%02d:%02d\n" $h $m $s } # echo loop $loop; # ffmpeg -ss 01:00:00 -i $1.mp4 -t 00:15:00 -c copy $1_05.mp4 fromSec=0 toSec=0 fromMin=0 toMin=0 fromTime="" recTime="" for fSeq in $(seq -f "%02g" 1 $loop) do fromSec=0 if [ $fSeq != "01" ] ; then fromSec=$((($fromMin)*60)) # fromSec=$(((($fromMin)*60)+1)) fi toSec=$(($toMin*60)) fromTime=$(convertsecs $fromSec) recTime=$(convertsecs $(($inc*60))) ffmpeg -ss $fromTime -i $1.mp4 -t $recTime -c copy $1_$fSeq.mp4 fromMin=$(($fromMin + $inc)) done # i=6789 # ((sec=i%60, i/=60, min=i%60, hrs=i/60)) # timestamp=$(printf "%d:%02d:%02d" $hrs $min $sec) # echo $timestamp # date -u -r $i +%T # TIME1="36" # TIME2="1036" # TIME3="91925" # echo $(convertsecs $TIME1) # echo $(convertsecs $TIME2) # echo $(convertsecs $TIME3) ```

'web > etc' 카테고리의 다른 글

Google BigQuery  (0) 2021.03.21
Editplus replace lowercase case with uppercase  (0) 2020.11.06
Microsoft Remote Desktop(RDC) 한영 전환 안됨  (1) 2020.06.24
611f14858cd043c8a31a9db143774486  (0) 2019.08.26
fastcopy batch  (0) 2019.07.28

댓글