Repository: yt-dlp/yt-dlp

Issue:
[bitchute/ffmpeg] Muxing fails due to unsupported timecode stream in MP4 file + -map 0
Copied from https://github.com/blackjack4494/yt-dlc/issues/291

## Verbose log

```
Y:\YouTube Channels\Chass>youtube-dl --cookies "Y:\cookies.txt" --add-metadata --write-description --write-info-json --write-thumbnail --all-subs --sleep-interval 1 -ciw -o "%(title)s.%(ext)s" -v https://www.bitchute.com/video/7KOApju0sI1E/
[debug] System config: []
[debug] User config: []
[debug] Custom config: []
[debug] Command-line args: ['--cookies', 'Y:\\cookies.txt', '--add-metadata', '--write-description', '--write-info-json', '--write-thumbnail', '--all-subs', '--sleep-interval', '1', '-ciw', '-o', '%(title)s.%(ext)s', '-v', 'https://www.bitchute.com/video/7KOApju0sI1E/']
[debug] Loading archive file None
[debug] Encodings: locale cp1252, fs utf-8, out utf-8, pref cp1252
[debug] youtube-dlc version 2020.11.11-2
[debug] Python version 3.9.0 (CPython) - Windows-10-10.0.19041-SP0
[debug] exe versions: ffmpeg 4.3.1-2020-11-19-full_build-www.gyan.dev, ffprobe 4.3.1-2020-11-19-full_build-www.gyan.dev
[debug] Proxy map: {}
[BitChute] 7KOApju0sI1E: Downloading webpage
[BitChute] 7KOApju0sI1E: Checking video URL
[debug] Default format spec: bestvideo+bestaudio/best
[info] Video description is already present
[info] Video description metadata is already present
[BitChute] 7KOApju0sI1E: Thumbnail is already present
[debug] Invoking downloader on 'https://z-28b3jxzl1og7.bitchute.com/iAhk3bN20i22/7KOApju0sI1E.mp4'
[download] 4chan threads - _x_ - The Desolate Towns Phenomenon.mp4 has already been downloaded
[download] 100% of 22.94MiB
[ffmpeg] Adding metadata to '4chan threads - _x_ - The Desolate Towns Phenomenon.mp4'
[debug] ffmpeg command line: ffmpeg -y -loglevel "repeat+info" -i "file:4chan threads - _x_ - The Desolate Towns Phenomenon.mp4" -map 0 -c copy -metadata "title=4chan threads - /x/ - The Desolate Towns Phenomenon" -metadata "date=20201218" -metadata "description=https://yuki.la/x/17299706
https://archive.4plebs.org/x/thread/22403433/#q22418409
https://yuki.la/x/25030586
If you wish to donate: https://www.paypal.me/thechasseurchannel
Bitchute: https://www.bitchute.com/channel/Chass/
Ultimate Spooky Greentext Playlist: https://www.youtube.com/playlist?list=PLbDSt84tOm2Nm0D8baMW3CfVaaF03LCjB
Music used:
Won't sleep - Kukomitzu
https://youtu.be/vz3KlzgEFm8?t=6
Stalker – Kukomitzu
https://youtu.be/vz3KlzgEFm8?t=297
♫ Epic Horror Synth Trailer Music ♪♬ - Something Wicked
https://www.youtube.com/watch?v=Zuw_O5MU5CE
[Vaporwave] Stevia Sphere - mint
https://www.youtube.com/watch?v=ykT3wtSCpzE
\"Midnight, the Stars and You\"
https://www.youtube.com/watch?v=-fN-Xjpd-qE
My last roadtrip - Kukomitzu
https://youtu.be/vz3KlzgEFm8?t=597
Outro music:
Gothic 3 - Geldern Night
https://www.youtube.com/watch?v=wCtV4DYZkK0" -metadata "comment=https://yuki.la/x/17299706
https://archive.4plebs.org/x/thread/22403433/#q22418409
https://yuki.la/x/25030586
If you wish to donate: https://www.paypal.me/thechasseurchannel
Bitchute: https://www.bitchute.com/channel/Chass/
Ultimate Spooky Greentext Playlist: https://www.youtube.com/playlist?list=PLbDSt84tOm2Nm0D8baMW3CfVaaF03LCjB
Music used:
Won't sleep - Kukomitzu
https://youtu.be/vz3KlzgEFm8?t=6
Stalker – Kukomitzu
https://youtu.be/vz3KlzgEFm8?t=297
♫ Epic Horror Synth Trailer Music ♪♬ - Something Wicked
https://www.youtube.com/watch?v=Zuw_O5MU5CE
[Vaporwave] Stevia Sphere - mint
https://www.youtube.com/watch?v=ykT3wtSCpzE
\"Midnight, the Stars and You\"
https://www.youtube.com/watch?v=-fN-Xjpd-qE
My last roadtrip - Kukomitzu
https://youtu.be/vz3KlzgEFm8?t=597
Outro music:
Gothic 3 - Geldern Night
https://www.youtube.com/watch?v=wCtV4DYZkK0" -metadata "purl=https://www.bitchute.com/video/7KOApju0sI1E/" -metadata "artist=Chass" "file:4chan threads - _x_ - The Desolate Towns Phenomenon.temp.mp4"
ERROR:   Stream #0:2 -> #0:2 (copy)
Traceback (most recent call last):
  File "youtube_dlc\YoutubeDL.py", line 2159, in post_process
  File "youtube_dlc\postprocessor\ffmpeg.py", line 532, in run
  File "youtube_dlc\postprocessor\ffmpeg.py", line 235, in run_ffmpeg_multiple_files
youtube_dlc.postprocessor.ffmpeg.FFmpegPostProcessorError:   Stream #0:2 -> #0:2 (copy)

```


## Description

Commit d03cfdce1bce28284fa0f168d5d278caacd2fa0b introduced `-map 0` to the FFmpeg post-processor to copy all streams. Unfortunately, the BitChute MP4 timecode stream I've run into here has an apparently invalid tag and can't be copied. If I type the `ffmpeg` command without `-map 0` it works fine since it simply ignores the extra unsupported stream. The option was added to ensure that extra streams are preserved, but in this particular case, it's causing a muxing failure due to an unsupported extra stream.
[bitchute/ffmpeg] Muxing fails due to unsupported timecode stream in MP4 file + -map 0
Copied from https://github.com/blackjack4494/yt-dlc/issues/291

## Verbose log

```
Y:\YouTube Channels\Chass>youtube-dl --cookies "Y:\cookies.txt" --add-metadata --write-description --write-info-json --write-thumbnail --all-subs --sleep-interval 1 -ciw -o "%(title)s.%(ext)s" -v https://www.bitchute.com/video/7KOApju0sI1E/
[debug] System config: []
[debug] User config: []
[debug] Custom config: []
[debug] Command-line args: ['--cookies', 'Y:\\cookies.txt', '--add-metadata', '--write-description', '--write-info-json', '--write-thumbnail', '--all-subs', '--sleep-interval', '1', '-ciw', '-o', '%(title)s.%(ext)s', '-v', 'https://www.bitchute.com/video/7KOApju0sI1E/']
[debug] Loading archive file None
[debug] Encodings: locale cp1252, fs utf-8, out utf-8, pref cp1252
[debug] youtube-dlc version 2020.11.11-2
[debug] Python version 3.9.0 (CPython) - Windows-10-10.0.19041-SP0
[debug] exe versions: ffmpeg 4.3.1-2020-11-19-full_build-www.gyan.dev, ffprobe 4.3.1-2020-11-19-full_build-www.gyan.dev
[debug] Proxy map: {}
[BitChute] 7KOApju0sI1E: Downloading webpage
[BitChute] 7KOApju0sI1E: Checking video URL
[debug] Default format spec: bestvideo+bestaudio/best
[info] Video description is already present
[info] Video description metadata is already present
[BitChute] 7KOApju0sI1E: Thumbnail is already present
[debug] Invoking downloader on 'https://z-28b3jxzl1og7.bitchute.com/iAhk3bN20i22/7KOApju0sI1E.mp4'
[download] 4chan threads - _x_ - The Desolate Towns Phenomenon.mp4 has already been downloaded
[download] 100% of 22.94MiB
[ffmpeg] Adding metadata to '4chan threads - _x_ - The Desolate Towns Phenomenon.mp4'
[debug] ffmpeg command line: ffmpeg -y -loglevel "repeat+info" -i "file:4chan threads - _x_ - The Desolate Towns Phenomenon.mp4" -map 0 -c copy -metadata "title=4chan threads - /x/ - The Desolate Towns Phenomenon" -metadata "date=20201218" -metadata "description=https://yuki.la/x/17299706
https://archive.4plebs.org/x/thread/22403433/#q22418409
https://yuki.la/x/25030586
If you wish to donate: https://www.paypal.me/thechasseurchannel
Bitchute: https://www.bitchute.com/channel/Chass/
Ultimate Spooky Greentext Playlist: https://www.youtube.com/playlist?list=PLbDSt84tOm2Nm0D8baMW3CfVaaF03LCjB
Music used:
Won't sleep - Kukomitzu
https://youtu.be/vz3KlzgEFm8?t=6
Stalker – Kukomitzu
https://youtu.be/vz3KlzgEFm8?t=297
♫ Epic Horror Synth Trailer Music ♪♬ - Something Wicked
https://www.youtube.com/watch?v=Zuw_O5MU5CE
[Vaporwave] Stevia Sphere - mint
https://www.youtube.com/watch?v=ykT3wtSCpzE
\"Midnight, the Stars and You\"
https://www.youtube.com/watch?v=-fN-Xjpd-qE
My last roadtrip - Kukomitzu
https://youtu.be/vz3KlzgEFm8?t=597
Outro music:
Gothic 3 - Geldern Night
https://www.youtube.com/watch?v=wCtV4DYZkK0" -metadata "comment=https://yuki.la/x/17299706
https://archive.4plebs.org/x/thread/22403433/#q22418409
https://yuki.la/x/25030586
If you wish to donate: https://www.paypal.me/thechasseurchannel
Bitchute: https://www.bitchute.com/channel/Chass/
Ultimate Spooky Greentext Playlist: https://www.youtube.com/playlist?list=PLbDSt84tOm2Nm0D8baMW3CfVaaF03LCjB
Music used:
Won't sleep - Kukomitzu
https://youtu.be/vz3KlzgEFm8?t=6
Stalker – Kukomitzu
https://youtu.be/vz3KlzgEFm8?t=297
♫ Epic Horror Synth Trailer Music ♪♬ - Something Wicked
https://www.youtube.com/watch?v=Zuw_O5MU5CE
[Vaporwave] Stevia Sphere - mint
https://www.youtube.com/watch?v=ykT3wtSCpzE
\"Midnight, the Stars and You\"
https://www.youtube.com/watch?v=-fN-Xjpd-qE
My last roadtrip - Kukomitzu
https://youtu.be/vz3KlzgEFm8?t=597
Outro music:
Gothic 3 - Geldern Night
https://www.youtube.com/watch?v=wCtV4DYZkK0" -metadata "purl=https://www.bitchute.com/video/7KOApju0sI1E/" -metadata "artist=Chass" "file:4chan threads - _x_ - The Desolate Towns Phenomenon.temp.mp4"
ERROR:   Stream #0:2 -> #0:2 (copy)
Traceback (most recent call last):
  File "youtube_dlc\YoutubeDL.py", line 2159, in post_process
  File "youtube_dlc\postprocessor\ffmpeg.py", line 532, in run
  File "youtube_dlc\postprocessor\ffmpeg.py", line 235, in run_ffmpeg_multiple_files
youtube_dlc.postprocessor.ffmpeg.FFmpegPostProcessorError:   Stream #0:2 -> #0:2 (copy)

```


