Skip to content

Instantly share code, notes, and snippets.

@crojasaragonez
Last active December 28, 2015 19:52
Show Gist options
  • Save crojasaragonez/8a05d96a84f83cec915b to your computer and use it in GitHub Desktop.
Save crojasaragonez/8a05d96a84f83cec915b to your computer and use it in GitHub Desktop.
require 'date'
SECONDS_PER_CHUNK = 300
FILE_NAME = 'file.mp3'
seconds = %x(mp3info -p "%S\n" #{FILE_NAME}).to_i
today = Date.today
start_date = Time.new(today.year, today.month, today.day)
end_date = start_date + seconds
part = 1
while start_date <= end_date
from = format('%d:%d:%d', start_date.hour, start_date.min, start_date.sec)
start_date += SECONDS_PER_CHUNK
%x(ffmpeg -i #{FILE_NAME} -vsync 2 -acodec copy -t 00:5:00 -ss #{from} part_#{part}.mp3)
part += 1
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment