Skip to content

Commit

Permalink
ffmpeg: ignore extra data streams with -dn (fixes ytdl-org#2)
Browse files Browse the repository at this point in the history
Sometimes, video files will arrive with a timecode data stream
that causes `-map 0` to error out due to the stream not being
supported in the output container. These data streams generally do
not matter, so tell ffmpeg to ignore them rather than choking on
them.
  • Loading branch information
jbruchon committed Jan 7, 2021
1 parent c82fc65 commit e0da59f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion youtube_dlc/postprocessor/embedthumbnail.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ def is_webp(path):
os.rename(encodeFilename(old_thumbnail_filename), encodeFilename(thumbnail_filename))

options = [
'-c', 'copy', '-map', '0',
'-c', 'copy', '-map', '0', '-dn',
'-attach', thumbnail_filename, '-metadata:s:t', 'mimetype=image/jpeg']

self._downloader.to_screen('[ffmpeg] Adding thumbnail to "%s"' % filename)
Expand Down
12 changes: 6 additions & 6 deletions youtube_dlc/postprocessor/ffmpeg.py
Original file line number Diff line number Diff line change
Expand Up @@ -359,7 +359,7 @@ def run(self, information):
if information['ext'] == self._preferedformat:
self._downloader.to_screen('[ffmpeg] Not remuxing video file %s - already is in target format %s' % (path, self._preferedformat))
return [], information
options = ['-c', 'copy', '-map', '0']
options = ['-c', 'copy', '-map', '0', '-dn']
prefix, sep, ext = path.rpartition('.')
outpath = prefix + sep + self._preferedformat
self._downloader.to_screen('[' + 'ffmpeg' + '] Remuxing video from %s to %s, Destination: ' % (information['ext'], self._preferedformat) + outpath)
Expand Down Expand Up @@ -428,7 +428,7 @@ def run(self, information):
input_files = [filename] + sub_filenames

opts = [
'-c', 'copy', '-map', '0',
'-c', 'copy', '-map', '0', '-dn',
# Don't copy the existing subtitles, we may be running the
# postprocessor a second time
'-map', '-0:s',
Expand Down Expand Up @@ -498,7 +498,7 @@ def add(meta_list, info_list=None):
filename = info['filepath']
temp_filename = prepend_extension(filename, 'temp')
in_filenames = [filename]
options = ['-map', '0']
options = ['-map', '0', '-dn']

if info['ext'] == 'm4a':
options.extend(['-vn', '-acodec', 'copy'])
Expand Down Expand Up @@ -578,7 +578,7 @@ def run(self, info):
filename = info['filepath']
temp_filename = prepend_extension(filename, 'temp')

options = ['-c', 'copy', '-map', '0', '-aspect', '%f' % stretched_ratio]
options = ['-c', 'copy', '-map', '0', '-dn', '-aspect', '%f' % stretched_ratio]
self._downloader.to_screen('[ffmpeg] Fixing aspect ratio in "%s"' % filename)
self.run_ffmpeg(filename, temp_filename, options)

Expand All @@ -596,7 +596,7 @@ def run(self, info):
filename = info['filepath']
temp_filename = prepend_extension(filename, 'temp')

options = ['-c', 'copy', '-map', '0', '-f', 'mp4']
options = ['-c', 'copy', '-map', '0', '-dn', '-f', 'mp4']
self._downloader.to_screen('[ffmpeg] Correcting container in "%s"' % filename)
self.run_ffmpeg(filename, temp_filename, options)

Expand All @@ -612,7 +612,7 @@ def run(self, info):
if self.get_audio_codec(filename) == 'aac':
temp_filename = prepend_extension(filename, 'temp')

options = ['-c', 'copy', '-map', '0', '-f', 'mp4', '-bsf:a', 'aac_adtstoasc']
options = ['-c', 'copy', '-map', '0', '-dn', '-f', 'mp4', '-bsf:a', 'aac_adtstoasc']
self._downloader.to_screen('[ffmpeg] Fixing malformed AAC bitstream in "%s"' % filename)
self.run_ffmpeg(filename, temp_filename, options)

Expand Down

0 comments on commit e0da59f

Please sign in to comment.