]> jfr.im git - yt-dlp.git/commitdiff
[hls] Enable `--hls-use-mpegts` by default when downloading live-streams
authorpukkandan <redacted>
Fri, 26 Feb 2021 16:21:31 +0000 (21:51 +0530)
committerpukkandan <redacted>
Fri, 26 Feb 2021 16:22:16 +0000 (21:52 +0530)
* Also added option `--no-hls-use-mpegts` to disable this

Related: #96

README.md
yt_dlp/downloader/external.py
yt_dlp/options.py

index d40fc536ca9c0449420c51cc206b49282cdacfb7..2d40b6a9aabdf5d93d88fee7d0d2ba48f790a415 100644 (file)
--- a/README.md
+++ b/README.md
@@ -317,10 +317,15 @@ ## Download Options:
                                      ffmpeg
     --hls-prefer-ffmpeg              Use ffmpeg instead of the native HLS
                                      downloader
-    --hls-use-mpegts                 Use the mpegts container for HLS videos,
-                                     allowing to play the video while
-                                     downloading (some players may not be able
-                                     to play it)
+    --hls-use-mpegts                 Use the mpegts container for HLS videos;
+                                     allowing some players to play the video
+                                     while downloading, and reducing the chance
+                                     of file corruption if download is
+                                     interrupted. This is enabled by default for
+                                     live streams
+    --no-hls-use-mpegts              Do not use the mpegts container for HLS
+                                     videos. This is default when not
+                                     downloading live streams
     --external-downloader NAME       Use the specified external downloader.
                                      Currently supports aria2c, avconv, axel,
                                      curl, ffmpeg, httpie, wget
index 4bef3bf52462caf592cb4fdf979d5a8c834ca4c7..5d9639076ba224f1d6e93f6b58dce9d299e07064 100644 (file)
@@ -398,7 +398,10 @@ def _call_downloader(self, tmpfilename, info_dict):
             args += ['-fs', compat_str(self._TEST_FILE_SIZE)]
 
         if protocol in ('m3u8', 'm3u8_native'):
-            if self.params.get('hls_use_mpegts', False) or tmpfilename == '-':
+            use_mpegts = (tmpfilename == '-') or self.params.get('hls_use_mpegts')
+            if use_mpegts is None:
+                use_mpegts = info_dict.get('is_live')
+            if use_mpegts:
                 args += ['-f', 'mpegts']
             else:
                 args += ['-f', 'mp4']
index c47f6ea50a13bdb61235049535fa5eadcae8fe99..88f74ff36dc5dba182be9bb8e73a5e2df9bac37b 100644 (file)
@@ -634,10 +634,18 @@ def _dict_from_multiple_values_options_callback(
         help='Use ffmpeg instead of the native HLS downloader')
     downloader.add_option(
         '--hls-use-mpegts',
-        dest='hls_use_mpegts', action='store_true',
+        dest='hls_use_mpegts', action='store_true', default=None,
         help=(
-            'Use the mpegts container for HLS videos, allowing to play the '
-            'video while downloading (some players may not be able to play it)'))
+            'Use the mpegts container for HLS videos; '
+            'allowing some players to play the video while downloading, '
+            'and reducing the chance of file corruption if download is interrupted. '
+            'This is enabled by default for live streams'))
+    downloader.add_option(
+        '--no-hls-use-mpegts',
+        dest='hls_use_mpegts', action='store_false',
+        help=(
+            'Do not use the mpegts container for HLS videos. '
+            'This is default when not downloading live streams'))
     downloader.add_option(
         '--external-downloader',
         dest='external_downloader', metavar='NAME',