Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 75 lines (58 sloc) 2.094 kb
c7990d1 @wedesoft Improved documentation
authored
1 hornetseye-ffmpeg
d6e6745 @wedesoft Loading rational.rb
authored
2 =================
c7990d1 @wedesoft Improved documentation
authored
3
4 **Author**: Jan Wedekind
5 **Copyright**: 2010, 2011
6 **License**: GPL
7
8 Synopsis
9 --------
10
fea8cbb @wedesoft Added missing file rubyinc.hh
authored
11 This Ruby extension defines the class {Hornetseye::AVInput} for reading frames from video files and the class {Hornetseye::AVOutput} for writing frames to video files.
0203133 @wedesoft Initial commit
authored
12
c7990d1 @wedesoft Improved documentation
authored
13 Installation
14 ------------
f048c06 @wedesoft Minor changes to documentation
authored
15
001cd77 @wedesoft Minor changes to documentation
authored
16 *hornetseye-ffmpeg* requires FFMpeg and the software scaling library. If you are running Debian or (K)ubuntu, you can install them like this:
c7990d1 @wedesoft Improved documentation
authored
17
001cd77 @wedesoft Minor changes to documentation
authored
18 $ sudo aptitude install libavformat-dev libswscale-dev
c7990d1 @wedesoft Improved documentation
authored
19
20 To install this Ruby extension, use the following command:
21
22 $ sudo gem install hornetseye-ffmpeg
23
24 Alternatively you can build and install the Ruby extension from source as follows:
25
26 $ rake
27 $ sudo rake install
28
29 Usage
30 -----
31
32 Simply run Interactive Ruby:
33
34 $ irb
35
36 You can load and use FFMpeg as shown below. The example is a simple video player.
37
38 require 'rubygems'
39 require 'hornetseye_ffmpeg'
40 require 'hornetseye_xorg'
41 require 'hornetseye_alsa'
42 include Hornetseye
43 raise 'Syntax: ./play.rb <video file> [offset]' unless ( 1 .. 2 ).member? ARGV.size
44 input = AVInput.new ARGV.first
45 input.pos = ARGV.last.to_i if ARGV.size > 1
46 display = X11Display.new
47 output = XVideoOutput.new
48 w, h = ( input.width * input.aspect_ratio ).to_i, input.height
49 window = X11Window.new display, output, w, h
50 window.title = ARGV.first
51 if input.has_audio?
52 alsa = AlsaOutput.new 'default:0', input.sample_rate, input.channels, 16, 1024
53 audio_frame = input.read_audio
54 else
55 t0 = Time.new.to_f
56 end
57 window.show
58 while display.status?
59 video_frame = input.read_video
60 if input.has_audio?
61 while alsa.avail >= audio_frame.shape[1]
62 alsa.write audio_frame
63 audio_frame = input.read_audio
64 end
65 t = input.audio_pos - alsa.delay.quo( alsa.rate )
66 else
67 t = Time.new.to_f - t0
68 end
69 delay = [ input.video_pos - t, 0 ].max
70 display.event_loop delay
71 output.write video_frame
72 display.process_events
73 end
74
Something went wrong with that request. Please try again.