diff options
author | Starfall <us@starfall.systems> | 2022-02-25 12:35:11 -0600 |
---|---|---|
committer | Starfall <us@starfall.systems> | 2022-02-25 12:35:11 -0600 |
commit | ad1733ea294c6049336a9aeeb7ff96c8fea22cfa (patch) | |
tree | 306ff2d36a8bce82039890c4327f7d7bf37583dc /lib | |
parent | c5f289e8ef7ec1592d068ac797add7332343820d (diff) | |
parent | e48eaf64cc7cb0cfab388331c4823ee5fb580d59 (diff) |
Merge remote-tracking branch 'glitch/main'
Diffstat (limited to 'lib')
-rw-r--r-- | lib/mastodon/statuses_cli.rb | 2 | ||||
-rw-r--r-- | lib/paperclip/transcoder.rb | 16 |
2 files changed, 16 insertions, 2 deletions
diff --git a/lib/mastodon/statuses_cli.rb b/lib/mastodon/statuses_cli.rb index e273e2614..91b08813b 100644 --- a/lib/mastodon/statuses_cli.rb +++ b/lib/mastodon/statuses_cli.rb @@ -54,7 +54,7 @@ module Mastodon ActiveRecord::Base.connection.add_index(:media_attachments, :remote_url, name: :index_media_attachments_remote_url, where: 'remote_url is not null', algorithm: :concurrently, if_not_exists: true) - max_id = Mastodon::Snowflake.id_at(options[:days].days.ago) + max_id = Mastodon::Snowflake.id_at(options[:days].days.ago, with_random: false) start_at = Time.now.to_f unless options[:continue] && ActiveRecord::Base.connection.table_exists?('statuses_to_be_deleted') diff --git a/lib/paperclip/transcoder.rb b/lib/paperclip/transcoder.rb index ec1305038..afd9f58ff 100644 --- a/lib/paperclip/transcoder.rb +++ b/lib/paperclip/transcoder.rb @@ -13,6 +13,7 @@ module Paperclip @time = options[:time] || 3 @passthrough_options = options[:passthrough_options] @convert_options = options[:convert_options].dup + @vfr_threshold = options[:vfr_frame_rate_threshold] end def make @@ -41,6 +42,11 @@ module Paperclip when 'mp4' @output_options['acodec'] = 'aac' @output_options['strict'] = 'experimental' + + if high_vfr?(metadata) && !eligible_to_passthrough?(metadata) + @output_options['vsync'] = 'vfr' + @output_options['r'] = @vfr_threshold + end end command_arguments, interpolations = prepare_command(destination) @@ -88,13 +94,21 @@ module Paperclip end def update_options_from_metadata(metadata) - return unless @passthrough_options && @passthrough_options[:video_codecs].include?(metadata.video_codec) && @passthrough_options[:audio_codecs].include?(metadata.audio_codec) && @passthrough_options[:colorspaces].include?(metadata.colorspace) + return unless eligible_to_passthrough?(metadata) @format = @passthrough_options[:options][:format] || @format @time = @passthrough_options[:options][:time] || @time @convert_options = @passthrough_options[:options][:convert_options].dup end + def high_vfr?(metadata) + @vfr_threshold && metadata.r_frame_rate && metadata.r_frame_rate > @vfr_threshold + end + + def eligible_to_passthrough?(metadata) + @passthrough_options && @passthrough_options[:video_codecs].include?(metadata.video_codec) && @passthrough_options[:audio_codecs].include?(metadata.audio_codec) && @passthrough_options[:colorspaces].include?(metadata.colorspace) + end + def update_attachment_type(metadata) @attachment.instance.type = MediaAttachment.types[:gifv] unless metadata.audio_codec end |