From 69f5fe45b98ef3ecb8e5ac69ebebdce7733a3ae4 Mon Sep 17 00:00:00 2001 From: pukkandan Date: Tue, 20 Dec 2022 00:41:45 +0530 Subject: [FFmpegVideoConvertor] Add `gif` to `--recode-video` --- yt_dlp/postprocessor/ffmpeg.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'yt_dlp/postprocessor/ffmpeg.py') diff --git a/yt_dlp/postprocessor/ffmpeg.py b/yt_dlp/postprocessor/ffmpeg.py index 67890fc31..069066e0c 100644 --- a/yt_dlp/postprocessor/ffmpeg.py +++ b/yt_dlp/postprocessor/ffmpeg.py @@ -538,7 +538,10 @@ class FFmpegExtractAudioPP(FFmpegPostProcessor): class FFmpegVideoConvertorPP(FFmpegPostProcessor): - SUPPORTED_EXTS = (*MEDIA_EXTENSIONS.common_video, *sorted(MEDIA_EXTENSIONS.common_audio + ('aac', 'vorbis'))) + SUPPORTED_EXTS = ( + *sorted((*MEDIA_EXTENSIONS.common_video, 'gif')), + *sorted((*MEDIA_EXTENSIONS.common_audio, 'aac', 'vorbis')), + ) FORMAT_RE = create_mapping_re(SUPPORTED_EXTS) _ACTION = 'converting' -- cgit v1.2.3 From 08e29b9f1f0b6e5fe1c1e87bf8169bfd7ac91d57 Mon Sep 17 00:00:00 2001 From: pukkandan Date: Mon, 2 Jan 2023 19:39:03 +0530 Subject: [cleanup] Misc Closes #5576, closes #5887 --- yt_dlp/postprocessor/ffmpeg.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'yt_dlp/postprocessor/ffmpeg.py') diff --git a/yt_dlp/postprocessor/ffmpeg.py b/yt_dlp/postprocessor/ffmpeg.py index 069066e0c..9b70d749f 100644 --- a/yt_dlp/postprocessor/ffmpeg.py +++ b/yt_dlp/postprocessor/ffmpeg.py @@ -407,7 +407,7 @@ class FFmpegPostProcessor(PostProcessor): """ concat_file = f'{out_file}.concat' self.write_debug(f'Writing concat spec to {concat_file}') - with open(concat_file, 'wt', encoding='utf-8') as f: + with open(concat_file, 'w', encoding='utf-8') as f: f.writelines(self._concat_spec(in_files, concat_opts)) out_flags = list(self.stream_copy_opts(ext=determine_ext(out_file))) @@ -711,7 +711,7 @@ class FFmpegMetadataPP(FFmpegPostProcessor): @staticmethod def _get_chapter_opts(chapters, metadata_filename): - with open(metadata_filename, 'wt', encoding='utf-8') as f: + with open(metadata_filename, 'w', encoding='utf-8') as f: def ffmpeg_escape(text): return re.sub(r'([\\=;#\n])', r'\\\1', text) @@ -981,7 +981,7 @@ class FFmpegSubtitlesConvertorPP(FFmpegPostProcessor): with open(dfxp_file, 'rb') as f: srt_data = dfxp2srt(f.read()) - with open(srt_file, 'wt', encoding='utf-8') as f: + with open(srt_file, 'w', encoding='utf-8') as f: f.write(srt_data) old_file = srt_file -- cgit v1.2.3 From d80ca5deaa46db6e498399bb04a72a4c10ee8e22 Mon Sep 17 00:00:00 2001 From: pukkandan Date: Tue, 3 Jan 2023 08:05:45 +0530 Subject: [utils] `mimetype2ext`: weba is not standard Fix bug in fbb73833067ba742459729809679a62f34b3e41e, 2647c933b8ed22f95dd8e9866c4db031867a1bc8 Closes #5935 --- yt_dlp/postprocessor/ffmpeg.py | 1 + 1 file changed, 1 insertion(+) (limited to 'yt_dlp/postprocessor/ffmpeg.py') diff --git a/yt_dlp/postprocessor/ffmpeg.py b/yt_dlp/postprocessor/ffmpeg.py index 9b70d749f..5acd75376 100644 --- a/yt_dlp/postprocessor/ffmpeg.py +++ b/yt_dlp/postprocessor/ffmpeg.py @@ -44,6 +44,7 @@ EXT_TO_OUT_FORMATS = { 'ts': 'mpegts', 'wma': 'asf', 'wmv': 'asf', + 'weba': 'webm', 'vtt': 'webvtt', } ACODECS = { -- cgit v1.2.3 From f737fb16d8234408c85bc189ccc926fea000515b Mon Sep 17 00:00:00 2001 From: Chris Caruso Date: Fri, 17 Feb 2023 00:06:15 -0800 Subject: [ExtractAudio] Handle outtmpl without ext (#6005) Authored by: carusocr Closes #5968 --- yt_dlp/postprocessor/ffmpeg.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'yt_dlp/postprocessor/ffmpeg.py') diff --git a/yt_dlp/postprocessor/ffmpeg.py b/yt_dlp/postprocessor/ffmpeg.py index 5acd75376..123a95a3a 100644 --- a/yt_dlp/postprocessor/ffmpeg.py +++ b/yt_dlp/postprocessor/ffmpeg.py @@ -508,8 +508,7 @@ class FFmpegExtractAudioPP(FFmpegPostProcessor): if acodec != 'copy': more_opts = self._quality_args(acodec) - # not os.path.splitext, since the latter does not work on unicode in all setups - temp_path = new_path = f'{path.rpartition(".")[0]}.{extension}' + temp_path = new_path = replace_extension(path, extension, information['ext']) if new_path == path: if acodec == 'copy': -- cgit v1.2.3 From 01ddec7e661bf90dc4c34e6924eb9d7629886cef Mon Sep 17 00:00:00 2001 From: bashonly <88596187+bashonly@users.noreply.github.com> Date: Wed, 8 Mar 2023 07:10:19 -0600 Subject: [postprocessor] Fix chapters if duration is not extracted (#6037) Authored by: bashonly --- yt_dlp/postprocessor/ffmpeg.py | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'yt_dlp/postprocessor/ffmpeg.py') diff --git a/yt_dlp/postprocessor/ffmpeg.py b/yt_dlp/postprocessor/ffmpeg.py index 123a95a3a..0e8f4c70b 100644 --- a/yt_dlp/postprocessor/ffmpeg.py +++ b/yt_dlp/postprocessor/ffmpeg.py @@ -302,6 +302,11 @@ class FFmpegPostProcessor(PostProcessor): None) return num, len(streams) + def _fixup_chapters(self, info): + last_chapter = traverse_obj(info, ('chapters', -1)) + if last_chapter and not last_chapter.get('end_time'): + last_chapter['end_time'] = self._get_real_video_duration(info['filepath']) + def _get_real_video_duration(self, filepath, fatal=True): try: duration = float_or_none( @@ -678,6 +683,7 @@ class FFmpegMetadataPP(FFmpegPostProcessor): @PostProcessor._restrict_to(images=False) def run(self, info): + self._fixup_chapters(info) filename, metadata_filename = info['filepath'], None files_to_delete, options = [], [] if self._add_chapters and info.get('chapters'): @@ -1040,6 +1046,7 @@ class FFmpegSplitChaptersPP(FFmpegPostProcessor): @PostProcessor._restrict_to(images=False) def run(self, info): + self._fixup_chapters(info) chapters = info.get('chapters') or [] if not chapters: self.to_screen('Chapter information is unavailable') -- cgit v1.2.3 From 0f0875ed555514f32522a0f30554fb08825d5124 Mon Sep 17 00:00:00 2001 From: Lesmiscore Date: Tue, 28 Mar 2023 01:17:42 +0900 Subject: [postprocessor/EmbedThumbnail,postprocessor/FFmpegMetadata] Fix error on attaching thumbnails and info json for mkv/mka (#6647) Authored by: Lesmiscore Current yt-dlp code never hit this bug, but would hit once filename sanitization gets better --- yt_dlp/postprocessor/ffmpeg.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'yt_dlp/postprocessor/ffmpeg.py') diff --git a/yt_dlp/postprocessor/ffmpeg.py b/yt_dlp/postprocessor/ffmpeg.py index 0e8f4c70b..63fc9ace6 100644 --- a/yt_dlp/postprocessor/ffmpeg.py +++ b/yt_dlp/postprocessor/ffmpeg.py @@ -809,7 +809,7 @@ class FFmpegMetadataPP(FFmpegPostProcessor): new_stream -= 1 yield ( - '-attach', infofn, + '-attach', self._ffmpeg_filename_argument(infofn), f'-metadata:s:{new_stream}', 'mimetype=application/json', f'-metadata:s:{new_stream}', 'filename=info.json', ) -- cgit v1.2.3 From 3f7e2bd80e3c5d8a1682f20a1b245fcd974f295d Mon Sep 17 00:00:00 2001 From: bashonly <88596187+bashonly@users.noreply.github.com> Date: Thu, 13 Apr 2023 14:21:09 -0500 Subject: [FFmpegFixupM3u8PP] Check audio codec before fixup (#6778) Closes #6673 Authored by: bashonly --- yt_dlp/postprocessor/ffmpeg.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'yt_dlp/postprocessor/ffmpeg.py') diff --git a/yt_dlp/postprocessor/ffmpeg.py b/yt_dlp/postprocessor/ffmpeg.py index 63fc9ace6..323f4303c 100644 --- a/yt_dlp/postprocessor/ffmpeg.py +++ b/yt_dlp/postprocessor/ffmpeg.py @@ -898,8 +898,11 @@ class FFmpegFixupM3u8PP(FFmpegFixupPostProcessor): @PostProcessor._restrict_to(images=False) def run(self, info): if all(self._needs_fixup(info)): + args = ['-f', 'mp4'] + if self.get_audio_codec(info['filepath']) == 'aac': + args.extend(['-bsf:a', 'aac_adtstoasc']) self._fixup('Fixing MPEG-TS in MP4 container', info['filepath'], [ - *self.stream_copy_opts(), '-f', 'mp4', '-bsf:a', 'aac_adtstoasc']) + *self.stream_copy_opts(), *args]) return [], info -- cgit v1.2.3