Module: FFMpeg::VideoOptions
- Included in:
- FFMpeg
- Defined in:
- lib/ffmpeg/video_options.rb
Instance Method Summary collapse
-
#aspect(aspect) ⇒ Object
Set aspect ratio (4:3, 16:9 or 1.3333, 1.7777).
-
#crop_bottom(size) ⇒ Object
Set bottom crop band size (in pixels).
-
#crop_left(size) ⇒ Object
Set left crop band size (in pixels).
-
#crop_right(size) ⇒ Object
Set right crop band size (in pixels).
-
#crop_top(size) ⇒ Object
Set top crop band size (in pixels).
-
#disable_video ⇒ Object
Disable video recording.
-
#framerate(fps) ⇒ Object
Set frame rate (Hz value, fraction or abbreviation), (default = 25).
-
#new_video ⇒ Object
Add a new video stream to the current output stream.
-
#pad_bottom(size) ⇒ Object
Set bottom pad band size (in pixels).
-
#pad_color(color) ⇒ Object
Set color of padded bands.
-
#pad_left(size) ⇒ Object
Set left pad band size (in pixels).
-
#pad_right(size) ⇒ Object
Set right pad band size (in pixels).
-
#pad_top(size) ⇒ Object
Set top pad band size (in pixels).
-
#resolution(resolution) ⇒ Object
Set frame size.
-
#same_video_quality ⇒ Object
Use same video quality as source (implies VBR).
-
#video_bitrate(bitrate) ⇒ Object
Set the video bitrate in bit/s (default = 200 kb/s or ‘200k’).
-
#video_bitrate_tolerance(tolerance) ⇒ Object
Set video bitrate tolerance (in bits, default 4000k).
-
#video_buffer_size(size) ⇒ Object
Set video buffer verifier buffer size (in bits).
-
#video_codec(codec) ⇒ Object
‘-vcodec codec’ Force video codec to codec.
-
#video_frames(number) ⇒ Object
Set the number of video frames to record.
-
#video_maximum_bitrate(bitrate) ⇒ Object
Set max video bitrate (in bit/s).
-
#video_minimum_bitrate(bitrate) ⇒ Object
Set min video bitrate (in bit/s).
-
#video_pass(index) ⇒ Object
Select the pass number (1 or 2).
-
#video_pass_logfile(prefix) ⇒ Object
Set two-pass log file name prefix to prefix, the default file name prefix is “ffmpeg2pass”.
Instance Method Details
#aspect(aspect) ⇒ Object
Set aspect ratio (4:3, 16:9 or 1.3333, 1.7777).
84 85 86 |
# File 'lib/ffmpeg/video_options.rb', line 84 def aspect(aspect) FFMpegCommand << "-aspect #{aspect}" end |
#crop_bottom(size) ⇒ Object
Set bottom crop band size (in pixels).
94 95 96 |
# File 'lib/ffmpeg/video_options.rb', line 94 def crop_bottom(size) FFMpegCommand << "-cropbottom #{size}" end |
#crop_left(size) ⇒ Object
Set left crop band size (in pixels).
99 100 101 |
# File 'lib/ffmpeg/video_options.rb', line 99 def crop_left(size) FFMpegCommand << "-cropleft #{size}" end |
#crop_right(size) ⇒ Object
Set right crop band size (in pixels).
104 105 106 |
# File 'lib/ffmpeg/video_options.rb', line 104 def crop_right(size) FFMpegCommand << "-cropright #{size}" end |
#crop_top(size) ⇒ Object
Set top crop band size (in pixels).
89 90 91 |
# File 'lib/ffmpeg/video_options.rb', line 89 def crop_top(size) FFMpegCommand << "-croptop #{size}" end |
#disable_video ⇒ Object
Disable video recording.
135 136 137 |
# File 'lib/ffmpeg/video_options.rb', line 135 def disable_video FFMpegCommand << "-vn" end |
#framerate(fps) ⇒ Object
Set frame rate (Hz value, fraction or abbreviation), (default = 25).
79 80 81 |
# File 'lib/ffmpeg/video_options.rb', line 79 def framerate(fps) FFMpegCommand << "-r #{fps}" end |
#new_video ⇒ Object
Add a new video stream to the current output stream.
193 194 195 |
# File 'lib/ffmpeg/video_options.rb', line 193 def new_video FFMpegCommand << "-newvideo" end |
#pad_bottom(size) ⇒ Object
Set bottom pad band size (in pixels).
114 115 116 |
# File 'lib/ffmpeg/video_options.rb', line 114 def pad_bottom(size) FFMpegCommand << "-padbottom #{size}" end |
#pad_color(color) ⇒ Object
Set color of padded bands. The value for padcolor is expressed as a six digit hexadecimal number where the first two digits represent red, the middle two digits green and last two digits blue (default = 000000 (black)).
130 131 132 |
# File 'lib/ffmpeg/video_options.rb', line 130 def pad_color(color) FFMpegCommand << "-padcolor #{color}" end |
#pad_left(size) ⇒ Object
Set left pad band size (in pixels).
119 120 121 |
# File 'lib/ffmpeg/video_options.rb', line 119 def pad_left(size) FFMpegCommand << "-padleft #{size}" end |
#pad_right(size) ⇒ Object
Set right pad band size (in pixels).
124 125 126 |
# File 'lib/ffmpeg/video_options.rb', line 124 def pad_right(size) FFMpegCommand << "-padright #{size}" end |
#pad_top(size) ⇒ Object
Set top pad band size (in pixels).
109 110 111 |
# File 'lib/ffmpeg/video_options.rb', line 109 def pad_top(size) FFMpegCommand << "-padtop #{size}" end |
#resolution(resolution) ⇒ Object
Set frame size. The format is ‘wxh’ (ffserver default = 160x128, ffmpeg default = same as source). The following abbreviations are recognized:
'sqcif'
128x96
'qcif'
176x144
'cif'
352x288
'4cif'
704x576
'qqvga'
160x120
'qvga'
320x240
'vga'
640x480
'svga'
800x600
'xga'
1024x768
'uxga'
1600x1200
'qxga'
2048x1536
'sxga'
1280x1024
'qsxga'
2560x2048
'hsxga'
5120x4096
'wvga'
852x480
'wxga'
1366x768
'wsxga'
1600x1024
'wuxga'
1920x1200
'woxga'
2560x1600
'wqsxga'
3200x2048
'wquxga'
3840x2400
'whsxga'
6400x4096
'whuxga'
7680x4800
'cga'
320x200
'ega'
640x350
'hd480'
852x480
'hd720'
1280x720
'hd1080'
1920x1080
64 65 66 |
# File 'lib/ffmpeg/video_options.rb', line 64 def resolution(resolution) FFMpegCommand << "-s #{resolution}" end |
#same_video_quality ⇒ Object
Use same video quality as source (implies VBR).
171 172 173 |
# File 'lib/ffmpeg/video_options.rb', line 171 def same_video_quality FFMpegCommand << "-sameq" end |
#video_bitrate(bitrate) ⇒ Object
Set the video bitrate in bit/s (default = 200 kb/s or ‘200k’).
69 70 71 |
# File 'lib/ffmpeg/video_options.rb', line 69 def video_bitrate(bitrate) FFMpegCommand << "-vb #{bitrate}" end |
#video_bitrate_tolerance(tolerance) ⇒ Object
Set video bitrate tolerance (in bits, default 4000k). Has a minimum value of: (target_bitrate/target_framerate). In 1-pass mode, bitrate tolerance specifies how far ratecontrol is willing to deviate from the target average bitrate value. This is not related to min/max bitrate. Lowering tolerance too much has an adverse effect on quality.
143 144 145 |
# File 'lib/ffmpeg/video_options.rb', line 143 def video_bitrate_tolerance(tolerance) FFMpegCommand << "-bt #{tolerance}" end |
#video_buffer_size(size) ⇒ Object
Set video buffer verifier buffer size (in bits).
160 161 162 |
# File 'lib/ffmpeg/video_options.rb', line 160 def video_buffer_size(size) FFMpegCommand << "-bufsize #{size}" end |
#video_codec(codec) ⇒ Object
‘-vcodec codec’ Force video codec to codec. Use the copy special value to tell that the raw codec data must be copied as is.
166 167 168 |
# File 'lib/ffmpeg/video_options.rb', line 166 def video_codec(codec) FFMpegCommand << "-vcodec #{codec}" end |
#video_frames(number) ⇒ Object
Set the number of video frames to record.
74 75 76 |
# File 'lib/ffmpeg/video_options.rb', line 74 def video_frames(number) FFMpegCommand << "-vframes #{number}" end |
#video_maximum_bitrate(bitrate) ⇒ Object
Set max video bitrate (in bit/s). Requires -bufsize to be set.
148 149 150 |
# File 'lib/ffmpeg/video_options.rb', line 148 def video_maximum_bitrate(bitrate) FFMpegCommand << "-maxrate #{bitrate}" end |
#video_minimum_bitrate(bitrate) ⇒ Object
Set min video bitrate (in bit/s). Most useful in setting up a CBR encode: ffmpeg -i myfile.avi -b 4000k -minrate 4000k -maxrate 4000k -bufsize 1835k out.m2v It is of little use elsewise.
155 156 157 |
# File 'lib/ffmpeg/video_options.rb', line 155 def video_minimum_bitrate(bitrate) FFMpegCommand << "-minrate #{bitrate}" end |
#video_pass(index) ⇒ Object
Select the pass number (1 or 2). It is used to do two-pass video encoding. The statistics of the video are recorded in the first pass into a log file (see also the option -passlogfile), and in the second pass that log file is used to generate the video at the exact requested bitrate. On pass 1, you may just deactivate audio and set output to null, examples for Windows and Unix:
ffmpeg -i foo.mov -vcodec libxvid -pass 1 -an -f rawvideo -y NUL ffmpeg -i foo.mov -vcodec libxvid -pass 1 -an -f rawvideo -y /dev/null
182 183 184 |
# File 'lib/ffmpeg/video_options.rb', line 182 def video_pass(index) FFMpegCommand << "-pass #{index}" end |
#video_pass_logfile(prefix) ⇒ Object
Set two-pass log file name prefix to prefix, the default file name prefix is “ffmpeg2pass”. The complete file name will be ‘PREFIX-N.log’, where N is a number specific to the output stream.
188 189 190 |
# File 'lib/ffmpeg/video_options.rb', line 188 def video_pass_logfile(prefix) FFMpegCommand << "-passlogfile #{prefix}" end |