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

various: sync track information output #14453

Merged
merged 4 commits into from
Jul 18, 2024

Conversation

guidocella
Copy link
Contributor

@guidocella guidocella commented Jun 27, 2024

Print "Image" instead of "Video" for video tracks. This fixes #8561.

Print the hls-bitrate in select.lua.

Show the same flags in loadfile.c, select.lua and stats.lua. The only differences are that only stats.lua prints albumart because it's supposed to show detailed track information, and select.lua prints the image flag because pressing g-v doesn't show Video or Image like in loadfile.c and stats.lua.

Copy link

github-actions bot commented Jun 27, 2024

Download the artifacts for this pull request:

Windows
macOS

@guidocella guidocella force-pushed the track-info branch 3 times, most recently from 646b914 to b8738e6 Compare June 27, 2024 15:33
@na-na-hi
Copy link
Contributor

Print "Image" instead of "Video" for video tracks. This fixes #8561.

This isn't an accurate description of images:

yes/true if this is a video track that consists of a single picture, no/false or unavailable otherwise. The heuristic used to determine if a stream is an image doesn't attempt to detect images in codecs normally used for videos.

The behavior is also different for different demuxers. For example, for gif animations, demux_lavf considers it a video, while demux_mf considers it an image. demux_lavf also considers a single frame AV1 video as an image even though it's a video in all other aspects.

@kasper93
Copy link
Contributor

kasper93 commented Jun 27, 2024

single frame AV1 video as an image

single frame AV1 is basically an AVIF image. It is correct to call it image.

local flags = {"default", "forced", "external", "dependent",
"hearing-impaired", "visual-impaired", "image", "albumart"}
local flags = {"default", "forced", "dependent", "visual-impaired",
"hearing-impaired", "albumart", "external"}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would still leave image flag here, even if redundant.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Restored.

@guidocella
Copy link
Contributor Author

This isn't an accurate description of images:

yes/true if this is a video track that consists of a single picture, no/false or unavailable otherwise. The heuristic used to determine if a stream is an image doesn't attempt to detect images in codecs normally used for videos.

The behavior is also different for different demuxers. For example, for gif animations, demux_lavf considers it a video, while demux_mf considers it an image. demux_lavf also considers a single frame AV1 video as an image even though it's a video in all other aspects.

I know, I wrote that paragraph. ;) I indeed explicitly programmed demux_lavf to consider 1-frame gifs as images as I have several actual old images with gif codec for some reason. Gif videos are detected as videos by demux_lavf and do not normally go through demux_mf since ffmpeg can detect them. And I made demux_lavf detect 1-frame AV1 videos as images because avif are indeed real images. Anyway, the image detection is reliable outside of FATE. I wouldn't use it to prevent video playback like in the previous gainmap PR but it's fine for nicer textual description.

@@ -79,15 +98,16 @@ local function format_track(track)
and track["codec-profile"] .. " " or "") ..
(track["demux-samplerate"] and track["demux-samplerate"] / 1000 ..
" kHz " or "") ..
(track.external and "external " or "")
):sub(1, -2) .. ")"
(track["hls-bitrate"] and track["hls-bitrate"] .. " kbps " or "")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is also demux-bitrate if you want to use that.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added.

Show the same flags in loadfile.c, select.lua and stats.lua. The only
differences are that only stats.lua prints both image and albumart
because it's supposed to show detailed track information, and select.lua
prints the image flag because pressing g-v doesn't show Video or Image
like in loadfile.c and stats.lua.
if (s && s->hls_bitrate > 0)
APPEND(b, " %d kbps", (s->hls_bitrate + 500) / 1000);
if (s && s->codec->bitrate)
APPEND(b, " %d KiBps", s->codec->bitrate / 8 / 1000);
Copy link
Contributor

@kasper93 kasper93 Jun 27, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1024, but see other comments first.

