@xKISHARRAx

Откуда после конвертации с помощью ffmpeg появляется лишний бинарный поток в метаданных файла?

Есть у меня условно видеофайл в котором 12 потоков (разные аудио дорожки, субтитры и т.д.). После конвертации с помощью ffmpeg и выбрав только два основных потока (один видео и один аудио) появляется третий поток, который промаркирован как бинарный, что в нем я не знаю. Вопрос такой, как его убрать? Если кто-то сталкивался, подскажите пожалуйста. Ниже приложу код
def run_ffmpeg(self, input_file, output_file, bitrate):
        '''run ffmpeg command'''
        try:
            command = [arg.format(input_file=input_file, output_file=output_file, b_v=bitrate, b_a=self.b_a) for arg in self.ffmpeg_command]  #run ffmpeg command which is in config
            subprocess.run(command, check=True)
            return True
        except subprocess.CalledProcessError as e:
            logging.error(f"Error running ffmpeg: {e}")
            return False
def convert_files(self):
        '''convert files to mp4 format'''
        signal.signal(signal.SIGINT, self.signal_handler)  #register signal handler

        video_files = self.db_file.select_data()

        for file_id, IsFilm, IsConverted, filename, nb_streams, streams in video_files:  #iterate through files
            self.file_id = file_id
            if self.interrupted:
                break
                
            if nb_streams > 2:  #check if file contains more than 2 streams
                streams_info = json.loads(streams)
                video_streams = [stream for stream in streams_info if stream['codec_type'] == 'video' and stream['index'] == 0]
                audio_streams = [stream for stream in streams_info if stream['codec_type'] == 'audio' and 'rus' in stream.get('tags', {}).get('language', '') and stream['codec_name'] == 'ac3' and stream['disposition'].get('default', 0) == 1 or stream['index'] == 1]
                
                if not IsConverted:
                    
                    if len(video_streams) > 0 and len(audio_streams) > 0:  #check if file contains video and audio streams
                        output_file = os.path.splitext(filename)[0] + '.mp4'  #create output file
                        self.remove_list.append(output_file)  #add file to remove list
                            
                        self.db_file.update_status_of_conversion(file_id, 'converting', datetime.now().strftime(self.data_format))

                        try:
                            if IsFilm:  #check if file is a film
                                bitrate = self.bitrate_video_film  #set bitrate
                            else:
                                bitrate = self.bitrate_video_serials
                            self.run_ffmpeg(filename, output_file, bitrate)  #run ffmpeg
                    
                            success, check_result = self.check_integrity(output_file)  #check if output file is corrupted
                            if success:
                                self.db_file.update_status_ending_conversion('done', datetime.now().strftime(self.data_format), check_result, file_id)
                                video_info = self.get_info.run_ffprobe(output_file)  #get video info of converted file
                                if video_info:
                                    streams = self.get_info.streams_data(video_info)  #get streams info of converted file
                                    self.db_file.update_files_table(output_file, True, len(streams), json.dumps(streams), file_id)  #update table 'Files' with new data
                            else:
                                logging.error(f'{filename}: {check_result}')
                                self.db_file. update_of_checking_integrity('Error', datetime.now().strftime(self.data_format), 'Error: check logs', file_id)  #update status of checking

                        except Exception as e:  #catch errors
                            error_messege = str(e)
                            logging.error(f'{filename}: {error_messege}')  #logging errors

До конвертации информация о потоках:
[{"index": 0, "codec_name": "h264", "codec_long_name": "H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10", "codec_type": "video", "disposition": {"default": 1}, "tags": {"language": null, "title": null}}, {"index": 1, "codec_name": "dts", "codec_long_name": "DCA (DTS Coherent Acoustics)", "codec_type": "audio", "disposition": {"default": 0}, "tags": {"language": "rus", "title": "DTS 5.1 @ 768 kbps - Dub, BD EUR"}}, {"index": 2, "codec_name": "ac3", "codec_long_name": "ATSC A/52A (AC-3)", "codec_type": "audio", "disposition": {"default": 0}, "tags": {"language": "rus", "title": "\u0410\u04213 5.1 @ 384 kbps - AVO, Ivanov"}}, {"index": 3, "codec_name": "ac3", "codec_long_name": "ATSC A/52A (AC-3)", "codec_type": "audio", "disposition": {"default": 0}, "tags": {"language": "ukr", "title": "\u0410\u04213 2.0 @ 192 kbps - DVO, TET"}}, {"index": 4, "codec_name": "dts", "codec_long_name": "DCA (DTS Coherent Acoustics)", "codec_type": "audio", "disposition": {"default": 0}, "tags": {"language": "eng", "title": "DTS 5.1 @ 1509 kbps - Original"}}, {"index": 5, "codec_name": "subrip", "codec_long_name": "SubRip subtitle", "codec_type": "subtitle", "disposition": {"default": 0}, "tags": {"language": "rus", "title": "Full"}}, {"index": 6, "codec_name": "subrip", "codec_long_name": "SubRip subtitle", "codec_type": "subtitle", "disposition": {"default": 1}, "tags": {"language": "rus", "title": "Forced"}}, {"index": 7, "codec_name": "subrip", "codec_long_name": "SubRip subtitle", "codec_type": "subtitle", "disposition": {"default": 0}, "tags": {"language": "ukr", "title": "Full"}}, {"index": 8, "codec_name": "subrip", "codec_long_name": "SubRip subtitle", "codec_type": "subtitle", "disposition": {"default": 0}, "tags": {"language": "eng", "title": "Full"}}, {"index": 9, "codec_name": "subrip", "codec_long_name": "SubRip subtitle", "codec_type": "subtitle", "disposition": {"default": 0}, "tags": {"language": "eng", "title": "Full SDH"}}, {"index": 10, "codec_name": "subrip", "codec_long_name": "SubRip subtitle", "codec_type": "subtitle", "disposition": {"default": 0}, "tags": {"language": "eng", "title": "Full SDH Colored"}}, {"index": 11, "codec_name": "png", "codec_long_name": "PNG (Portable Network Graphics) image", "codec_type": "video", "disposition": {"default": 0}, "tags": {"language": null, "title": null}}]


Информация о потоках после конвертации:
[{"index": 0, "codec_name": "h264", "codec_long_name": "H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10", "codec_type": "video", "disposition": {"default": 1}, "tags": {"language": "und", "title": null}}, {"index": 1, "codec_name": "ac3", "codec_long_name": "ATSC A/52A (AC-3)", "codec_type": "audio", "disposition": {"default": 1}, "tags": {"language": "rus", "title": null}}, {"index": 2, "codec_name": "bin_data", "codec_long_name": "binary data", "codec_type": "data", "disposition": {"default": 0}, "tags": {"language": "eng", "title": null}}]


Вот команда для конвертации, она хранится в отдельном json конфиге:
"ffmpeg_command": [
      "ffmpeg",
      "-i", "{input_file}",
      "-c:v", "libx264",
      "-c:a", "ac3",
      "-map", "0:v:0",
      "-map", "0:a:0",
      "-b:v", "{b_v}",
      "-b:a", "{b_a}",
      "-preset:v", "ultrafast",
      "-strict", "experimental",
      "-movflags", "+faststart",
      "{output_file}"
    ],
  • Вопрос задан
  • 75 просмотров
Пригласить эксперта
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы
SpectrumData Екатеринбург
от 150 000 до 250 000 ₽
Гринатом Москва
от 150 000 ₽
DIGITAL SECTOR Краснодар
от 150 000 до 250 000 ₽
27 июн. 2024, в 10:20
1000 руб./за проект
27 июн. 2024, в 09:54
3000 руб./за проект