Repository: yt-dlp/yt-dlp

Issue:
Some Twitter/X videos download an mp4 that doesn't play in VLC but works after conversion through ffmpeg
### DO NOT REMOVE OR SKIP THE ISSUE TEMPLATE

- [X] I understand that I will be **blocked** if I *intentionally* remove or skip any mandatory\* field

### Checklist

- [X] I'm reporting that yt-dlp is broken on a **supported** site
- [X] I've verified that I'm running yt-dlp version **2023.07.06** ([update instructions](https://github.com/yt-dlp/yt-dlp#update)) or later (specify commit)
- [X] I've checked that all provided URLs are playable in a browser with the same IP and same login details
- [X] I've checked that all URLs and arguments with special characters are [properly quoted or escaped](https://github.com/yt-dlp/yt-dlp/wiki/FAQ#video-url-contains-an-ampersand--and-im-getting-some-strange-output-1-2839-or-v-is-not-recognized-as-an-internal-or-external-command)
- [X] I've searched [known issues](https://github.com/yt-dlp/yt-dlp/issues/3766) and the [bugtracker](https://github.com/yt-dlp/yt-dlp/issues?q=) for similar issues **including closed ones**. DO NOT post duplicates
- [X] I've read the [guidelines for opening an issue](https://github.com/yt-dlp/yt-dlp/blob/master/CONTRIBUTING.md#opening-an-issue)
- [X] I've read about [sharing account credentials](https://github.com/yt-dlp/yt-dlp/blob/master/CONTRIBUTING.md#are-you-willing-to-share-account-details-if-needed) and I'm willing to share it if required

### Region

United States

### Provide a description that is worded well enough to be understood

Twitter/X video plays fine in browser: https://twitter.com/Permissionless/status/1702054516458156126

Running yt-dlp shows an MP4:

```
[info] 1702047765721661440: Downloading 1 format(s): http-2176
[download] Destination: Permissionless II - Why are we here？  Permissionless II opener from @ErikVoorhees that got an entire crypto conference on their feet [1702047765721661440].mp4
[download] 100% of   79.59MiB in 00:01:25 at 953.51KiB/s
```

Playing in VLC and other media players fails.

Running `file` shows it's an ISO format:

```
file *.mp4 
Permissionless.mp4: ISO Media
```

So I renamed it to `.iso` and used `ffmpeg` to convert from iso to MP4 and it worked:

```
ffmpeg -i Permissionless.iso Permissionless.mp4
```

### Provide verbose output that clearly demonstrates the problem

- [X] Run **your** yt-dlp command with **-vU** flag added (`yt-dlp -vU <your command line>`)
- [X] If using API, add `'verbose': True` to `YoutubeDL` params instead
- [X] Copy the WHOLE output (starting with `[debug] Command-line config`) and insert it below

### Complete Verbose Output

```shell
[debug] Command-line config: ['-vU', '-o', 'Permissionless.mp4', 'https://x.com/Permissionless/status/1702054516458156126']
[debug] Encodings: locale UTF-8, fs utf-8, pref UTF-8, out utf-8, error utf-8, screen utf-8
[debug] yt-dlp version stable@2023.07.06 [b532a3481] (source)
[debug] Lazy loading extractors is disabled
[debug] Git HEAD: 7b71643cc
[debug] Python 3.11.4 (CPython x86_64 64bit) - Linux-6.4.13-100.fc37.x86_64-x86_64-with-glibc2.36 (OpenSSL 3.0.9 30 May 2023, glibc 2.36)
[debug] exe versions: ffmpeg 5.1.3 (setts), ffprobe 5.1.3
[debug] Optional libraries: Cryptodome-3.17, brotli-1.0.9, certifi-2022.12.07, mutagen-1.46.0, sqlite3-2.6.0, websockets-11.0.2
[debug] Proxy map: {}
[debug] Loaded 1865 extractors
[debug] Fetching release info: https://api.github.com/repos/yt-dlp/yt-dlp/releases/latest
Available version: stable@2023.07.06, Current version: stable@2023.07.06
yt-dlp is up to date (stable@2023.07.06)
[generic] Extracting URL: https://x.com/Permissionless/status/1702054516458156126
[generic] 1702054516458156126: Downloading webpage
[redirect] Following redirect to https://twitter.com/Permissionless/status/1702054516458156126
[twitter] Extracting URL: https://twitter.com/Permissionless/status/1702054516458156126
[twitter] 1702054516458156126: Downloading guest token
[twitter] 1702054516458156126: Downloading GraphQL JSON
[debug] [twitter] Extracting from video info: 1702047765721661440
[twitter] 1702054516458156126: Downloading m3u8 information
[debug] Sort order given by extractor: res, br, size, proto
[debug] Formats sorted by: hasvid, ie_pref, res, br, size, proto, lang, quality, fps, hdr:12(7), vcodec:vp9.2(10), channels, acodec, asr, vext, aext, hasaud, source, id
[debug] Default format spec: bestvideo*+bestaudio/best
[info] 1702047765721661440: Downloading 1 format(s): http-2176
[debug] Invoking http downloader on "https://video.twimg.com/amplify_video/1702047765721661440/vid/avc1/1280x720/mZwyanLBCkbm0A8l.mp4?tag=14"
[download] Destination: Permissionless.mp4
[download] 100% of   79.59MiB in 00:00:09 at 8.62MiB/s
```



Discussion:
https://en.wikipedia.org/wiki/ISO_base_media_file_format

It's just a container format that uses mp4 extension. This is not unusual

mpv and ffmpeg/ffprobe/ffplay can read/play this download just fine. Seems like a VLC issue
see https://github.com/yt-dlp/yt-dlp/issues/8750#issuecomment-1862713911

Resolving patch:
diff --git a/yt_dlp/extractor/twitter.py b/yt_dlp/extractor/twitter.py
--- a/yt_dlp/extractor/twitter.py
+++ b/yt_dlp/extractor/twitter.py
@@ -1416,8 +1416,8 @@ def add_thumbnail(name, size):
                 'thumbnails': thumbnails,
                 'view_count': traverse_obj(media, ('mediaStats', 'viewCount', {int_or_none})),  # No longer available
                 'duration': float_or_none(traverse_obj(media, ('video_info', 'duration_millis')), 1000),
-                # The codec of http formats are unknown
-                '_format_sort_fields': ('res', 'br', 'size', 'proto'),
+                # Prioritize m3u8 formats for compat, see https://github.com/yt-dlp/yt-dlp/issues/8117
+                '_format_sort_fields': ('res', 'proto:m3u8', 'br', 'size'),  # http format codec is unknown
             }
 
         def extract_from_card_info(card):


Test patch: