Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

--merge-output-format mkv / Resulting file is missing bit rate metadata #9924

Open
9 tasks done
BlohoJo opened this issue May 15, 2024 · 5 comments
Open
9 tasks done
Labels
external issue Issue with an external tool

Comments

@BlohoJo
Copy link

BlohoJo commented May 15, 2024

DO NOT REMOVE OR SKIP THE ISSUE TEMPLATE

  • I understand that I will be blocked if I intentionally remove or skip any mandatory* field

Checklist

Provide a description that is worded well enough to be understood

Download any video from Youtube using the command line option + argument --merge-output-format mkv.

Install MediaInfo.

Right click the file and select MediaInfo. Observe that the report will show only "Overall bit rate", there is no bit rate shown for the separate video stream or the audio stream.

Install MKVToolNix. Launch MKVToolNix GUI, drag the downloaded file into the source file window, then start multiplexing to a new file. Right click the created file, then select MediaInfo. Observe that the report shows the bit rates for the separate video stream and audio stream.

Can yt-dlp be fixed so that it will include the bit rates for the separate video and audio streams?

Provide verbose output that clearly demonstrates the problem

  • Run your yt-dlp command with -vU flag added (yt-dlp -vU <your command line>)
  • If using API, add 'verbose': True to YoutubeDL params instead
  • Copy the WHOLE output (starting with [debug] Command-line config) and insert it below

Complete Verbose Output

E:\USER\temp_ytdl>yt-dlp.exe -vU -f "(bv*[vcodec~='^(avc|h264)']+ba[acodec~='^(m
p4a|aac)']) / (bv*+ba/b)" --merge-output-format mkv "https://www.youtube.com/wat
ch?v=P9ZFOPj7Q7Y"
[debug] Command-line config: ['-vU', '-f', "(bv*[vcodec~='^(avc|h264)']+ba[acode
c~='^(mp4a|aac)']) / (bv*+ba/b)", '--merge-output-format', 'mkv', 'https://www.y
outube.com/watch?v=P9ZFOPj7Q7Y']
[debug] Encodings: locale cp1252, fs utf-8, pref cp1252, out utf-8 (No VT), erro
r utf-8 (No VT), screen utf-8 (No VT)
[debug] yt-dlp version stable@2024.04.09 from yt-dlp/yt-dlp [ff0779267] (win_exe
)
[debug] Python 3.8.10 (CPython AMD64 64bit) - Windows-2008ServerR2-6.1.7601-SP1
(OpenSSL 1.1.1k  25 Mar 2021)
[debug] exe versions: ffmpeg N-93824-g479a5f644f (fdk), ffprobe N-89595-g40d4b13
228, rtmpdump 2.4-20151223-gfa8646d-OpenSSL_1.0.2n-x86_64-static
[debug] Optional libraries: Cryptodome-3.20.0, brotli-1.1.0, certifi-2024.02.02,
 curl_cffi-0.5.10, mutagen-1.47.0, requests-2.31.0, sqlite3-3.35.5, urllib3-2.2.
