Skip to content

Instantly share code, notes, and snippets.

@michiels
Created November 14, 2012 14:19
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save michiels/4072363 to your computer and use it in GitHub Desktop.
Save michiels/4072363 to your computer and use it in GitHub Desktop.
FFMPEG Wrapper
class FFMPEGWrapper
def duration_in_sections
command = IO.popen("ffmpeg -i #{uploaded_file} 2>&1 | awk '/Duration/ { print substr($2,0,length($2)-1) }'")
duration_output = command.read
matches = duration_output.match(/(\d{2}):(\d{2}):(\d{2}\.\d{1,2})\n/)
hours = matches[1].to_f
minutes = matches[2].to_f
seconds = matches[3].to_f
miliseconds = matches[4].to_f
return (hours * 60.0 * 60.0) + (minutes * 60.0) + seconds
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment