module Video2gif::FFmpeg::Subtitles::ClassMethods
Public Instance Methods
bitmap_subtitles_scale_overlay(options)
click to toggle source
# File lib/video2gif/ffmpeg/subtitles.rb, line 77 def bitmap_subtitles_scale_overlay(options) if has_bitmap_subtitles(options) [ subtitles_scale(options), subtitles_overlay ] end end
has_bitmap_subtitles(options)
click to toggle source
# File lib/video2gif/ffmpeg/subtitles.rb, line 54 def has_bitmap_subtitles(options) has_subtitles(options) && KNOWN_BITMAP_FORMATS.include?(subtitle_info(options)[:codec_name]) end
has_subtitles(options)
click to toggle source
# File lib/video2gif/ffmpeg/subtitles.rb, line 43 def has_subtitles(options) options[:subtitles] && options[:probe_infos][:streams].any? { |s| s[:codec_type] == 'subtitle' } end
has_text_subtitles(options)
click to toggle source
# File lib/video2gif/ffmpeg/subtitles.rb, line 58 def has_text_subtitles(options) has_subtitles(options) && KNOWN_TEXT_FORMATS.include?(subtitle_info(options)[:codec_name]) end
subtitle_info(options)
click to toggle source
# File lib/video2gif/ffmpeg/subtitles.rb, line 47 def subtitle_info(options) if has_subtitles(options) options[:probe_infos][:streams].find_all { |s| s[:codec_type] == 'subtitle' } .fetch(options[:subtitle_index], nil) end end
subtitles_overlay()
click to toggle source
# File lib/video2gif/ffmpeg/subtitles.rb, line 73 def subtitles_overlay '[0:v][subs]overlay=format=auto' end
subtitles_scale(options)
click to toggle source
# File lib/video2gif/ffmpeg/subtitles.rb, line 62 def subtitles_scale(options) scale_parameters = [] scale_parameters << 'flags=lanczos' scale_parameters << 'sws_dither=none' scale_parameters << "width=#{video_info(options)[:width]}" scale_parameters << "height=#{video_info(options)[:height]}" "[0:s:#{options[:subtitle_index]}]scale=#{scale_parameters.join(':')}[subs]" end
text_subtitles(options)
click to toggle source
# File lib/video2gif/ffmpeg/subtitles.rb, line 86 def text_subtitles(options) if has_text_subtitles(options) %W[ setpts=PTS+#{Utils.duration_to_seconds(options[:seek])}/TB subtitles='#{options[:input_filename]}':si=#{options[:subtitle_index]} setpts=PTS-STARTPTS ] end end