more things depend on gif.
This commit is contained in:
parent
1e408d9b25
commit
c1063b4ff8
1 changed files with 21 additions and 20 deletions
|
@ -200,26 +200,27 @@ class Content(models.Model):
|
||||||
if self.photo and self.photo.image.url.endswith('.gif'):
|
if self.photo and self.photo.image.url.endswith('.gif'):
|
||||||
video_path = self.photo.image.path.replace('.gif', '.mp4')
|
video_path = self.photo.image.path.replace('.gif', '.mp4')
|
||||||
image_path = self.photo.image.path.replace('.gif', '.jpg')
|
image_path = self.photo.image.path.replace('.gif', '.jpg')
|
||||||
if os.path.exists(self.photo.image.path) and not os.path.exists(video_path):
|
if os.path.exists(self.photo.image.path):
|
||||||
height = self.photo.image.height
|
if not os.path.exists(video_path):
|
||||||
if height % 2:
|
height = self.photo.image.height
|
||||||
height += 1
|
if height % 2:
|
||||||
cmd = [
|
height += 1
|
||||||
'ffmpeg',
|
cmd = [
|
||||||
'-hide_banner', '-nostats', '-loglevel', 'error',
|
'ffmpeg',
|
||||||
'-i', self.photo.image.path,
|
'-hide_banner', '-nostats', '-loglevel', 'error',
|
||||||
'-vf', 'scale=-2:%s' % height,
|
'-i', self.photo.image.path,
|
||||||
'-pix_fmt', 'yuv420p',
|
'-vf', 'scale=-2:%s' % height,
|
||||||
video_path
|
'-pix_fmt', 'yuv420p',
|
||||||
]
|
video_path
|
||||||
subprocess.call(cmd)
|
]
|
||||||
if not os.path.exists(image_path):
|
subprocess.call(cmd)
|
||||||
cmd = [
|
if not os.path.exists(image_path):
|
||||||
'ffmpeg',
|
cmd = [
|
||||||
'-hide_banner', '-nostats', '-loglevel', 'error',
|
'ffmpeg',
|
||||||
'-i', self.photo.image.path, '-frames:v', '1', image_path
|
'-hide_banner', '-nostats', '-loglevel', 'error',
|
||||||
]
|
'-i', self.photo.image.path, '-frames:v', '1', image_path
|
||||||
subprocess.call(cmd)
|
]
|
||||||
|
subprocess.call(cmd)
|
||||||
return self.photo.image.url.replace('.gif', '.mp4')
|
return self.photo.image.url.replace('.gif', '.mp4')
|
||||||
|
|
||||||
@cached_property
|
@cached_property
|
||||||
|
|
Loading…
Add table
Reference in a new issue