ahmedghani commited on
Commit
066843c
β€’
1 Parent(s): 48a1732
Files changed (1) hide show
  1. video_convertor.py +2 -2
video_convertor.py CHANGED
@@ -16,7 +16,7 @@ class VideoConverter:
16
  def load_video(self):
17
  try:
18
  self.video = VideoFileClip(self.input_file)
19
- self.audio = AudioFileClip(self.input_file)
20
  except Exception as e:
21
  raise Exception(f"Error loading video: {e}")
22
 
@@ -41,7 +41,7 @@ class VideoConverter:
41
  raise Exception("No audio stream found in the input file")
42
 
43
  try:
44
- audio_segment = AudioSegment.from_file(self.input_file, self.video.audio.codec)
45
  audio_segment.export(output_file, format=format.lower())
46
  print(f"Audio converted to {format} format successfully!")
47
  return output_file
 
16
  def load_video(self):
17
  try:
18
  self.video = VideoFileClip(self.input_file)
19
+ self.audio = self.video.audio if self.video.audio is not None else None
20
  except Exception as e:
21
  raise Exception(f"Error loading video: {e}")
22
 
 
41
  raise Exception("No audio stream found in the input file")
42
 
43
  try:
44
+ audio_segment = AudioSegment.from_file(self.input_file, self.audio.codec)
45
  audio_segment.export(output_file, format=format.lower())
46
  print(f"Audio converted to {format} format successfully!")
47
  return output_file