📜 ⬆️ ⬇️

Webcasting - working with encodings

Having connected to Corbin (no, this is not an advertisement), and for the sake of interest, while browsing their website, I came across a large number of Internet radio stations, whom I immediately tried to get addicted to. My disappointment was great. I did not find a single player that would work normally with the encoding of the tags of the stream. The last hope was VLC, but it turned out to be the worst of all - it received only general information about the stream, but did not receive the information about the current composition transmitted by the server.
Mplayer gave me the following to the console:
torkvemada@inquisitia-nout ~ $ mplayer 85.21.79.5:8185/listen.pls
MPlayer 1.0rc2-4.3.3 (C) 2000-2007 MPlayer Team
CPU: Intel(R) Atom(TM) CPU N270 @ 1.60GHz (Family: 6, Model: 28, Stepping: 2)
CPUflags: MMX: 1 MMX2: 1 3DNow: 0 3DNow2: 0 SSE: 1 SSE2: 1
Compiled with runtime CPU detection.
mplayer: could not connect to socket
mplayer: No such file or directory
Failed to open LIRC support. You will not be able to use your remote control.

Playing 85.21.79.5:8185/listen.pls.
Resolving 85.21.79.5 for AF_INET6...
Couldn't resolve name for AF_INET6: 85.21.79.5
Connecting to server 85.21.79.5[85.21.79.5]: 8185...
Cache size set to 320 KBytes

Playing 85.21.79.5:8185/.
Resolving 85.21.79.5 for AF_INET6...
Couldn't resolve name for AF_INET6: 85.21.79.5
Connecting to server 85.21.79.5[85.21.79.5]: 8185...
Name : 101.ru: Aquarium BG
Genre : N/A
Website: www.101.ru
Public : yes
Bitrate: 0kbit/s
Cache size set to 320 KBytes
Cache fill: 0.00% (0 bytes)
ICY Info: StreamTitle='ÀÊÂÀÐÈÓÌ - Íàóêè Þíîøåé - 0:00';StreamUrl='';
Cache fill: 15.00% (49152 bytes)
Audio file file format detected.
==========================================================================
Forced audio codec: mad
Opening audio decoder: [libmad] libmad mpeg audio decoder
AUDIO: 44100 Hz, 2 ch, s16le, 96.0 kbit/6.80% (ratio: 12000->176400)
Selected audio codec: [mad] afm: libmad (libMAD MPEG layer 1-2-3)
==========================================================================
AO: [pulse] 44100Hz 2ch s16le (2 bytes per sample)
Video: no video
Starting playback...
A: 27.8 (27.8) of -0.0 (unknown) 3.7% 45%
ICY Info: StreamTitle='ÀÊÂÀÐÈÓÌ - Âåëèêèé Äâîðíèê - 0:00';StreamUrl='';
A: 212.2 (03:32.2) of -0.0 (unknown) 3.7% 45%
ICY Info: StreamTitle='ADVBEGIN - ADVBEGIN - 0:00';StreamUrl='';
A: 213.5 (03:33.5) of -0.0 (unknown) 3.7% 45%
ICY Info: StreamTitle='ADV_0001 - 0:00';StreamUrl='';
A: 243.6 (04:03.5) of -0.0 (unknown) 3.7% 45%
ICY Info: StreamTitle='ADVENG - ADVENG - 0:00';StreamUrl='';
A: 247.7 (04:07.6) of -0.0 (unknown) 3.7% 45%
ICY Info: StreamTitle='ÀÊÂÀÐÈÓÌ - Áëþç Ïðîñòîãî ×åëîâåêà - 0:00';StreamUrl='';
A: 348.7 (05:48.7) of -0.0 (unknown) 3.6% 45%
Exiting... (Quit)

As you can see, all the information is obtained, but it turned out to be unable to recognize the cp1251 mplayer encoding. Like all other players. A similar situation, by the way, with a high probability would be repeated in Windows, it would be enough just to find a stream with UTF-8. But we, fortunately, have the opportunity to rectify the situation. In an hour of digging into mplayer source and a couple of recompilations (alas, my atom leaves much to be desired in terms of compilation speed), I sketched a small patch that allows the command line parameter to indicate in which encoding the stream comes to us and displays the information in the correct encoding. The patch uses iconv, so if desired, it can be adapted to absolutely any player, to display both id3 tags and stream information in your linux system.
All further guidance relates to APT systems (Ubuntu, Debian, possibly AltLinux etc.), but it is easy to repeat it on an arbitrary system.
Run ` apt-get source mplayer` to get the mplayer source.
Go to the resulting directory (mine is mplayer-1.0 ~ rc2 ) and edit the files:

It now remains to assemble and install. We type ` debuild` and either get scolded for missing packages (install them and run debuild again), or after a while we have several assembled deb packages. Install: ` sudo dpkg -i ../mplayer_1.0~rc2-0ubuntu19+medibuntu1_i386.deb` and fix so that the package manager does not even think about reinstalling the package from the repository: ` sudo aptitude hold mplayer` .
Lazy can download:

Now we specify the parameter `tagcp` and enjoy:
torkvemada@inquisitia-nout ~ $ mplayer -tagcp cp1251 85.21.79.5:8185/listen.pls
MPlayer 1.0rc2-4.3.3 (C) 2000-2007 MPlayer Team
CPU: Intel(R) Atom(TM) CPU N270 @ 1.60GHz (Family: 6, Model: 28, Stepping: 2)
CPUflags: MMX: 1 MMX2: 1 3DNow: 0 3DNow2: 0 SSE: 1 SSE2: 1
Compiled with runtime CPU detection.
mplayer: could not connect to socket
mplayer: No such file or directory
Failed to open LIRC support. You will not be able to use your remote control.

Playing 85.21.79.5:8185/listen.pls.
Resolving 85.21.79.5 for AF_INET6...
Couldn't resolve name for AF_INET6: 85.21.79.5
Connecting to server 85.21.79.5[85.21.79.5]: 8185...
Cache size set to 320 KBytes

Playing 85.21.79.5:8185/.
Resolving 85.21.79.5 for AF_INET6...
Couldn't resolve name for AF_INET6: 85.21.79.5
Connecting to server 85.21.79.5[85.21.79.5]: 8185...
Name : 101.ru: Aquarium BG
Genre : N/A
Website: www.101.ru
Public : yes
Bitrate: 0kbit/s
Cache size set to 320 KBytes
Cache fill: 0.00% (0 bytes)
ICY Info: StreamTitle=' - - 0:00';StreamUrl='';
Cache fill: 15.00% (49152 bytes)
Audio file file format detected.
==========================================================================
Forced audio codec: mad
Opening audio decoder: [libmad] libmad mpeg audio decoder
AUDIO: 44100 Hz, 2 ch, s16le, 96.0 kbit/6.80% (ratio: 12000->176400)
Selected audio codec: [mad] afm: libmad (libMAD MPEG layer 1-2-3)
==========================================================================
AO: [pulse] 44100Hz 2ch s16le (2 bytes per sample)
Video: no video
Starting playback...
A: 14.9 (14.8) of -0.0 (unknown) 6.6% 45%
ICY Info: StreamTitle=' - №2 - 0:00';StreamUrl='';
A: 19.8 (19.8) of -0.0 (unknown) 6.5% 46%
Exiting... (Quit)

')

Source: https://habr.com/ru/post/72168/


All Articles