support for running ugoira conversion manually from console
This commit is contained in:
@@ -38,8 +38,10 @@ class PixivUgoiraConverter
|
|||||||
end
|
end
|
||||||
|
|
||||||
ext = folder.first.name.match(/\.(\w{,4})$/)[1]
|
ext = folder.first.name.match(/\.(\w{,4})$/)[1]
|
||||||
system("ffmpeg -loglevel quiet -i #{tmpdir}/images/%06d.#{ext} -codec:v libvpx -crf 4 -b:v 5000k -an #{tmpdir}/tmp.webm")
|
# system("ffmpeg -loglevel quiet -i #{tmpdir}/images/%06d.#{ext} -codec:v libvpx -crf 4 -b:v 5000k -an #{tmpdir}/tmp.webm")
|
||||||
system("mkvmerge -q -o #{write_path} --webm --timecodes 0:#{tmpdir}/timecodes.tc #{tmpdir}/tmp.webm")
|
# system("mkvmerge -q -o #{write_path} --webm --timecodes 0:#{tmpdir}/timecodes.tc #{tmpdir}/tmp.webm")
|
||||||
|
system("ffmpeg -i #{tmpdir}/images/%06d.#{ext} -codec:v libvpx -crf 4 -b:v 5000k -an #{tmpdir}/tmp.webm")
|
||||||
|
system("mkvmerge -o #{write_path} --webm --timecodes 0:#{tmpdir}/timecodes.tc #{tmpdir}/tmp.webm")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,17 @@
|
|||||||
class PixivUgoiraService
|
class PixivUgoiraService
|
||||||
attr_reader :width, :height, :frame_data, :content_type
|
attr_reader :width, :height, :frame_data, :content_type
|
||||||
|
|
||||||
|
def self.regen(post)
|
||||||
|
service = new()
|
||||||
|
service.load(
|
||||||
|
:is_ugoira => true,
|
||||||
|
:ugoira_width => post.image_width,
|
||||||
|
:ugoira_height => post.image_height,
|
||||||
|
:ugoira_frame_data => post.pixiv_ugoira_frame_data.data
|
||||||
|
)
|
||||||
|
service.generate_resizes(post.file_path, post.large_file_path, post.preview_file_path, false)
|
||||||
|
end
|
||||||
|
|
||||||
def process(post)
|
def process(post)
|
||||||
save_frame_data(post)
|
save_frame_data(post)
|
||||||
end
|
end
|
||||||
@@ -9,9 +20,13 @@ class PixivUgoiraService
|
|||||||
PixivUgoiraFrameData.create(:data => @frame_data, :content_type => @content_type, :post_id => post.id)
|
PixivUgoiraFrameData.create(:data => @frame_data, :content_type => @content_type, :post_id => post.id)
|
||||||
end
|
end
|
||||||
|
|
||||||
def generate_resizes(source_path, output_path, preview_path)
|
def generate_resizes(source_path, output_path, preview_path, delay = true)
|
||||||
# Run this a bit in the future to give the upload process time to move the file
|
# Run this a bit in the future to give the upload process time to move the file
|
||||||
PixivUgoiraConverter.delay(:queue => Socket.gethostname, :run_at => 2.seconds.from_now).convert(source_path, output_path, preview_path, @frame_data)
|
if delay
|
||||||
|
PixivUgoiraConverter.delay(:queue => Socket.gethostname, :run_at => 2.seconds.from_now).convert(source_path, output_path, preview_path, @frame_data)
|
||||||
|
else
|
||||||
|
PixivUgoiraConverter.convert(source_path, output_path, preview_path, @frame_data)
|
||||||
|
end
|
||||||
|
|
||||||
# since the resizes will be delayed, just touch the output file so the
|
# since the resizes will be delayed, just touch the output file so the
|
||||||
# file distribution wont break
|
# file distribution wont break
|
||||||
|
|||||||
Reference in New Issue
Block a user