Получить mplayer для отображения текущего времени в часах и минутах

1791
enigmaticPhysicist

По умолчанию mplayer отображает текущее местоположение в видео в секундах, что является менее чем бесполезным. Пример:

A:4086.2 V:4086.2 A-V: 0.000 ct: 0.039 0/ 0 17% 2% 2.1% 3 0  ^--------^----- This is the current location in seconds. 

Ну и что с того? Mplayer имеет ужасные настройки по умолчанию. Что еще нового? Но mplayer легко настраивается до мельчайших деталей, поэтому должен быть способ изменить эту строку и поместить туда любую информацию, которая вам нужна. Хотя я просмотрел справочную страницу и не могу найти вариант, который это сделает. Идеальное поведение:

A:1:08:06.2 V:1:08:06.2 A-V: 0.000 ct: 0.039 0/ 0 17% 2% 2.1% 3 0  ^-----------^----- This is the current location in hours:minutes:seconds. 

Кто-нибудь нашел способ сделать это?

4

2 ответа на вопрос

3
林果皞

Let's look at the source code of mplayer, mplayer.c:

... // Audio time if (mpctx->sh_audio) { saddf(line, &pos, width, "A:%6.1f ", a_pos); if (!sh_video) { float len = demuxer_get_time_length(mpctx->demuxer); saddf(line, &pos, width, "("); sadd_hhmmssf(line, &pos, width, a_pos); saddf(line, &pos, width, ") of %.1f (", len); sadd_hhmmssf(line, &pos, width, len); saddf(line, &pos, width, ") "); } } // Video time if (sh_video) saddf(line, &pos, width, "V:%6.1f ", sh_video->pts); // A-V sync if (mpctx->sh_audio && sh_video) saddf(line, &pos, width, "A-V:%7.3f ct:%7.3f ", a_v, corr); ... 

As you can see, only if (mpctx->sh_audio) AND if (!sh_video) whereas audio-only will call sadd_hhmmssf() which will print hh:mm:ss format to stdout. But mpctx->sh_audio && sh_video whereas audio+video wouldn't.

So if you invoke the mplayer command with -novideo option, it will included hh:mm:ss format:

[xiaobai@xiaobai example]$ mplayer -novideo example.mkv MPlayer SVN-r37391-5.1.1 (C) 2000-2015 MPlayer Team ... Video: no video Position: 58 % A: 90.5 (01:30.4) of 145.4 (02:25.4) 0.0% 

[MPlayer-dev-eng] [PATCH] total time for audio-only files explained the origin of audio-only:

the attached patch makes MPlayer display the total time in the status line for audio-only files. I think this is useful for audio-only since

1) the status line is still quite small

2) you can't just activate the OSD to find the total time

From this explanation, we know OSD can be activated to achieve the same goal. So now just read man mplayer and search for OSD keyword:

 ... o Toggle OSD states: none / seek / seek + timer / seek + timer + total time. ... P Show progression bar, elapsed time and total duration on the OSD. ... -osdlevel <0-3> (MPlayer only) Specifies which mode the OSD should start in. 0 subtitles only 1 volume + seek (default) 2 volume + seek + timer + percentage 3 volume + seek + timer + percentage + total time ... 

This means that press P will toggle the current time/total time on the fly, or invoke mplayer -osdlevel 3 file to show the current time/total time consistently: enter image description here

[UPDATE]

Keep in mind that there are 4 states if you continuously pressing o:

  1. current time
  2. current time/total time (acts like -osdlevel 3)
  3. OSD enabled (no time show yet, but press P is allow)
  4. OSD disabled (press P will do nothing)

For unknown reason,-novideo still accept o key, and only introduce 2 states, i.e., enabled OSD and disable OSD. A bug occur if you press o enable OSD and then press P and it will show 00:00:00/total time.

Интересно. Похоже, mplayer нужен новый переключатель для изменения форматирования времени в терминале. Тем не менее, экранное меню - достойный обходной путь. Спасибо за вашу помощь, Xiaobai. enigmaticPhysicist 8 лет назад 1
0
enigmaticPhysicist

Моим собственным решением было переключение на форк mplayer под названием mpv, который по умолчанию обрабатывает отображение времени терминала в реальном времени. Кажется, что серьезное развитие mplayer полностью зашло в тупик, поэтому mpv стал лучше во всех отношениях. Он стал моим основным медиаплеером.

Похожие вопросы