mzltest commited on
Commit
ac1411c
·
1 Parent(s): 88e588e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +14 -1
app.py CHANGED
@@ -120,7 +120,20 @@ def downloadTubeUpload(query):
120
  print(aurl)
121
  command = f'wget "{aurl}" -O temp.mp4'
122
  os.system(command)
123
- command= f'curl --url https://www.lalal.ai/api/upload/ --data-binary @temp.mp4 --header "Content-Disposition: attachment; filename=temp.mp4" -s'
 
 
 
 
 
 
 
 
 
 
 
 
 
124
  moutput=getoutput(command)
125
  print(moutput)
126
  upload_response=json.loads(moutput)
 
120
  print(aurl)
121
  command = f'wget "{aurl}" -O temp.mp4'
122
  os.system(command)
123
+
124
+ result = os.popen('ffprobe -v error -show_entries format=duration -of default=noprint_wrappers=1:nokey=1 temp.mp4')
125
+ duration = float(result.read().strip())
126
+
127
+ # 计算需要截取的时间区间
128
+ start_time = max(0, (duration - 60) / 2)
129
+ end_time = start_time + 60
130
+ start_time = int(start_time * 1000)
131
+ end_time = int(end_time * 1000)
132
+
133
+ # 使用ffmpeg进行截取
134
+ os.system(f'ffmpeg -i temp.mp4 -ss {start_time} -t {end_time - start_time} -c copy output.mp4')
135
+
136
+ command= f'curl --url https://www.lalal.ai/api/upload/ --data-binary @output.mp4 --header "Content-Disposition: attachment; filename=output.mp4" -s'
137
  moutput=getoutput(command)
138
  print(moutput)
139
  upload_response=json.loads(moutput)