clsid2 / mpc-hc

Media Player Classic
GNU General Public License v3.0
11.17k stars 493 forks source link

Display source resolution and codec in status bar #1264

Closed ltguillaume closed 7 months ago

ltguillaume commented 3 years ago

Currently it's difficult to quickly check the resolution and codec of the currently playing video. This is useful info at all times, but especially when opening a video via YouTube-dl.

Pressing Tab is too invasive, first because it draws over the entire video, second because it takes a while to find the info among all the text, and third because it takes 3 more Tab presses to get rid of it.

I propose, like the advanced settings ShowLangInStatusbar and ShowFPSInStatusbar, two settings called ShowResolutionInStatusbar and ShowCodecInStatusbar, in order to show both the video source resolution and codec on the status bar.

cw2 commented 3 years ago

It seems to be rather similar to #1200 (in principle), so I guess I could try this one too... What would be the preferred/recommended format of the displayed information?

Currently, with the above mentioned settings the status text looks something like Playing [H/W] [AUD:eng] [23.98 fps (1.00x)]

and the requested video codec information shown in the Properties is like Video: MPEG4 Video (H264) 1920x800 23.976fps [V: English [eng] (h264 high L4.1, yuv420p, 1920x800) [default]]

ArcticGems commented 3 years ago

Maybe: Playing [H/W] [1920x800] [H264] [23.98 fps (1.00x)] [AUD:eng] or Playing [H/W] [H264:1920x800] [23.98 fps (1.00x)] [AUD:eng]

ltguillaume commented 3 years ago

I'd say: Playing H/W H264 1920x800 23.98fps (1.00x) English

I'm not sure why the [ ] brackets are there: they're not clickable pieces of text or anything (could be useful for audio language, though), so I'd say they just add clutter. Somehow it makes me feel like the text is clickable.

clsid2 commented 3 years ago

The brackets are to separate the pieces of information. I am not going to debate that at this moment. In future I may think about possible changes. For example grouping related things together.

It could be a single option to show video format FourCC and resolution: [H264 1920x800]

A helper function should be written to gather this info from the filter graph. Call it after graph creation and cache the values, so it doesn't need to redo it on each statusbar refresh.

ltguillaume commented 3 years ago

Yeah, I agree, some separation makes it clearer. I also agree that codec+resolution could be combined, and audio codec+language would perhaps be helpful, too. Example: Playing H/W | H264 1920x800 | 23.98fps (1.00x) | AC3 English

ArcticGems commented 3 years ago

Yeah, I agree, some separation makes it clearer. I also agree that codec+resolution could be combined, and audio codec+language would perhaps be helpful, too. Example: Playing H/W | H264 1920x800 | 23.98fps (1.00x) | AC3 English

Good idea to also add audio codec+language!

I'm fine with either of these two =

Playing [H/W] [H264:1920x800] [23.98fps (1.00x)] [AC3:English] Playing H/W | H264 1920x800 | 23.98fps (1.00x) | AC3 English

cw2 commented 3 years ago

@clsid2 It will take me a while to get more familiar with the existing code base, so I would like to ask if there is already a function that returns codec name like 'H264'? I have found certain functions that return too much information (e.g. stream Info(...)) or CMediaTypeEx::GetVideoCodecName(...). Or should it simply be FOURCC ?

clsid2 commented 3 years ago

I don't think there is a function for that yet.

But I found some example code for extracting the FourCC from a video mediatype. PlayerCaptureDialog.h ->line 184 Note: the whole string conversion step done there seems inefficient to me. You could also just compare some values in subtype.Data4 to verify if it is a video mediatype. In case it is not, set FourCC to "UNKN" (unknown).

Video mediatypes look like this: {34363248-0000-0010-8000-00AA00389B71} Where the first part is the FourCC (in hex format in reverse order).

ArcticGems commented 3 years ago

@cw2 Any plans for adding audio codec + language??

ltguillaume commented 3 years ago

Thanks @cw2, looks great!

clsid2 commented 3 years ago

There already is an option for showing the audio and subtitle language.

ltguillaume commented 3 years ago

There already is an option for showing the audio and subtitle language.

@clsid2 I think @ArcticGems is aware of this, it's about showing codec + language.

ArcticGems commented 3 years ago

@clsid2 For example something like [AC3 English] =

Playing [H/W] [H264 1920x800] [23.98fps (1.00x)] [AC3 English]

cw2 commented 3 years ago

Playing [H/W] [H264 1920x800] [23.98fps (1.00x)] [AC3 English]

There is a slight problem with retrieving descriptive name of the (mainly audio) codec, resp. the media subtype. In the current implementation, "video codec" is FourCC code of the media subtype, so in case of H264 the displayed value is actually something like "AVC1". Unfortunately, most audio media subtypes do not have such descriptive strings and there is not yet a function in the existing codebase that would readily provide it in the desired format.

@clsid2 has already mentioned it in https://github.com/clsid2/mpc-hc/pull/1270#issuecomment-908511452 and also he is planning to change the formatting code. Personally, I like the information in the form mentioned above, which is very similar to what is already displayed in various submenus and Properties dialog; I will gladly help with the implementation...

ArcticGems commented 3 years ago

Playing [H/W] [H264 1920x800] [23.98fps (1.00x)] [AC3 English]

