Created
November 28, 2011 20:06
-
-
Save metacritical/1401808 to your computer and use it in GitHub Desktop.
Ruby video player implemented using HornetsEye
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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