1, websockets-12.0
[debug] Proxy map: {}
[debug] Request Handlers: urllib, requests, websockets, curl_cffi
[debug] Loaded 1810 extractors
[debug] Fetching release info: https://api.github.com/repos/yt-dlp/yt-dlp/releas
es/latest
Latest version: stable@2024.04.09 from yt-dlp/yt-dlp
yt-dlp is up to date (stable@2024.04.09 from yt-dlp/yt-dlp)
[youtube] Extracting URL: https://www.youtube.com/watch?v=P9ZFOPj7Q7Y
[youtube] P9ZFOPj7Q7Y: Downloading webpage
[youtube] P9ZFOPj7Q7Y: Downloading ios player API JSON
[youtube] P9ZFOPj7Q7Y: Downloading android player API JSON
WARNING: [youtube] Skipping player responses from android clients (got player re
sponses for video "aQvGIIdgFDM" instead of "P9ZFOPj7Q7Y")
[debug] [youtube] Extracting signature function js_74a3a562_105
[youtube] P9ZFOPj7Q7Y: Downloading player 74a3a562
[debug] Saving youtube-sigfuncs.js_74a3a562_105 to cache
[debug] [youtube] Extracting nsig function with jsinterp
[debug] Saving youtube-nsig.74a3a562 to cache
[debug] [youtube] Decrypted nsig bUYNN4hIPhbqTGAIMGM => DqR0bApKIw-0mg
[debug] Loading youtube-nsig.74a3a562 from cache
[debug] [youtube] Decrypted nsig KJrrNvefEpd1t5X9JTr => sB_8fP3heXFuew
[debug] [youtube] Extracting signature function js_74a3a562_101
[debug] Saving youtube-sigfuncs.js_74a3a562_101 to cache
[youtube] P9ZFOPj7Q7Y: Downloading m3u8 information
[debug] Sort order given by extractor: quality, res, fps, hdr:12, source, vcodec
:vp9.2, channels, acodec, lang, proto
[debug] Formats sorted by: hasvid, ie_pref, quality, res, fps, hdr:12(7), source
, vcodec:vp9.2(10), channels, acodec, lang, proto, size, br, asr, vext, aext, ha
saud, id
[info] P9ZFOPj7Q7Y: Downloading 1 format(s): 135+140
[debug] Invoking http downloader on "https://rr5---sn-nx57ynsk.googlevideo.com/v
ideoplayback?expire=1715793623&ei=d5pEZqKqDNHnsfIP7P6rkAo&ip=51.81.168.52&id=o-A
HZSqT2OHm5g6qKA1rjUO6pbk3YEMCz25VSA4gZoAYRh&itag=135&source=youtube&requiressl=y
es&xpc=EgVo2aDSNQ%3D%3D&mh=bt&mm=31%2C26&mn=sn-nx57ynsk%2Csn-tt1elnel&ms=au%2Con
r&mv=m&mvi=5&pl=19&initcwndbps=588750&vprv=1&svpuc=1&mime=video%2Fmp4&rqh=1&gir=
yes&clen=1288262&dur=216.951&lmt=1406543830951951&mt=1715771575&fvip=5&keepalive
=yes&c=IOS&sparams=expire%2Cei%2Cip%2Cid%2Citag%2Csource%2Crequiressl%2Cxpc%2Cvp
rv%2Csvpuc%2Cmime%2Crqh%2Cgir%2Cclen%2Cdur%2Clmt&sig=AJfQdSswRQIhANT_tfDzENxNF8z
iW8ZerRGQLLbi5fWrMODYjuf_YQSyAiBDPhMufou1NCmAZz-SGwGsRwUbzqRCStWXl5MJeLU1Mw%3D%3
D&lsparams=mh%2Cmm%2Cmn%2Cms%2Cmv%2Cmvi%2Cpl%2Cinitcwndbps&lsig=AHWaYeowRQIgOR23
dHBwYYURgRoakgsfvqU-zoVQfMAv8J9TXr6759ICIQCAilSyS2d3P7P4FRVMr7C5OTgA4BRNAb7Ae4Z2
VHpCZw%3D%3D"
[debug] File locking is not supported. Proceeding without locking
[download] Destination: Book Of Love - Late Show (1986) [P9ZFOPj7Q7Y].f135.mp4
[download] 100% of    1.23MiB in 00:00:00 at 15.75MiB/s
[debug] Invoking http downloader on "https://rr5---sn-nx57ynsk.googlevideo.com/v
ideoplayback?expire=1715793623&ei=d5pEZqKqDNHnsfIP7P6rkAo&ip=51.81.168.52&id=o-A
HZSqT2OHm5g6qKA1rjUO6pbk3YEMCz25VSA4gZoAYRh&itag=140&source=youtube&requiressl=y
es&xpc=EgVo2aDSNQ%3D%3D&mh=bt&mm=31%2C26&mn=sn-nx57ynsk%2Csn-tt1elnel&ms=au%2Con
r&mv=m&mvi=5&pl=19&initcwndbps=588750&vprv=1&svpuc=1&mime=audio%2Fmp4&rqh=1&gir=
yes&clen=3485682&dur=217.082&lmt=1406543849090076&mt=1715771575&fvip=5&keepalive
=yes&c=IOS&sparams=expire%2Cei%2Cip%2Cid%2Citag%2Csource%2Crequiressl%2Cxpc%2Cvp
rv%2Csvpuc%2Cmime%2Crqh%2Cgir%2Cclen%2Cdur%2Clmt&sig=AJfQdSswRAIgKxJ4kfmosu_5535
-DVni1j-SVsVW_KP_5GQKcPAPTBECIE9Qu075JSkCuALloELSDpiHTMe5jJPyu_M0uq9rzLaV&lspara
ms=mh%2Cmm%2Cmn%2Cms%2Cmv%2Cmvi%2Cpl%2Cinitcwndbps&lsig=AHWaYeowRQIgOR23dHBwYYUR
gRoakgsfvqU-zoVQfMAv8J9TXr6759ICIQCAilSyS2d3P7P4FRVMr7C5OTgA4BRNAb7Ae4Z2VHpCZw%3
D%3D"
[download] Destination: Book Of Love - Late Show (1986) [P9ZFOPj7Q7Y].f140.m4a
[download] 100% of    3.32MiB in 00:00:00 at 30.44MiB/s
[Merger] Merging formats into "Book Of Love - Late Show (1986) [P9ZFOPj7Q7Y].mkv
"
[debug] ffmpeg command line: ffmpeg -y -loglevel repeat+info -i "file:Book Of Lo
ve - Late Show (1986) [P9ZFOPj7Q7Y].f135.mp4" -i "file:Book Of Love - Late Show
(1986) [P9ZFOPj7Q7Y].f140.m4a" -c copy -map 0:v:0 -map 1:a:0 -movflags +faststar
t "file:Book Of Love - Late Show (1986) [P9ZFOPj7Q7Y].temp.mkv"
Deleting original file Book Of Love - Late Show (1986) [P9ZFOPj7Q7Y].f140.m4a (p
ass -k to keep)
Deleting original file Book Of Love - Late Show (1986) [P9ZFOPj7Q7Y].f135.mp4 (p
ass -k to keep)

