Created: 2012-03-21 15:25
Updated: 2018-01-17 09:08
License: other

Video Splitter

Video Splitter (VS) is a video-utility, released as a ruby gem, that allows you to split video files.

Supported formats

VS supports wmv, f4v (or flv) and mp4 video formats. It implements a splitting strategy based on video file extension. It's easy to implement others strategy by putting a splitter_strategy.rb file in your lib/video_splitter folder, and by adding a key/value (:ext => YourFormatSplitter) pair in the @@strategy hash (as you can override the gem class).


VS requires rails 3.2 or newer, so first of all, install it:

gem install rails -v 3.2

You can easily build up a brand new rails application that use video splitter by using the video_splitter.rb template, executing this command:

rails new my_app -m

Or simply include it in your Gemfile:

gem 'video_splitter', :git => 'git://'

and then run

bundle install

rails generate video_splitter:install

The video_splitter:install generator do some rilevant action that you need to be aware of:

  • copies the video_splitter.yml in your config folder
  • copies an after_split.rb class in your lib/video_splitter folder
  • copies the video-splitter.split_done.js in your assets/javascripts folder
  • copies the index.html.erb in your app/views/application folder
    and inject the index action (as just to make the application runnning) in your application_controller.rb
  • creates input and output video folders in your public/video folder
  • adds the video_splitter routes in your routes.rb file
  • adds js and css require in your application.js and in your application.css
  • adds the lib folder to the autoload paths

Video Splitter configuration

In any case you have to setup the __video_splitter.yml__ with your local paths:
  • ffmpeg_path: path to your local ffmpeg binaries (tipically /usr/bin/ffmpeg)
  • input_folders: an hash that define paths and labels for your local input folders

Keep in mind that input folders you specify on video_splitter.yml will be mounted on your public/video/input folder.

After split callbacks

VideoSplitter::AfterSplit class menages the after split process callbacks:

  • after_each_split
  • after_all_splits (in case of batch splitting)

It defines methods optionally passed to render_video_splitter helper:

render_video_splitter({ :after_each_split => :do_something_after_each_split, :after_all_splits => :do_something_after_all_splits })

The after_each_split callback can access info stored in the @options hash:

  • output_filename: only the new splitted file name, without extension
  • output_format: the new splitted file extension
  • timecode_input: the original file inpoint from which the cut was done
  • timecode_output: the original file outpoint to which the cut was done
  • video[:file_path]: the original file path
  • length: length of the new splitted video in seconds

The after all splits callback can access info stored in the @options hash. It provides informations about the whole splitting process, so you'll have two arrays:

  • successful: successfuly splitted files (one or many)
  • errors: unsuccessfuly splitted files (one or many)

After split rendering

After all splits (after the whole splitting process) you may want to render something. To do this, in your assets/javascripts folder you'll find a video-splitter.split_done.js that implements a splitDone method. You can modify it as you want.

Js and Css require

As VS is provided with jQuery and jQuery UI libraries, the install generator removes their requires from your application.js

Requirements and dependencies

VS needs ffmpeg installed on your local machine. For more information about ffmpeg visit

Other useful links for a correct ffmpeg installation:

Vs use the mediaelement.js library (HTML5 and shim and player and provides a plugin (mep-feature-videosplitter.js) that adds in/out markers to it. It also draws a subclip timeline using jQuery UI slider.


Once you have VS gem installed on your machine and video_splitter.yml properly configured, you can access it at this url: http://localhost:3000/video_splitter

Contributing to VS

  • Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet
  • Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it
  • Fork the project
  • Start a feature/bugfix branch
  • Commit and push until you are happy with your contribution
  • Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
  • Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.

To do

  • Some test.
  • Grep TODO annotations.
  • A branch for earlier Rails version (e.g. 2.3.14)
  • Better methods documentation for Rdoc
  • Improve this readme file, possibly with a better english :)
  • Publish the VS gem to


VS is Copyright (c) 2012 Interact S.P.A. It is free software, and may be redistributed under the terms specified in the LICENSE.txt file.

Cookies help us deliver our services. By using our services, you agree to our use of cookies Learn more