Sha256: d6bdd3ed05e0f459ac79cc52ea1a2bafbbe35f5091ceeaf4347a8e1d76e2be3b

Contents?: true

Size: 952 Bytes

Versions: 42

Compression:

Stored size: 952 Bytes

Contents

#!/usr/bin/env ruby

require 'gst'

def type_find(file)
  pipeline = Gst::Pipeline.new("pipeline")

  source = Gst::ElementFactory.make("filesrc", "source")
  type_find = Gst::ElementFactory.make("typefind", "type-find")
  sink = Gst::ElementFactory.make("fakesink", "sink")

  pipeline.add(source, type_find, sink)
  source >> type_find >> sink

  found_caps = nil
  type_find.signal_connect("have-type") do |element, probability, caps|
    found_caps = caps
  end

  loop = GLib::MainLoop.new
  source.location = file
  bus = pipeline.bus
  bus.add_watch do |bus, message|
    case message.type
    when Gst::Message::STATE_CHANGED, Gst::Message::EOS
      loop.quit
    when Gst::Message::ERROR
      p message.parse
      loop.quit
    end
    true
  end
  pipeline.pause
  loop.run
  pipeline.stop

  if found_caps
    puts("#{file} - #{found_caps}")
  else
    puts("#{file} - No type found")
  end
end

ARGV.each do |file|
  type_find(file)
end

Version data entries

42 entries across 42 versions & 1 rubygems

Version Path
gstreamer-1.2.6-x86-mingw32 sample/type-find.rb
gstreamer-1.2.6 sample/type-find.rb
gstreamer-1.2.5-x86-mingw32 sample/type-find.rb
gstreamer-1.2.5 sample/type-find.rb
gstreamer-1.2.4-x86-mingw32 sample/type-find.rb
gstreamer-1.2.4 sample/type-find.rb
gstreamer-1.2.3-x86-mingw32 sample/type-find.rb
gstreamer-1.2.3 sample/type-find.rb
gstreamer-1.2.2-x86-mingw32 sample/type-find.rb
gstreamer-1.2.2 sample/type-find.rb
gstreamer-1.2.1-x86-mingw32 sample/type-find.rb
gstreamer-1.2.1 sample/type-find.rb
gstreamer-1.2.0-x86-mingw32 sample/type-find.rb
gstreamer-1.2.0 sample/type-find.rb
gstreamer-1.1.9-x86-mingw32 sample/type-find.rb
gstreamer-1.1.9 sample/type-find.rb
gstreamer-1.1.8-x86-mingw32 sample/type-find.rb
gstreamer-1.1.8 sample/type-find.rb
gstreamer-1.1.7 sample/type-find.rb
gstreamer-1.1.7-x86-mingw32 sample/type-find.rb