Skip to main content
edited tags; edited tags
Link
Gilles 'SO- stop being evil'
  • 865.3k
  • 205
  • 1.8k
  • 2.3k
Tweeted twitter.com/#!/StackUnix/status/386691411846103040
Source Link
ironsand
  • 5.4k
  • 13
  • 55
  • 74

how to convert number to time format in shell script?

I want to cut a video into about 10 minute parts like this.

ffmpeg -i video.mp4 -ss 00:00:00 -t 00:10:00 -c copy 01.mp4
ffmpeg -i video.mp4 -ss 00:10:00 -t 00:10:00 -c copy 02.mp4
ffmpeg -i video.mp4 -ss 00:20:00 -t 00:10:00 -c copy 03.mp4

With for it will be like this.

for i in `seq 10`; do ffmpeg -i video.mp4 -ss 00:${i}0:00 -t 00:10:00 -c copy ${i].mp4; done;

But it works only if duration is under a hour. How can I convert number to time format in bash shell?