---------------------------------------------------

General
Unique ID                                : 82742846397301302004546982710879441108 (0x3E3FB14B5A44C52500940031778FD0D4)
Complete name                            : E:\USER\temp_ytdl\Book Of Love - Late Show (1986) [P9ZFOPj7Q7Y].mkv
Format                                   : Matroska
Format version                           : Version 4
File size                                : 4.50 MiB
Duration                                 : 3 min 37 s
Overall bit rate                         : 174 kb/s
Frame rate                               : 29.970 FPS
Writing application                      : Lavf58.27.103
Writing library                          : Lavf58.27.103
ErrorDetectionType                       : Per level 1

Video
ID                                       : 1
Format                                   : AVC
Format/Info                              : Advanced Video Codec
Format profile                           : Main@L3.1
Format settings                          : CABAC / 3 Ref Frames
Format settings, CABAC                   : Yes
Format settings, Reference frames        : 3 frames
Codec ID                                 : V_MPEG4/ISO/AVC
Duration                                 : 3 min 36 s
Width                                    : 854 pixels
Height                                   : 480 pixels
Display aspect ratio                     : 16:9
Active width                             : 486 pixels
Active display aspect ratio              : 1.010
Frame rate mode                          : Constant
Frame rate                               : 29.970 (30000/1001) FPS
Color space                              : YUV
Chroma subsampling                       : 4:2:0
Bit depth                                : 8 bits
Scan type                                : Progressive
Default                                  : Yes
Forced                                   : No

Audio
ID                                       : 2
Format                                   : AAC LC
Format/Info                              : Advanced Audio Codec Low Complexity
Codec ID                                 : A_AAC-2
Duration                                 : 3 min 37 s
Channel(s)                               : 2 channels
Channel layout                           : L R
Sampling rate                            : 44.1 kHz
Frame rate                               : 43.066 FPS (1024 SPF)
Compression mode                         : Lossy
Default                                  : Yes
Forced                                   : No

---------------------------------------------------

General
Unique ID                                : 280540080071693167673469279249637603123 (0xD30E0DD84212962509948D5234607733)
Complete name                            : E:\USER\temp_ytdl\Book Of Love - Late Show (1986) (MKVToolNix).mkv
Format                                   : Matroska
Format version                           : Version 4
File size                                : 4.46 MiB
Duration                                 : 3 min 37 s
Overall bit rate                         : 172 kb/s
Frame rate                               : 29.970 FPS
Encoded date                             : 2024-05-15 11:22:32 UTC
Writing application                      : mkvmerge v48.0.0 ('Fortress Around Your Heart') 64-bit
Writing library                          : libebml v1.4.0 + libmatroska v1.6.0 / Lavf58.27.103

