Skip to content

Instantly share code, notes, and snippets.

@metacritical
Created November 28, 2011 20:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save metacritical/1401808 to your computer and use it in GitHub Desktop.
Save metacritical/1401808 to your computer and use it in GitHub Desktop.
Ruby video player implemented using HornetsEye
require 'rubygems'
require 'hornetseye_ffmpeg'
require 'hornetseye_xorg'
require 'hornetseye_alsa'
include Hornetseye
input = AVInput.new 'sintel.mp4'
alsa = AlsaOutput.new 'default:0', input.sample_rate, input.channels
audio_frame = input.read_audio
X11Display.show 600, :output => XVideoOutput do |display|
img = input.read
while alsa.avail >= audio_frame.shape[1]
alsa.write audio_frame
audio_frame = input.read_audio
end
delay = input.video_pos - input.audio_pos + (alsa.delay + audio_frame.shape[1]).quo(alsa.rate)
display.event_loop [delay, 0].max
img
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment