Sha256: d698a3cd6080b8753f4fa4aaa2963544554e2e9195dfd977f91c9469af261efa

Contents?: true

Size: 889 Bytes

Versions: 3

Compression:

Stored size: 889 Bytes

Contents

module Ffprober
  class Wrapper
    def initialize(json)
      @json = json
    end

    def format
      @format ||= Ffprober::Format.new(json[:format])
    end

    def video_streams
      @video_streams ||= stream_by_codec("video").map { |data| Ffprober::VideoStream.new(data) }
    end

    def audio_streams
      @audio_streams ||= stream_by_codec("audio").map { |data| Ffprober::AudioStream.new(data) }
    end

    def chapters
      @chapters ||= json[:chapters].map { |chapter| Ffprober::Chapter.new(chapter) }
    end

    def subtitle_streams
      @subtitle_streams ||= stream_by_codec("subtitle").map { |stream| Ffprober::SubtitleStream.new(stream) }
    end

    private

    def stream_by_codec(codec_type)
      streams.select { |stream| stream[:codec_type] == codec_type }
    end

    def streams
      json[:streams]
    end

    def json
      @json
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
ffprober-0.4.5 lib/ffprober/wrapper.rb
ffprober-0.4.4 lib/ffprober/wrapper.rb
ffprober-0.4.3 lib/ffprober/wrapper.rb