Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
tree: 0ed5415520
Fetching contributors…

Octocat-spinner-32-eaf2f5

Cannot retrieve contributors at this time

file 45 lines (32 sloc) 0.937 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44
#!/usr/bin/env ruby

require 'ffmpeg'
require 'pp'

file = ARGV.shift

abort "#{$PROGRAM_NAME} filename" unless file

input = FFMPEG::FormatContext.new file

puts input.filename
puts "#{input.duration.to_f / FFMPEG::TIME_BASE} seconds #{input.bit_rate} bps"
puts

puts 'streams:'
input.streams.each do |stream|
  codec_context = stream.codec_context
  decoder = codec_context.decoder

  dsp = "\t%2d %s" % [
    stream.stream_index,
    codec_context.codec_type,
  ]

  case codec_context.codec_type
  when :AUDIO then
    dsp << " #{stream.time_base.den} Hz"
    dsp << " #{codec_context.channels} channels"
    dsp << " #{FFMPEG::SampleFormat::FORMATS[codec_context.sample_format]}"
  when :VIDEO then
    dsp << " frame rate %s" % stream.r_frame_rate
    dsp << " size: #{codec_context.dimensions}"
  end

  dsp << "\n\t\t#{decoder.long_name}"

  puts dsp
end

puts
puts "time base: #{FFMPEG::TIME_BASE} #{FFMPEG::TIME_BASE_Q}"
puts

Something went wrong with that request. Please try again.