This commit is contained in:
j 2025-02-01 12:40:30 +05:30
parent 5ad72d2faf
commit 51eff7f9b5

View File

@ -170,20 +170,20 @@ class Content(models.Model):
('og:title', self.title), ('og:title', self.title),
] ]
if self.photo and self.photo.image.url.endswith('.gif'): if self.photo and self.photo.image.url.endswith('.gif'):
video_path = c.photo.image.path.replace('.gif', '.mp4') video_path = self.photo.image.path.replace('.gif', '.mp4')
image_path = c.photo.image.path.replace('.gif', '.jpg') image_path = self.photo.image.path.replace('.gif', '.jpg')
if not os.path.exists(video_path): if not os.path.exists(video_path):
cmd = [ cmd = [
'ffmpeg', 'ffmpeg',
'-hide_banner', '-nostats', '-loglevel', 'error', '-hide_banner', '-nostats', '-loglevel', 'error',
'-i', c.photo.image.path, video_path '-i', self.photo.image.path, video_path
] ]
subprocess.call(cmd) subprocess.call(cmd)
if not os.path.exists(image_path): if not os.path.exists(image_path):
cmd = [ cmd = [
'ffmpeg', 'ffmpeg',
'-hide_banner', '-nostats', '-loglevel', 'error', '-hide_banner', '-nostats', '-loglevel', 'error',
'-i', c.photo.image.path, '-frames:v', '1', image_path '-i', self.photo.image.path, '-frames:v', '1', image_path
] ]
subprocess.call(cmd) subprocess.call(cmd)
if os.path.exists(video_path): if os.path.exists(video_path):