Skip to content

Instantly share code, notes, and snippets.

@gmanley
Created July 17, 2014 07:54
Show Gist options
  • Save gmanley/caf715d79ca0f99a8f03 to your computer and use it in GitHub Desktop.
Save gmanley/caf715d79ca0f99a8f03 to your computer and use it in GitHub Desktop.
Designing initial interface for MediaMerge.

Create a job. A job is what defines what we are merging.

job = MediaMerge::Job.new

Create an input. An input defines a media source.

sub_input = MediaMerge::Input.new('sample (en).mkv')

Input#tracks returns an array of Track objects.

sub_input.tracks.each do |track|
  if track.subtitle? && track.lang_code == :en
    # Sets this track to be copied and the options
    track.copy(name: 'English Sub', default: true)
  end
end

Another way to define an input.

video_audio_input = MediaMerge::Input.new('sample [bluray].mkv'
  copy: {
    type: [ :video, audio: { lang_code: :ja } ]
  }
})

After defining the inputs we add them to the job.

job.inputs.push(video_audio_input, sub_input)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment