class MultimediaParadise::Video::Watermark
Constants
- NAMESPACE
#¶ ↑
NAMESPACE
¶ ↑#¶ ↑
- OVERLAY_POSITION
#¶ ↑
OVERLAY_POSITION
¶ ↑This may specify where the overlayed image is situated.
#¶ ↑
- USE_THIS_IMAGE_AS_WATERMARK
#¶ ↑
USE_THIS_IMAGE_AS_WATERMARK
¶ ↑Which image to use a watermark. This will become the ivar @image_to_use_as_watermark.
#¶ ↑
USE_THIS_IMAGE_AS_WATERMARK
= ‘/home/x/DATA/IMG/NJOY/RandomBeachGal.jpg’
Public Class Methods
new( commandline_arguments = ARGV, run_already = true )
click to toggle source
#¶ ↑
initialize¶ ↑
The first input is the file that will be modified via a watermark.
The second input is the image we use as watermark.
#¶ ↑
# File lib/multimedia_paradise/video/watermark.rb, line 66 def initialize( commandline_arguments = ARGV, run_already = true ) reset set_commandline_arguments( commandline_arguments ) run if run_already end
Public Instance Methods
determine_which_image_to_use_and_which_videofile_to_use()
click to toggle source
#¶ ↑
determine_which_image_to_use_and_which_videofile_to_use
¶ ↑
#¶ ↑
# File lib/multimedia_paradise/video/watermark.rb, line 241 def determine_which_image_to_use_and_which_videofile_to_use first_argument = @commandline_arguments.first second_argument = @commandline_arguments[1] set_videofile(first_argument) set_image(second_argument) end
output_file?()
click to toggle source
#¶ ↑
output_file? (output tag)¶ ↑
#¶ ↑
# File lib/multimedia_paradise/video/watermark.rb, line 162 def output_file? @name_of_output_file end
Also aliased as: output?
process_each_video_now()
click to toggle source
#¶ ↑
process_each_video_now
¶ ↑
#¶ ↑
# File lib/multimedia_paradise/video/watermark.rb, line 216 def process_each_video_now @videofile.each {|entry| _ = "ffmpeg -i #{entry}".dup _ << ' -strict -2' _ << ' -y' # We will always overwrite, hence this option. _ << ' -vf "movie='+@image_to_use_as_watermark+ ' [watermark]; [in][watermark] overlay='+OVERLAY_POSITION+' [out]" ' _ << output_file? e simp(_) # Better to have colours. system(_) } end
report()
click to toggle source
reset()
click to toggle source
#¶ ↑
reset (reset tag)¶ ↑
#¶ ↑
Calls superclass method
MultimediaParadise::Base#reset
# File lib/multimedia_paradise/video/watermark.rb, line 80 def reset super() # ======================================================================= # # === @namespace # ======================================================================= # @namespace = NAMESPACE # ======================================================================= # # === @videofile # ======================================================================= # @videofile = nil # ======================================================================= # # Provide a default watermark-logo next. # ======================================================================= # set_image_to_use_as_watermark( USE_THIS_IMAGE_AS_WATERMARK ) set_name_of_output_file end
run()
click to toggle source
sanitize_name_of_output_file()
click to toggle source
set_commandline_arguments( i )
click to toggle source
set_image_to_use_as_watermark(i = :rand)
click to toggle source
#¶ ↑
set_image_to_use_as_watermark
¶ ↑
Set the image you want to use for watermarking here.
#¶ ↑
# File lib/multimedia_paradise/video/watermark.rb, line 190 def set_image_to_use_as_watermark(i = :rand) i = i.to_s if i.include? '--' i = i.scan(/-?-?image=(.+)/).flatten.first.to_s end case i # ======================================================================= # # === rand # ======================================================================= # when /^rand/ i = Dir[File.dirname(USE_THIS_IMAGE_AS_WATERMARK)+'/*'].sample else if Cyberweb.web_images_does_include?(i) i = Cyberweb.get_webimage(i) end end # ======================================================================= # # Next, assign to @image_to_use_as_watermark. We will use # this as path to the image file in question. # ======================================================================= # @image_to_use_as_watermark = i end
Also aliased as: set_image
set_name_of_output_file( i = 'watermarked_video_file_'+ File.basename( input?.gsub(/
click to toggle source
#¶ ↑
set_name_of_output_file
¶ ↑
This method-call must be after the input has been determined.
#¶ ↑
# File lib/multimedia_paradise/video/watermark.rb, line 171 def set_name_of_output_file( i = 'watermarked_video_file_'+ File.basename( input?.gsub(/#{File.extname(input_file?)}/,'') ) ) i = i.first if i.is_a? Array i = i.to_s.dup unless i.include? '/' # In this case, add the full path. i.prepend (Dir.pwd+'/').squeeze '/' end @name_of_output_file = i end
set_videofile(i = '')
click to toggle source
#¶ ↑
set_videofile
¶ ↑
#¶ ↑
# File lib/multimedia_paradise/video/watermark.rb, line 114 def set_videofile(i = '') i = i.join(' ').strip if i.is_a? Array i = i.to_s.dup case i # ======================================================================= # # === watermark --help # ======================================================================= # when /^-?-?help$/ show_help; exit # ======================================================================= # # === image=:austria # ======================================================================= # when /--image=(\S+)/ # This will match to "--image=:austria 273_Rambo.avi", see http://rubular.com/r/SwkpuftyFT set_image($1.to_s.dup) i.gsub!(/(--image=\S+)/, '') # Get rid of this part here. end @videofile = [i] set_name_of_output_file end
show_help()
click to toggle source