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

loadfile: update the format of terminal track information #14405

Merged
merged 1 commit into from
Jun 24, 2024

Conversation

guidocella
Copy link
Contributor

Stop making unselected tracks and editions grey because they can be hard to read over a dark background (\033[2m would be hard to differentiate from regular text with a light theme instead), and because there is no way to not print the escape sequences in --log-file.

Just use the same circles as the OSD and OSC. We need to print the empty circles for alignment on mlterm with East Asian fonts (we could also make them invisible with \033[8m but it would still get added to log files).

Add back the space before tracks and editions so they look like a sub-section of the "Playing..." line printed with playlists and of "Track switched", consistently with the metadata which starts with space which makes it look like a sub-section of the "File tags" line.

Also stop converting Hz to kHz for consistency with other log messages, e.g. AO: [pipewire] 48000Hz stereo 2ch floatp

Copy link
Member

@sfan5 sfan5 left a comment

Choose a reason for hiding this comment

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

I prefer "2ch 48000Hz" but this addresses the important points
"2.0 48000Hz" is also okay but not used inside mpv otherwise

@sfan5
Copy link
Member

sfan5 commented Jun 21, 2024

relevant PR #14192 (comment)

Copy link

github-actions bot commented Jun 21, 2024

Download the artifacts for this pull request:

Windows
macOS

player/loadfile.c Outdated Show resolved Hide resolved
player/loadfile.c Outdated Show resolved Hide resolved
player/loadfile.c Outdated Show resolved Hide resolved
player/loadfile.c Show resolved Hide resolved
@guidocella
Copy link
Contributor Author

Do we want to merge the track data in one set of parentheses, or at least hls-bitrate and external?

@rach-md
Copy link

rach-md commented Jun 22, 2024

Could you make it more consistent? samplerate on ao does not use space but track does. Also codec profile only show up after track switched, so show them from very first or just remove it.

@kasper93
Copy link
Contributor

  • editions are still quoted, while titles are not
  • after consideration editions should be first as before, they are the biggest, most important entity
  • there are two spaces after ●/○ for edition, while there are no for video/audio/subs
  • two spaces after track title look like an error, the separation is no clear enough and looks strange. Either bring back ' or make the separation more pronounced by other means
  • I think I preferred track modificators at the beginning, they are mixed in between the title and parameters now, maybe at the end would be better, after params.
  • For edition to be consistent we could alias edition to eid and do [ 0.035914] cplayer: ● Edition --eid=0 'Director's Cut' (*) aligned with the rest.
[  0.035624]    cplayer: ● Video  --vid=1  --vlang=eng  Salt (2010)  (*) (h264 1920x800 23.976 fps)
[  0.035679]    cplayer: ● Audio  --aid=1  --alang=eng  AC3 5.1 @ 640 Kbps  (*) (ac3 6ch 48000 Hz)
[  0.035722]    cplayer: ○ Audio  --aid=2  --alang=pol  AC3 5.1 @ 640 Kbps  (ac3 6ch 48000 Hz)
[  0.035761]    cplayer: ○ Audio  --aid=3  --alang=eng  Commentary  (aac 2ch 48000 Hz)
[  0.035810]    cplayer: ○ Subs   --sid=1  --slang=pol  (*) (subrip)
[  0.035846]    cplayer: ● Subs   --sid=2  --slang=eng  (subrip)
[  0.035881]    cplayer: ○ Subs   --sid=3  --slang=eng  forced  (subrip)
[  0.035914]    cplayer: ●  --edition=0 'Director's Cut' (*)
[  0.035947]    cplayer: ○  --edition=1 'Extended Cut'

@guidocella
Copy link
Contributor Author

Updated. Editions had issues because I've been modifying them blindly since I can't find any file with them so I don't think it's worth adding an option alias just for aligning them with tracks when they're so rare.

@kasper93
Copy link
Contributor

Looks like this now

[  0.035891]    cplayer: ● --edition=0  'Director's Cut'  (*)
[  0.035935]    cplayer: ○ --edition=1  'Extended Cut'
[  0.035994]    cplayer: ● Video  --vid=1  --vlang=eng  'Salt (2010)' (h264 1920x800 23.976 fps) (*)
[  0.036032]    cplayer: ● Audio  --aid=1  --alang=eng  'AC3 5.1 @ 640 Kbps' (ac3 6ch 48000 Hz) (*)
[  0.036073]    cplayer: ○ Audio  --aid=2  --alang=pol  'AC3 5.1 @ 640 Kbps' (ac3 6ch 48000 Hz)
[  0.036106]    cplayer: ○ Audio  --aid=3  --alang=eng  'Commentary' (aac 2ch 48000 Hz)
[  0.036139]    cplayer: ○ Subs   --sid=1  --slang=pol  (subrip) (*)
[  0.036172]    cplayer: ● Subs   --sid=2  --slang=eng  (subrip)
[  0.036204]    cplayer: ○ Subs   --sid=3  --slang=eng  'forced' (subrip)

I'm fine with this. Let see what @sfan5 thinks though.

@guidocella
Copy link
Contributor Author

Maybe use single spaces for editions?

@kasper93
Copy link
Contributor

Maybe use single spaces for editions?

Ok for me.

player/loadfile.c Outdated Show resolved Hide resolved
Comment on lines 301 to 307
APPEND(b, " (external)");
if (t->default_track)
APPEND(b, " (*)");
if (t->forced_track)
APPEND(b, " (f)");
if (t->attached_picture)
APPEND(b, " [P]");
Copy link
Contributor

Choose a reason for hiding this comment

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

Also instead of hieroglyphs, we could print it in full. Bit longer, but who know what [P] means?

(default, external, picture) for example, in most cases there are 1-2 flags per track.

Copy link
Member

Choose a reason for hiding this comment

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

I think short form is fine for (*) because it's so common

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It is incomprehensible without reading the code though

Copy link
Member

Choose a reason for hiding this comment

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

We can simply document it in the manual

Copy link
Contributor

@kasper93 kasper93 Jun 23, 2024

Choose a reason for hiding this comment

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

default is not that long and there is plenty of space (excluding title, which may not fit anyway). I mean sure, we can make users read code/docs to see what (*) means, but how to you even search for this? And why explain output when we can make it self-explainable? No other media player does some cryptic flags.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I agree with kasper, I don't see where you could even put in the docs.

print_stream(mpctx, mpctx->tracks[n]);
print_stream(mpctx, mpctx->tracks[n], msg ||
mpctx->playlist->num_entries > 1 ||
mpctx->playing->playlist_path);
Copy link
Member

Choose a reason for hiding this comment

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

a comment would be good

@guidocella guidocella force-pushed the tracks-circle branch 3 times, most recently from 067c6f0 to 9eb7f63 Compare June 23, 2024 16:36
player/loadfile.c Outdated Show resolved Hide resolved
player/loadfile.c Outdated Show resolved Hide resolved
player/loadfile.c Outdated Show resolved Hide resolved
Comment on lines 309 to 311
if (t->default_track || t->forced_track || t->attached_picture ||
t->visual_impaired_track || t->hearing_impaired_track || t->is_external)
APPEND(b, " [");
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
if (t->default_track || t->forced_track || t->attached_picture ||
t->visual_impaired_track || t->hearing_impaired_track || t->is_external)
APPEND(b, " [");
if (t->default_track || t->forced_track || t->attached_picture ||
t->visual_impaired_track || t->hearing_impaired_track || t->is_external)
{
APPEND(b, " [");
}

Copy link
Contributor

Choose a reason for hiding this comment

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

or even move it to first check

APPEND(b, first ? " [" : ""); first = false;

@sfan5
Copy link
Member

sfan5 commented Jun 23, 2024

can we maybe not make this into one mega-commit that changes everything all over again?

there are clear problems with the current code that I would prefer to see fixed before the next round of bikesheddings.
(by current I mean what's currently in master since d49879f)

@kasper93
Copy link
Contributor

there are clear problems with the current code

Which ones specifically? I though we are bikeshedding it from the beginning.

@guidocella
Copy link
Contributor Author

Which ones specifically? I though we are bikeshedding it from the beginning.

Same, and the changes are already done.

@kasper93
Copy link
Contributor

LGTM. I'm stopping here. I promise, I won't comment anymore.

Comment on lines 242 to 244
#define ADD_FLAG(b, flag, first) \
APPEND(b, " %s%s", first ? "[" : "", flag); \
first = false;
Copy link
Contributor

@kasper93 kasper93 Jun 23, 2024

Choose a reason for hiding this comment

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

Ok, last one.

Just small suggestion, wrap it in do while, so you don't accidentally forget about {}. And if you do that, you can remove {} from ifs below.

Suggested change
#define ADD_FLAG(b, flag, first) \
APPEND(b, " %s%s", first ? "[" : "", flag); \
first = false;
#define ADD_FLAG(b, flag) do { \
APPEND(b, " %s%s", first ? "[" : "", flag); \
first = false; \
} while(0)

(also removed first arg, we can assume it is there)

@guidocella guidocella force-pushed the tracks-circle branch 2 times, most recently from 20cbfa9 to 50f8db1 Compare June 23, 2024 18:03
@sfan5
Copy link
Member

sfan5 commented Jun 23, 2024

Which ones specifically? I though we are bikeshedding it from the beginning.

The color handling regarding log file and depending on stdout state is objectively broken.

@sfan5 sfan5 self-requested a review June 23, 2024 21:40
Copy link
Member

@sfan5 sfan5 left a comment

Choose a reason for hiding this comment

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

Fine otherwise

player/loadfile.c Outdated Show resolved Hide resolved
Stop making unselected tracks and editions grey because they can be hard
to read over a dark background (\033[2m would be hard to differentiate
from regular text with a light theme instead), and because there is no
way to not print the escape sequences in --log-file.

Just use the same circles as the OSD and OSC. We need to print the empty
circles for alignment on mlterm with East Asian fonts (we could also
make them invisible with \033[8m but it would still get added to log
files).

Add back the space before tracks and editions when printed after
"Playing..." or "Track switched" and similar, so they look like a
sub-section of it, consistently with the metadata which starts with
space which makes it look like a sub-section of the "File tags" line.

Leave 2 spaces between track columns.

Make the lang options only as long as the longest language.

Place hls-bitrate within the same parentheses as the other data.

Replace the incomprehensible (*) (f) and [P] with textual descriptions
within []. Also place external there.

Stop converting Hz to kHz for consistency with other log messages, e.g.
AO: [pipewire] 48000Hz stereo 2ch floatp

Remove the space in "2 ch" so it doesn't look like 2 separate values (We
considered using mp_chmap_to_str(&s->codec->channels) but it prints
values like "unknown2").
@sfan5 sfan5 merged commit 82ffe8f into mpv-player:master Jun 24, 2024
20 checks passed
@guidocella guidocella deleted the tracks-circle branch June 24, 2024 15:50
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.

None yet

4 participants