Skip to content

Instantly share code, notes, and snippets.

@Fivell
Created August 2, 2012 21:32
Show Gist options
  • Save Fivell/3240844 to your computer and use it in GitHub Desktop.
Save Fivell/3240844 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