summaryrefslogtreecommitdiff
path: root/cli/app/search/video.py
blob: 4f10d49563010ba38671b5bfdd514f2b46945586 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
import shutil
import os

from app.settings import app_cfg

def export_video(fp_frames, fps=30):
  print("Exporting video...")
  cmd = [
    '/home/lens/bin/ffmpeg',
    '-hide_banner',
    '-y', # '-v', 'quiet',
    '-r', fps,
    '-i', join(app_cfg.DIR_OUTPUTS, fp_frames, 'frame_%04d.png'),
    '-pix_fmt', 'yuv420p',
    join(app_cfg.DIR_OUTPUTS, fp_frames + '.mp4')
  ]
  # print(' '.join(cmd))
  call(cmd)
  shutil.rmtree(join(app_cfg.DIR_OUTPUTS, fp_frames))

def export_video_final(fp_frames):
  print("Exporting video...")
  cmd = [
    '/home/lens/bin/ffmpeg',
    '-hide_banner',
    '-y', # '-v', 'quiet',
    '-r', fps,
    '-i', join(app_cfg.DIR_OUTPUTS, fp_frames, 'frame_%05d.png'),
    '-c:v', 'libx264',
    '-preset', 'slow',
    '-crf', '19',
    '-vf', 'fps=25',
    '-pix_fmt', 'yuv420p',
    '-s', '512x512',
    join(app_cfg.DIR_RENDERS, fp_frames + '.mp4')
  ]
  # print(' '.join(cmd))
  call(cmd)
  shutil.rmtree(join(app_cfg.DIR_OUTPUTS, fp_frames))