There is a slight problem with retrieving descriptive name of the (mainly audio) codec, resp. the media subtype. In the current implementation, "video codec" is FourCC code of the media subtype, so in case of H264 the displayed value is actually something like "AVC1". Unfortunately, most audio media subtypes do not have such descriptive strings and there is not yet a function in the existing codebase that would readily provide it in the desired format.

@cw2 So it's not a simple "string extraction" from what can be seen in Properties dialog (sorry, not a programmer 🙇 )??

Well, hopefully there will be a solution in near future 😃

cw2 commented 3 years ago

Well, not really a simple "string extraction" - it has to be the opposite way, "string composition" :) One possible implementation could be a lightweight version of CMediaTypeEx.ToString() function... https://github.com/clsid2/mpc-hc/blob/da4065080d0d31cef8a36aa251e8c129ae027eb6/src/DSUtil/MediaTypeEx.cpp#L49-L223 (the resulting string has too much information and uses too detailed descriptions, we just need a more compact version for the status bar)

ale5000-git commented 3 years ago

I haven't tried but this should do the trick:

CString GetAudioFormat(IPin* pPin)
{
    CString codec = _T(""); 

    if (majortype == MEDIATYPE_Audio || subtype == MEDIASUBTYPE_DOLBY_AC3) {
        if (formattype == FORMAT_WaveFormatEx) {
            WAVEFORMATEX* wfe = (WAVEFORMATEX*)Format();

            if (wfe->wFormatTag/* > WAVE_FORMAT_PCM && wfe->wFormatTag < WAVE_FORMAT_EXTENSIBLE
            && wfe->wFormatTag != WAVE_FORMAT_IEEE_FLOAT*/
                    || subtype != GUID_NULL) {
                codec = GetAudioCodecName(subtype, wfe->wFormatTag, false);
                } 
            } 
        } else if (formattype == FORMAT_VorbisFormat || formattype == FORMAT_VorbisFormat2) {
            codec = GetAudioCodecName(subtype, 0, false); 
        } 
    }
    if (codec.IsEmpty())
        codec = _T("UNKN");

    return codec;
}

I have just adapted it on Notepad++ so there can be errors.

clsid2 commented 3 years ago

The WAVEFORMAT audio mediatypes use a unique 2 character value, which is actually just a numeric ID, not anything descriptive. You need to add a mapping table to convert those IDs into strings. You can find a list of mediatypes in ksuuids.h and moreuuids.h. The table doesn't need to be complete at first, we can expand it later to add rare stuff. For descriptions use the shortest form that is commonly used. For example "AC3", "DTS", and "TrueHD".

For video I will probably also add a mapping function to normalize certain common FourCCs into their actual format name. For example AVC1->H264, HVC1->HEVC, and FPS1->Fraps.

ale5000-git commented 3 years ago

@clsid2: Why not just reusing this? https://github.com/clsid2/mpc-hc/blob/develop/src/DSUtil/MediaTypeEx.cpp#L294 It can be refactored and can be added a parameter to return short or long text.

I don't look at C++ from a lot of time but wouldn't something like this or similar work?

CString CMediaTypeEx::GetAudioCodecName(const GUID& subtype, WORD wFormatTag, bool fulltext = true)
{
...
names[WAVE_FORMAT_DOLBY_AC3] = fulltext? _T("Dolby AC3") : _T("AC3")

70% of them are already short enough.

clsid2 commented 3 years ago

Yes, that could be adapted to optionally return shortened names.

ArcticGems commented 3 years ago

I just updated.

It looks very nice! 👍

The fps should be next to "video codec + resolution" IMO and maybe remove the space in "23.98 fps". =

Playing [H/W] [H264 1920x800] [23.98fps (1.00x)]

I'm eagerly waiting for the "audio codec + language"(AC3 English) to be added. 😃 ❤️

ArcticGems commented 3 years ago

Is the "codec translation" done in lav splitter a better choice than cw2 suggestion??? =

https://git.1f0.de/gitweb/?p=lavfsplitter.git;a=blob;f=decoder/LAVVideo/Media.cpp;h=e5b3d8bde9a35d4b6cc312f766157037e56951eb;hb=HEAD

clsid2 commented 3 years ago

That is totally not useful at all. Everyone please stop making this kind of useless suggestions when you don't have any knowledge on the subject. This wastes my time and is really demotivating me to work on this.

dbojan commented 8 months ago

Hello. I see that this has not been implemented yet.

If this is not going to be added, could you please add this: when user press key 'i' on keyboard, program would show info from 'file/properties/media info', or at least 'file/properties/details' with info about audio and video codec in file.

Or add it to view/information, labeled as 'a/v codec': ...

Or another menu item, similar to statistics, which would always show audio and video codec info.

It is very useful when working with multiple files with different formats/codecs.

Thanks.

clsid2 commented 8 months ago

It can already show a lot of info in status bar: Options > Advanced

Only audio is not yet implemented.

adipose commented 7 months ago

Good to close?

bibsp commented 6 months ago

VVC added?

adipose commented 6 months ago

VVC added?

What's VVC? H266?

bibsp commented 6 months ago

Yes. Else it will be detected as UNKN.

clsid2 commented 6 months ago

Wrong. It will simply show the fourcc which is VVC1.