understanding commited on
Commit
b34dcc3
Β·
verified Β·
1 Parent(s): 730abe3

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -6
app.py CHANGED
@@ -61,24 +61,27 @@ def process_video_task(url: str, cookie: Optional[str], task_id: str):
61
  for chunk in r.iter_bytes(chunk_size=8192):
62
  f.write(chunk)
63
 
64
- # 2. Update DB: Encoding
65
  db.execute("UPDATE jobs SET status = 'encoding' WHERE task_id = ?", (task_id,))
66
  db.commit()
67
 
 
 
 
 
 
68
  (
69
  ffmpeg
70
  .input(temp_in_path)
71
- .output(temp_out_path, vcodec='libx264', crf=23, acodec='aac', movflags='+faststart')
72
  .run(capture_stdout=True, capture_stderr=True)
73
  )
74
 
75
- #
76
- # βœ…βœ…βœ… FIX: Get duration using ffprobe βœ…βœ…βœ…
77
- #
78
  probe = ffmpeg.probe(temp_out_path)
79
  duration = int(float(probe['format']['duration'])) # Get duration in seconds
80
 
81
- # 3. Update DB: Complete
82
  final_file_name = f"{task_id}_out.mp4"
83
  db.execute(
84
  "UPDATE jobs SET status = 'complete', file_name = ?, duration = ? WHERE task_id = ?",
 
61
  for chunk in r.iter_bytes(chunk_size=8192):
62
  f.write(chunk)
63
 
64
+ # 2. Update DB: "Fixing" (not encoding)
65
  db.execute("UPDATE jobs SET status = 'encoding' WHERE task_id = ?", (task_id,))
66
  db.commit()
67
 
68
+ #
69
+ # βœ…βœ…βœ… THE FIX IS HERE βœ…βœ…βœ…
70
+ # We changed this from vcodec='libx264' to 'c=copy'
71
+ # This is the FAST (0% CPU) "re-package"
72
+ #
73
  (
74
  ffmpeg
75
  .input(temp_in_path)
76
+ .output(temp_out_path, c='copy', movflags='+faststart') # <-- CHANGED
77
  .run(capture_stdout=True, capture_stderr=True)
78
  )
79
 
80
+ # 3. Get duration using ffprobe
 
 
81
  probe = ffmpeg.probe(temp_out_path)
82
  duration = int(float(probe['format']['duration'])) # Get duration in seconds
83
 
84
+ # 4. Update DB: Complete
85
  final_file_name = f"{task_id}_out.mp4"
86
  db.execute(
87
  "UPDATE jobs SET status = 'complete', file_name = ?, duration = ? WHERE task_id = ?",