Module: Video2gif::FFmpeg::Subtitles::ClassMethods
- Defined in:
- lib/video2gif/ffmpeg/subtitles.rb
Instance Method Summary collapse
- #bitmap_subtitles_scale_overlay(options) ⇒ Object
- #has_bitmap_subtitles(options) ⇒ Object
- #has_subtitles(options) ⇒ Object
- #has_text_subtitles(options) ⇒ Object
- #subtitle_info(options) ⇒ Object
- #subtitles_overlay ⇒ Object
- #subtitles_scale(options) ⇒ Object
- #text_subtitles(options) ⇒ Object
Instance Method Details
#bitmap_subtitles_scale_overlay(options) ⇒ Object
77 78 79 80 81 82 83 84 |
# File 'lib/video2gif/ffmpeg/subtitles.rb', line 77 def () if has_bitmap_subtitles() [ subtitles_scale(), ] end end |
#has_bitmap_subtitles(options) ⇒ Object
54 55 56 |
# File 'lib/video2gif/ffmpeg/subtitles.rb', line 54 def has_bitmap_subtitles() has_subtitles() && KNOWN_BITMAP_FORMATS.include?(subtitle_info()[:codec_name]) end |
#has_subtitles(options) ⇒ Object
43 44 45 |
# File 'lib/video2gif/ffmpeg/subtitles.rb', line 43 def has_subtitles() [:subtitles] && [:probe_infos][:streams].any? { |s| s[:codec_type] == 'subtitle' } end |
#has_text_subtitles(options) ⇒ Object
58 59 60 |
# File 'lib/video2gif/ffmpeg/subtitles.rb', line 58 def has_text_subtitles() has_subtitles() && KNOWN_TEXT_FORMATS.include?(subtitle_info()[:codec_name]) end |
#subtitle_info(options) ⇒ Object
47 48 49 50 51 52 |
# File 'lib/video2gif/ffmpeg/subtitles.rb', line 47 def subtitle_info() if has_subtitles() [:probe_infos][:streams].find_all { |s| s[:codec_type] == 'subtitle' } .fetch([:subtitle_index], nil) end end |
#subtitles_overlay ⇒ Object
73 74 75 |
# File 'lib/video2gif/ffmpeg/subtitles.rb', line 73 def '[0:v][subs]overlay=format=auto' end |
#subtitles_scale(options) ⇒ Object
62 63 64 65 66 67 68 69 70 71 |
# File 'lib/video2gif/ffmpeg/subtitles.rb', line 62 def subtitles_scale() scale_parameters = [] scale_parameters << 'flags=lanczos' scale_parameters << 'sws_dither=none' scale_parameters << "width=#{video_info()[:width]}" scale_parameters << "height=#{video_info()[:height]}" "[0:s:#{[:subtitle_index]}]scale=#{scale_parameters.join(':')}[subs]" end |
#text_subtitles(options) ⇒ Object
86 87 88 89 90 91 92 93 94 |
# File 'lib/video2gif/ffmpeg/subtitles.rb', line 86 def text_subtitles() if has_text_subtitles() %W[ setpts=PTS+#{Utils.duration_to_seconds([:seek])}/TB subtitles='#{[:input_filename]}':si=#{[:subtitle_index]} setpts=PTS-STARTPTS ] end end |