class MultimediaParadise::ConvertAudioToVideoWithImage

Public Class Methods

[](i = '') click to toggle source
#

MultimediaParadise::ConvertAudioToVideoWithImage[]

#
# File lib/multimedia_paradise/multimedia/convert_audio_to_video_with_image.rb, line 142
def self.[](i = '')
  new(i)
end
new( audio_file = nil, image_file = nil, run_already = true ) { || ... } click to toggle source
#

initialize

#
# File lib/multimedia_paradise/multimedia/convert_audio_to_video_with_image.rb, line 31
def initialize(
    audio_file  = nil,
    image_file  = nil,
    run_already = true
  )
  reset
  set_use_this_audio_file(audio_file)
  set_use_this_image_file(image_file)
  if block_given?
    yielded = yield
    case yielded
    # === :to_mp4
    when :to_mp4
      do_store_as_mp4_file
    end
  end
  run if run_already
end

Public Instance Methods

audio_file?() click to toggle source
#

audio_file?

#
# File lib/multimedia_paradise/multimedia/convert_audio_to_video_with_image.rb, line 79
def audio_file?
  @use_this_audio_file
end
do_store_as_mp4_file() click to toggle source
#

do_store_as_mp4_file

#
# File lib/multimedia_paradise/multimedia/convert_audio_to_video_with_image.rb, line 64
def do_store_as_mp4_file
  @use_this_as_file_extension_for_the_output = 'mp4'
end
do_the_conversion() click to toggle source
#

do_the_conversion

This is the method that does the actual conversion-step.

#
# File lib/multimedia_paradise/multimedia/convert_audio_to_video_with_image.rb, line 103
def do_the_conversion
  image_file = image_file?
  e "The image `#{sfile(image_file)}` will be used."
  output_file_name = audio_file?.dup.
                     sub(/\.mp3$/,'')+
                     '.'+
                     @use_this_as_file_extension_for_the_output
  # ======================================================================= #
  # _ = 'ffmpeg -loop 1 -r 1 -i '+image_file+
  #    ' -i '+audio_file?+' '\
  #    '-c:a copy -shortest '+
  #    output_file_name
  # ======================================================================= #
  # The next one was added as of 17.05.2020.
  #
  # Example:
  #
  #   ffmpeg -i pic-0.png -i slide1_audio.mp3 -acodec copy -vcodec libx264 final.mp4
  #
  # ======================================================================= #
  _ = 'ffmpeg'\
      ' -i '+image_file+
      ' -i '+audio_file?+
      ' -acodec copy'+
      ' -vcodec libx264'+
      ' '+output_file_name
  esystem _
end
image_file?() click to toggle source
#

image_file?

#
# File lib/multimedia_paradise/multimedia/convert_audio_to_video_with_image.rb, line 94
def image_file?
  @use_this_image_file
end
reset() click to toggle source
#

reset (reset tag)

#
Calls superclass method MultimediaParadise::Base#reset
# File lib/multimedia_paradise/multimedia/convert_audio_to_video_with_image.rb, line 53
def reset
  super()
  # ======================================================================= #
  # === @use_this_as_file_extension_for_the_output
  # ======================================================================= #
  @use_this_as_file_extension_for_the_output = 'avi'
end
run() click to toggle source
#

run (run tag)

#
# File lib/multimedia_paradise/multimedia/convert_audio_to_video_with_image.rb, line 135
def run
  do_the_conversion
end
set_use_this_audio_file(i) click to toggle source
#

set_use_this_audio_file

#
# File lib/multimedia_paradise/multimedia/convert_audio_to_video_with_image.rb, line 71
def set_use_this_audio_file(i)
  i = i.first if i.is_a? Array
  @use_this_audio_file = i
end
set_use_this_image_file(i) click to toggle source
#

set_use_this_image_file

#
# File lib/multimedia_paradise/multimedia/convert_audio_to_video_with_image.rb, line 86
def set_use_this_image_file(i)
  i = i.first if i.is_a? Array
  @use_this_image_file = i
end