Video
ID                                       : 1
Format                                   : AVC
Format/Info                              : Advanced Video Codec
Format profile                           : Main@L3.1
Format settings                          : CABAC / 3 Ref Frames
Format settings, CABAC                   : Yes
Format settings, Reference frames        : 3 frames
Codec ID                                 : V_MPEG4/ISO/AVC
Duration                                 : 3 min 36 s
Bit rate                                 : 44.4 kb/s
Width                                    : 854 pixels
Height                                   : 480 pixels
Display aspect ratio                     : 16:9
Active width                             : 486 pixels
Active display aspect ratio              : 1.010
Frame rate mode                          : Constant
Frame rate                               : 29.970 (30000/1001) FPS
Color space                              : YUV
Chroma subsampling                       : 4:2:0
Bit depth                                : 8 bits
Scan type                                : Progressive
Bits/(Pixel*Frame)                       : 0.004
Stream size                              : 1.15 MiB (26%)
Language                                 : English
Default                                  : Yes
Forced                                   : No

Audio
ID                                       : 2
Format                                   : AAC LC
Format/Info                              : Advanced Audio Codec Low Complexity
Codec ID                                 : A_AAC-2
Duration                                 : 3 min 37 s
Bit rate                                 : 126 kb/s
Channel(s)                               : 2 channels
Channel layout                           : L R
Sampling rate                            : 44.1 kHz
Frame rate                               : 43.066 FPS (1024 SPF)
Compression mode                         : Lossy
Stream size                              : 3.25 MiB (73%)
Language                                 : English
Default                                  : Yes
Forced                                   : No
@JeromeMartinez
Copy link

Can yt-dlp be fixed so that it will include the bit rates for the separate video and audio streams?

It is not in yt-dlp, it is in FFmpeg (used by yt-dlp).

@seproDev seproDev added external issue Issue with an external tool and removed enhancement New feature or request triage Untriaged issue labels May 15, 2024
@BlohoJo
Copy link
Author

BlohoJo commented May 15, 2024

Anything that can be done via FFmpeg?

Is it instead possible for yt-dlp to use mkvmerge/libebml for --merge-output-format mkv?

@BlohoJo
Copy link
Author

BlohoJo commented May 15, 2024

I just asked ChatGPT 4o for FFmpeg. ("Write an example FFmpeg command line that will mux a video and audio stream to a MKV file, and will automatically determine each indivdual stream's bit rate and then include that metadata for each individual stream's bit rate in the MKV file.") Here is the command line it gave, I don't have time yet to try it out...

ffmpeg -i input_video.mp4 -i input_audio.aac -map 0:v -map 1:a -c copy -metadata:s:v:0 "bit_rate=$(ffprobe -v error -select_streams v:0 -show_entries stream=bit_rate -of default=noprint_wrappers=1:nokey=1 input_video.mp4)" -metadata:s:a:0 "bit_rate=$(ffprobe -v error -select_streams a:0 -show_entries stream=bit_rate -of default=noprint_wrappers=1:nokey=1 input_audio.aac)" output.mkv

@pukkandan
Copy link
Member

According to MediaArea/MediaInfo#691 (comment), --exec "mkvpropedit --add-track-statistics-tags" should act as a workaround.

Is it instead possible for yt-dlp to use mkvmerge/libebml for --merge-output-format mkv?

#1879

I just asked ChatGPT

@BlohoJo Actually try whether it works. ChatGPT often gives nonsense answers and there is no point posting them here unless you can confirm it is valid.

If anyone successfully manages to get ffmpeg to add the data, let us know. Otherwise, there is nothing we can do for now.

@seproDev
Copy link
Collaborator

seproDev commented May 15, 2024

These tags are not part of the Matroska spec. As such, FFmpeg does not mux them. https://gitlab.com/mbunkus/mkvtoolnix/-/wikis/Track-statistics-tags

There is an open feature request for FFmpeg to write them as well: https://trac.ffmpeg.org/ticket/7467

I just asked ChatGPT 4o for FFmpeg.

No, this does not work. It just adds the BIT_RATE metadata field. I am not sure if this is even possible with FFmpeg.
Either way, imo. this is not something yt-dlp should do.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
external issue Issue with an external tool
Projects
None yet
Development

No branches or pull requests

4 participants