## Description

Commit d03cfdce1bce28284fa0f168d5d278caacd2fa0b introduced `-map 0` to the FFmpeg post-processor to copy all streams. Unfortunately, the BitChute MP4 timecode stream I've run into here has an apparently invalid tag and can't be copied. If I type the `ffmpeg` command without `-map 0` it works fine since it simply ignores the extra unsupported stream. The option was added to ensure that extra streams are preserved, but in this particular case, it's causing a muxing failure due to an unsupported extra stream.


Discussion:
This doesn't seem to be an issue with yt-dlc. Other bitchute videos work fine. This particular video has a broken data stream. You can fix it by using `--postprocessor-args "-map -0:d?"`
This happens with multiple BitChute videos. It is not isolated to that single one.
Do you have any ideas how to fix this? I dont want to throw away the data streams of all videos just because of a few videos
Is there a way to tell ffmpeg to ignore unsupported streams instead of throwing an error?
This doesn't seem to be an issue with yt-dlc. Other bitchute videos work fine. This particular video has a broken data stream. You can fix it by using `--postprocessor-args "-map -0:d?"`
This happens with multiple BitChute videos. It is not isolated to that single one.
Do you have any ideas how to fix this? I dont want to throw away the data streams of all videos just because of a few videos
Is there a way to tell ffmpeg to ignore unsupported streams instead of throwing an error?

Resolving patch:
diff --git a/youtube_dlc/postprocessor/embedthumbnail.py b/youtube_dlc/postprocessor/embedthumbnail.py
--- a/youtube_dlc/postprocessor/embedthumbnail.py
+++ b/youtube_dlc/postprocessor/embedthumbnail.py
@@ -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)
diff --git a/youtube_dlc/postprocessor/ffmpeg.py b/youtube_dlc/postprocessor/ffmpeg.py
--- a/youtube_dlc/postprocessor/ffmpeg.py
+++ b/youtube_dlc/postprocessor/ffmpeg.py
@@ -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)
@@ -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',
@@ -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'])
@@ -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)
 
@@ -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)
 
@@ -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)
 


Test patch: