GilangAlRusliadi commited on
Commit
d8344ef
·
1 Parent(s): 55cd4b4
Files changed (2) hide show
  1. others.py +20 -36
  2. trailer.py +1 -1
others.py CHANGED
@@ -275,44 +275,28 @@ def convert_videos(height, filename):
275
 
276
  return output_file
277
 
278
- def join_video():
279
- # Tentukan direktori untuk gambar, video, dan output
280
- image_dir = '/home/user/app/Trailer/Thumbnail'
281
- if not os.path.exists(image_dir):
282
- os.makedirs(image_dir)
283
- video_dir = '/home/user/app/Hasil Konversi'
284
- if not os.path.exists(video_dir):
285
- os.makedirs(video_dir)
286
- video_path = '/home/user/app/Trailer/Video'
287
- if not os.path.exists(video_path):
288
- os.makedirs(video_path)
289
 
290
  # Tentukan jalur ke file audio yang akan digunakan untuk intro
291
  audio_file = './sound.wav'
292
-
293
- # Dapatkan daftar file video di direktori video
294
- video_files = os.listdir(video_dir)
295
-
296
- # Ulangi daftar file video
297
- for video_file in video_files:
298
- # Dapatkan nama file video tanpa ekstensi
299
- name = os.path.splitext(video_file)[0]
300
- # Temukan file gambar yang sesuai
301
- image_file = find_image_file(name, image_dir)
302
- # Periksa apakah file gambar ada
303
- if image_file:
304
- output_dir = '/home/user/app/Hasil Join'
305
- if not os.path.exists(output_dir):
306
- os.makedirs(output_dir)
307
- # Tentukan jalur ke file output
308
- output_file = os.path.join(output_dir, f'{name}.mp4')
309
- # Gunakan ffmpeg untuk membuat video 1 detik dari file gambar dan audio
310
- os.system(f"ffmpeg -loop 1 -i {image_file} -i {audio_file} -c:v libx264 -b:v 850k -bufsize 1000k -r 30 -b:a 160k -ar 44100 -ac 2 -t 1 -pix_fmt yuv420p -vf scale=1280:720 -shortest {name}.mp4")
311
- # Gunakan ffmpeg untuk menggabungkan intro dan video
312
- with open('input.txt', 'w') as f:
313
- f.write(f"file '{name}.mp4'\n")
314
- f.write(f"file '{os.path.join(video_dir, video_file)}'\n")
315
- os.system( f"ffmpeg -f concat -safe 0 -i input.txt -c:v libx264 -b:v 850k -bufsize 1000k -r 30 -b:a 160k -ar 44100 -ac 2 -c:a aac -pix_fmt yuv420p -vf scale=1280:720 {output_file}")
316
- print(f"Video intro dan video asli berhasil digabungkan menjadi {output_file}")
317
 
318
  return output_file
 
275
 
276
  return output_file
277
 
278
+ def join_video(thumbnail_file, video_file):
 
 
 
 
 
 
 
 
 
 
279
 
280
  # Tentukan jalur ke file audio yang akan digunakan untuk intro
281
  audio_file = './sound.wav'
282
+
283
+ # Dapatkan nama file video tanpa ekstensi
284
+ name = os.path.splitext(video_file)[0]
285
+ # Temukan file gambar yang sesuai
286
+ image_file = thumbnail_file
287
+ # Periksa apakah file gambar ada
288
+ if image_file:
289
+ output_dir = '/home/user/app/Hasil Join'
290
+ if not os.path.exists(output_dir):
291
+ os.makedirs(output_dir)
292
+ # Tentukan jalur ke file output
293
+ output_file = f'{output_dir}/{name}.mp4'
294
+ # Gunakan ffmpeg untuk membuat video 1 detik dari file gambar dan audio
295
+ os.system(f"ffmpeg -loop 1 -i {image_file} -i {audio_file} -c:v libx264 -b:v 850k -bufsize 1000k -r 30 -b:a 160k -ar 44100 -ac 2 -t 1 -pix_fmt yuv420p -vf scale=1280:720 -shortest {name}.mp4")
296
+ # Gunakan ffmpeg untuk menggabungkan intro dan video
297
+ with open('input.txt', 'w') as f:
298
+ f.write(f"file '{name}.mp4'\n")
299
+ f.write(f"file '{video_file}'\n")
300
+ os.system( f"ffmpeg -f concat -safe 0 -i input.txt -c:v libx264 -b:v 850k -bufsize 1000k -r 30 -b:a 160k -ar 44100 -ac 2 -c:a aac -pix_fmt yuv420p -vf scale=1280:720 {output_file}")
 
 
 
 
 
 
301
 
302
  return output_file
trailer.py CHANGED
@@ -27,7 +27,7 @@ def trailer(url):
27
  output_file = convert_videos(720, video_file)
28
  print("==================================================================================")
29
  # Menggabungkan video
30
- output_file = join_video()
31
  print("==================================================================================")
32
 
33
  video_info = "Series: {series}/n"
 
27
  output_file = convert_videos(720, video_file)
28
  print("==================================================================================")
29
  # Menggabungkan video
30
+ output_file = join_video(thumbnail_file, video_file)
31
  print("==================================================================================")
32
 
33
  video_info = "Series: {series}/n"