@@ -956,21 +956,21 @@ def update_progress(progress):
956956 compressed_chunk_writer = compressed_chunk_writer_class (db_data .image_quality , ** kwargs )
957957 original_chunk_writer = original_chunk_writer_class (original_quality , ** kwargs )
958958
959- # def get_file_encoding(file_path):
960- # import chardet
959+ def get_file_encoding (file_path ):
960+ import chardet
961961
962- # with open(file_path, 'rb') as f:
963- # rawdata = f.read(1024)
964- # result = chardet.detect(rawdata)
965- # encoding = result['encoding']
962+ with open (file_path , 'rb' ) as f :
963+ rawdata = f .read (1024 )
964+ result = chardet .detect (rawdata )
965+ encoding = result ['encoding' ]
966966
967- # return encoding
967+ return encoding
968968 def get_audio_duration (file_path ):
969- # encoding=get_file_encoding(file_path)
970- # slogger.glob.debug("ENCODING")
971- # slogger.glob.debug(encoding)
969+ encoding = get_file_encoding (file_path )
970+ slogger .glob .debug ("ENCODING" )
971+ slogger .glob .debug (encoding )
972972 # Open the audio file
973- container = av .open (file_path )
973+ container = av .open (file_path , metadata_encoding = encoding )
974974
975975 # Get the first audio stream
976976 audio_stream = next ((stream for stream in container .streams if stream .codec .type == 'audio' ), None )
@@ -1000,6 +1000,7 @@ def get_audio_duration(file_path):
10001000
10011001 segment_duration = db_task .segment_duration
10021002 db_task .data .audio_total_duration = get_audio_duration (details ['source_path' ][0 ])
1003+ # db_task.data.audio_total_duration = 720000 #get_audio_duration(details['source_path'][0])
10031004 total_audio_frames = extractor .get_total_frames ()
10041005
10051006 slogger .glob .debug ("TOTAL AUDIO DURATION" )
0 commit comments