@@ -0,0 +1,2 @@
remove deprecated `packet-video-bitrate` `packet-audio-bitrate` and
`packet-sub-bitrate` properties
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No line breaks. The lines are wrapped automatically by the generation scripts.

player/command.c Outdated
} else {
*(char **)arg = talloc_asprintf(NULL, "%.3f Mbps", rate / 1000.0);
*(char **)arg = talloc_asprintf(NULL, "%.3f MiBps", rate / 1024);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This shouldn't be changed. Are there any software or websites even using these units?

player/command.c Outdated
} else {
*(char **)arg = talloc_asprintf(NULL, "%.3f Mbps", rate / 1000.0);
*(char **)arg = talloc_asprintf(NULL, "%.3f MiBps", rate / 1024);
Copy link
Contributor

@kasper93 kasper93 Jun 27, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMHO KiB/s looks less cursed than KiBps.

But it also more common to use bits per second. So maybe we should stick to that, to avoid angry users coming at us. And kilobits per seconds, not kibibits.

I know I suggested using utils.format_bytes_humanized, but it seems to do more harm than good. Unless we actually change there.

So to summary. I would use bits, kb/s, Mb/s for bitrates. That would be compatible with common values that other software show.

EDIT:

We can add, to be used with bits values, like bitrate. And keep using the other one for cache size. Dunno.

function mp_utils.format_bits_humanized(b)
    local d = {"bits", "kb", "Mb", "Gb", "Tb", "Pb"}
    local i = 1
    while b >= 1000 do
        b = b / 1000
        i = i + 1
    end
    return string.format("%0.2f %s", b, d[i] and d[i] or "*1000^" .. (i-1))
end

Comment on lines 302 to 305
if (s && s->codec->bitrate)
APPEND(b, " %d kbps", (s->codec->bitrate + 500) / 1000);
if (s && s->hls_bitrate)
APPEND(b, " %d kbps", (s->hls_bitrate + 500) / 1000);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it looks confusing to have two bitrates printed without any indications.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added "HLS" to hls-bitrate only since it's the only that's totally inaccurate.

These have been deprecated for 9 years so it's fine to remove them.

Using the replacement properties like video-bitrate in stats.lua will
convert big enough bitrates to Mbps.
if (s && s->codec->bitrate)
APPEND(b, " %d kbps", (s->codec->bitrate + 500) / 1000);
if (s && s->hls_bitrate)
APPEND(b, " %d HLS kbps", (s->hls_bitrate + 500) / 1000);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this looks strange to me

Copy link
Contributor

@kasper93 kasper93 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, apart from HLS naming, looks odd.

@kasper93 kasper93 merged commit 8110bda into mpv-player:master Jul 18, 2024
21 checks passed
@guidocella guidocella deleted the track-info branch July 18, 2024 20:53
if (s && s->codec->bitrate)
APPEND(b, " %d kbps", (s->codec->bitrate + 500) / 1000);
if (s && s->hls_bitrate)
APPEND(b, " %d HLS kbps", (s->hls_bitrate + 500) / 1000);
Copy link
Member

@sfan5 sfan5 Aug 1, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what kind of unit is "HLS kbps"?
I get the idea to indicate where the bitrate came from but it looks weird and I don't think users really care.

my suggestion is to print codec bitrate if available or else print hls bitrate, but without the extra "HLS"
(based on the assumption that codec bitrate is generally more accurate than hls bitrate)

guidocella added a commit to guidocella/mpv that referenced this pull request Aug 1, 2024
Print demux-bitrate if available, else hls-bitrate, not both (as
demux-bitrate is generally more reliable). This avoids printing "HLS
kbps" which looks weird.

Fixes
mpv-player#14453 (comment)
sfan5 pushed a commit that referenced this pull request Aug 2, 2024
Print demux-bitrate if available, else hls-bitrate, not both (as
demux-bitrate is generally more reliable). This avoids printing "HLS
kbps" which looks weird.

Fixes
#14453 (comment)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

mpv thinks cover is a video track
4 participants