-
Notifications
You must be signed in to change notification settings - Fork 127
/
Copy pathrecording.html
333 lines (329 loc) · 30 KB
/
recording.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head>
<meta charset="utf-8" />
<meta name="generator" content="pandoc" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes" />
<title>Recording stations</title>
<style>
body {padding: 2em;}
@media screen and (max-width: 770px) {
body {padding: 10px;}
}
body {max-width: 750px; margin: auto;}
h2 {margin-top: 2.5em; border-bottom:1px solid SaddleBrown; color: SaddleBrown;}
h3 {margin-top: 2em; color: SaddleBrown; text-decoration: underline SaddleBrown}
h4 {margin: 2em 0 1em 0; color: SaddleBrown; font-size: 1em;}
h4:before {content: "# "; font-weight: bold; vertical-align: middle;}
h5 {margin: 2em 0 1em 0; color: SaddleBrown; font-size: 1em;;}
h5:before {content: "## "; font-weight: bold; vertical-align: middle;}
p, table, ol, ul {margin-left: .8em;}
STRONG {color: SaddleBrown;}
dl {margin: 2em;}
dd {margin: 1em;}
dt {font-weight: bold;}
TABLE {border: 1px solid SaddleBrown; border-collapse: collapse; margin-left: auto; margin-right: auto; border-radius: 5px; -moz-border-radius: 5px; border-collapse:separate; box-shadow: 5px 5px 15px #888888;}
TH {text-align: left; vertical-align: top; padding: 5px;color: SaddleBrown;border: 1px solid SaddleBrown; background-color: SaddleBrown; color: white;}
TD {text-align: left; vertical-align: top; padding: 5px 10px;border: 1px solid SaddleBrown;}
pre { background-color: rgba(245, 245, 245, 1); color: #474747; padding: 1.5em; border: 1px solid #C7C7C7; border-radius: 5px; -moz-border-radius: 5px; -webkit-border-radius: 5px; overflow: auto; box-shadow: 5px 5px 15px #C7C7C7;}
.task-list {list-style-type: none; padding: 0; margin: 0 0 0 1em ;}
img{display: block; margin-left: auto; margin-right: auto; max-width: 750px; width: 100%; background:transparent; padding:3px; border:1px solid #999999; border-radius: 5px; -moz-border-radius: 5px; -webkit-border-radius: 5px; box-shadow:5px 5px 15px #888888;}
.indented {text-indent: -1.5em; padding-left: 1.5em; margin-left: 1em;}
a{ color: SaddleBrown;}
a:visited{color: SaddleBrown;}
</style>
</head>
<body>
<header id="title-block-header">
</header>
<h1 style="color: SaddleBrown" id="pyradio-stations-recording">PyRadio Stations Recording</h1>
<hr />
<p><strong>Berfore you continue, read this!</strong></p>
<p>Generally, recording a radio streaming broadcast is considered legit, if the recording is to be used for personal use only (i.e. to listen to the broadcast at a later time).</p>
<p>Distributing such a recording, is illegal. Broadcasting it is also illegal. Its reproduction before an audience is also illegal. In some countries/regions, it is also illegal to split or tag the songs in the recording.</p>
<p>Please make sure you are informed about this topic, about what the law considers illegal at your country/region, <strong>before using this feature!</strong></p>
<p><strong>You have been warned!</strong></p>
<p><strong>PyRadio</strong>, its creator and maintainers do not condone any behavior that involves online piracy or copyright violation. This feature is provided strictly for personal use, and to utilize another requested feature: <strong>pausing and resuming</strong> playback.</p>
<hr />
<h2 id="table-of-contents">Table of Contents <span style="padding-left: 10px;"><sup style="font-size: 50%"><a href="#" title="Go to top of the page">Top</a></sup></span></h2>
<!-- vim-markdown-toc Marked -->
<ul>
<li><a href="#intro">Intro</a>
<ul>
<li><a href="#mpv">MPV</a></li>
<li><a href="#mplayer">MPlayer</a></li>
<li><a href="#vlc">VLC</a></li>
<li><a href="#vlc-recording-on-windows">VLC recording on Windows</a></li>
</ul></li>
<li><a href="#recording-implementation">Recording implementation</a>
<ul>
<li><a href="#starting-recording-from-the-command-line">Starting recording from the command line</a></li>
<li><a href="#file-location">File location</a>
<ul>
<li><a href="#changing-recordings-location">Changing recordings location</a></li>
</ul></li>
<li><a href="#file-type">File type</a></li>
<li><a href="#chapters">Chapters</a></li>
<li><a href="#cover-image">Cover image</a>
<ul>
<li><a href="#mkvtoolnix-installation">MKVToolNix installation</a>
<ul>
<li><a href="#linux">Linux</a></li>
<li><a href="#macos">MacOS</a></li>
<li><a href="#windows">Windows</a></li>
</ul></li>
</ul></li>
<li><a href="#files-location">Files location</a></li>
<li><a href="#pausing-playback">Pausing playback</a></li>
</ul></li>
<li><a href="#post-recording">Post recording</a>
<ul>
<li><a href="#changing-the-cover">Changing the cover</a></li>
<li><a href="#correcting-chapter-markers">Correcting chapter markers</a>
<ul>
<li><a href="#1.-extract-the-srt">1. Extract the SRT</a></li>
<li><a href="#2.-edit-the-srt-file">2. Edit the SRT file</a></li>
<li><a href="#3.-srt-to-chapters">3. SRT to Chapters</a></li>
</ul></li>
</ul></li>
<li><a href="#listing-recordings-and-the--mkv-command-line-option">Listing recordings and the -mkv command line option</a></li>
</ul>
<!-- vim-markdown-toc -->
<p><a href="index.html#recording-stations">[Return to main doc]</a></p>
<h2 id="intro">Intro <span style="padding-left: 10px;"><sup style="font-size: 50%"><a href="#" title="Go to top of the page">Top</a></sup></span></h2>
<p><strong>PyRadio v. 0.9.2.8</strong> introduces the ability to record stations, a feature used mainly to facilitate another feature: the ability to <em>pause and resume playback</em>.</p>
<p>All supported media players (<strong>MPV</strong>, <strong>MPlayer</strong> and <strong>VLC</strong>) support stream recording, each implementing it in a different way, which pose a challenge for the front end implementation.</p>
<p>Before we see the differences, let us talk about some things that will make the whole thing easier to understand.</p>
<p>When it comes to recording a stream the program has to provide two things:</p>
<ol type="1">
<li><p>a <strong>recorder</strong>, which is the component that will connect to the stream (in our case the station), receive its data, and write them in a file that media players can recognize and reproduce.<br />
<br />
Since this is the program receiving data from the station, it will also receive song titles, or other stations data, but will not save them to the recorded file.</p></li>
<li><p>a <strong>monitor</strong>, which is the component that will reproduce the saved stream so that the user can monitor what is being downloaded.<br />
<br />
The <strong>monitor</strong> will just reproduce what’s written to the file by the <strong>recorder</strong>, so it knows nothing about a station, it’s data and song titles transmitted by it.</p></li>
</ol>
<p>Now, let’s see how <strong>PyRadio</strong>’s supported players behave.</p>
<h3 id="mpv">MPV</h3>
<p><strong>MPV</strong> stream recording has the following characteristics:</p>
<ul>
<li><p>it is considered an <strong>experimental feature</strong> by the <strong>MPV</strong> developers.<br />
Radio streaming uses well known and established codecs (mainly mp3 and aac) and I have had no broken recording while testing the feature (even with flac stations).</p></li>
<li><p><strong>MPV</strong> has the ability to play and record a stream at the same time (both the <strong>recorder</strong> and the <strong>monitor</strong> components are active simultaneously).<br />
This is very convenient, since all one has to do is add a command line parameter and start recording, while listening to what’s being recorded.</p></li>
<li><p>adjusting the volume or muting the player will not affect what’s being recorded.</p></li>
<li><p>when paused, the player will pause the playback but will keep recording the stream. Furthermore, song titles will stop being updated, but will be correctly displayed and updated when playback is resumed.</p></li>
</ul>
<h3 id="mplayer">MPlayer</h3>
<p><strong>MPlayer</strong> stream recording has the following characteristics:</p>
<ul>
<li><p>it does not have the ability to record and play a stream at the same time.<br />
This means that the front end (<strong>PyRadio</strong>) will have to use two <em>mplayer</em> instances (run <em>mplayer</em> twice): one as a <strong>recorder</strong> and one as a <strong>monitor</strong>.</p></li>
<li><p>the <strong>recorder</strong> will display the song titles in addition to saving the output file.</p></li>
<li><p>the <strong>monitor</strong> will be started after the output file gets to a certain size, set to 12000 bytes by trial and error.</p></li>
<li><p>pausing and resuming the <strong>monitor</strong> for long will lead to song titles being out of sync, since the <strong>recorder</strong> will keep receiving data (and song titles) even when the playback if off.</p></li>
</ul>
<h3 id="vlc">VLC</h3>
<p><strong>VLC</strong> stream recording has the following characteristics:</p>
<ul>
<li><p>it does not have the ability to record and play a stream at the same time.<br />
This means that the front end (<strong>PyRadio</strong>) will have to use two <em>vlc</em> instances (run <em>vlc</em> twice): one as a <strong>recorder</strong> and one as a <strong>monitor</strong>.</p></li>
<li><p>the <strong>recorder</strong> will display the song titles in addition to saving the output file.</p></li>
<li><p>the <strong>monitor</strong> will be started after the output file gets to a certain size, set to 120000 bytes by trial and error.</p></li>
<li><p>pausing and resuming the <strong>monitor</strong> for long will lead to song titles being out of sync, since the <strong>recorder</strong> will keep receiving data (and song titles) even when the playback if off.</p></li>
</ul>
<h3 id="vlc-recording-on-windows">VLC recording on Windows</h3>
<p><strong>VLC</strong> recording in <strong>not</strong> supported on <strong>Windows</strong>.</p>
<p>The <strong>VLC</strong> implementation on <strong>Window</strong> is a bit clumsy as it is as a radio player, and duplicating all this clumsiness in order to support recording as well, is just too much.</p>
<p>Trying to enable recording while <strong>VLC</strong> is the active player will lead to displaying a message informing the user of the situation and ways to proceed.</p>
<p>Consequently, this restriction has been applied to the “<em>Switch Media Player</em>” window (opened with “<strong>\m</strong>”); when recording a station and trying to change the player in use on <strong>Windows</strong>, selecting <strong>VLC</strong> is not supported.</p>
<h2 id="recording-implementation">Recording implementation <span style="padding-left: 10px;"><sup style="font-size: 50%"><a href="#" title="Go to top of the page">Top</a></sup></span></h2>
<p>The following keys are used for this feature:</p>
<table>
<thead>
<tr>
<th>Key</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td>|<br>(pipe symbol)</td>
<td>Toggle recording on and off</td>
</tr>
<tr>
<td>Space</td>
<td>Pause and resume playback</td>
</tr>
</tbody>
</table>
<p>In order to record a station, recording has to be enabled <strong>beforehand</strong>, by pressing the <em>“pipe symbol</em>” or “<em>vetical line</em>” (“<strong>|</strong>”). Then the following message appears:</p>
<p><a href="https://members.hellug.gr/sng/pyradio/pyradio-recording1.jpg" target="_blank"><img style="width: 550px" src="https://members.hellug.gr/sng/pyradio/pyradio-recording1.jpg" alt="Enable recording" /></a></p>
<p>When this is done an “<strong>[r]</strong>” will be displayed at the top left corner of the window. This means that recording is enabled, but <strong>PyRadio</strong> is not currently recording to a file.</p>
<p>When playback is started (i.e. start playing a station), an “<strong>[R]</strong>” will be displayed at the top left corner of the window (replacing the “<strong>[r]</strong>” that was already there), which means that <strong>PyRadio</strong> is actually recording the station to a file.</p>
<p>The following image is a mockup presenting the difference.</p>
<p><a href="https://members.hellug.gr/sng/pyradio/pyradio-recording2.jpg" target="_blank"><img style="width: 550px" src="https://members.hellug.gr/sng/pyradio/pyradio-recording2.jpg" alt="Recording mockup" /></a></p>
<p>Pressing the <em>“pipe symbol</em>” or “<em>vetical line</em>” (“<strong>|</strong>”) again will disable recording and nothing will be displayed at the top left corner of the window. The actual recording of the station will still be active, until the station is stopped.</p>
<p>It must be made clear that toggling the recording status for <strong>PyRadio</strong> will actually take effect after a station has been started or stopped. This is because of the way the players get the recording command; through command line arguments, which can only be passed when the player is executed.</p>
<h3 id="starting-recording-from-the-command-line">Starting recording from the command line</h3>
<p>One can use the “<strong>–record</strong>” command line parameter to start the program in recording mode.</p>
<p>This would be extra useful to start playback and recording, for example:</p>
<pre>pyradio -p 3 --record</pre>
<p>This command would open the default playlist (or the one last used, if set in the config), using the default player, and start playing and recording station No 3.</p>
<p style="margin: 1.5em 4em 0 4em; text-indent: -2.5em;"><strong>Note:</strong> If the default player is <strong>VLC</strong> on Windows, and the “<strong>–record</strong>” command line parameter is used, a message informing the user that recording is not supported, will be displayed.</p>
<h3 id="file-location">File location</h3>
<p>Files created by the recording feature will be saved under the “<strong>pyradio-recordings</strong>” folder inside the user’s <strong>HOME</strong> directory, by default.</p>
<p>The file will be named:</p>
<pre>[date] [Station Name].mkv</pre>
<p style="margin: 1.5em 4em 0 4em; text-indent: -2.5em;"><strong>Note:</strong> Up to version <strong>0.9.2.24</strong>, <strong>PyRadio</strong> would save the recorded files in a folder named <strong>recordings</strong> inside its configuration directory. If this folder already exists, it will be automatically moved to the new default location.</p>
<h4 id="changing-recordings-location">Changing recordings location</h4>
<p>One could change the location (and name) of the recordings folder, using the “<em>Recording dir</em>” option in the <em>Configuration windows</em>.</p>
<p>Upon saving the configuration, <strong>PyRadio</strong> will move the existing folder to the new location. If the new location’s folder already exists, the old folder will be moved inside it (in order to avoid overwriting any existing files).</p>
<p>You can get more info at <a href="rec-dir.html">Recording Directory</a>.</p>
<h3 id="file-type">File type</h3>
<p><strong>PyRadio</strong> will produce a <strong>mkv</strong> file when recording a station.</p>
<p>This is just a measure of convenience since the type of audio (mp3, aac, aac+, flac, etc.) the station will broadcast cannot be known beforehand (before starting the recording, that is).</p>
<p>Although a <strong>mkv</strong> file is a video/audio/subs etc. container, it’s perfectly fine to contain just a sound stream, as is the case of the files produced by <strong>PyRadio</strong>.</p>
<p>The file can be (hopefully) reproduced using any video media player.</p>
<h3 id="chapters">Chapters</h3>
<p>As a convenience, <strong>PyRadio</strong> will write chapter markers to the file produced, provided that:</p>
<ol type="1">
<li><p><a target="_blank" href="https://mkvtoolnix.download/">MKVToolNix</a> is installed.<br />
MKVToolNix is a set of tools to create, alter and inspect <a target="_blank" href="http://www.matroska.org/">Matroska</a> files under Linux, other Unices and Windows.<br />
<strong>PyRadio</strong> uses <em>mkvmerge</em> (<em>mkvmerge.exe</em> on Windows) to add chapters to the MKV file.</p></li>
<li><p>The stations will provide <em>ICY Titles</em> (the titles will be used as <strong>chapter titles</strong>).</p></li>
</ol>
<p>Things to consider:</p>
<ul>
<li><p>The first chaprer will always be at 00:00 and will be the name of the station.</p></li>
<li><p>Chapters markers timing depends on the time the <em>ICY Titles</em> are received, plus any overhead added by <strong>PyRadio</strong>.<br />
<br />
This means that, for whatever reason, a chapter marker may not exactly point to the beginning of the song associated with it. To change or correct chapter markers, please refer to section <a href="#correcting-chapter-markers">Correcting chapter markers</a>.</p></li>
</ul>
<h3 id="cover-image">Cover image</h3>
<p><strong>PyRadio</strong> will insert a cover image to every recorded file when <a target="_blank" href="https://mkvtoolnix.download/">MKVToolNix</a> has been detected.</p>
<p>The default image is named “<em>cover.png</em>” and is located in the “<em>data</em>” folder, within the configuration directory.</p>
<p>There are two way to change this cover image:</p>
<ol type="1">
<li><p>To permanently change the cover image for all recordings, create a <strong>PNG</strong> file named “<strong>user-cover.png</strong>” in the “<em>data</em>” folder.<br />
<br />
<strong>Tip:</strong> to get to the folder, execute <strong>pyradio</strong>, press “***” and “<strong>2</strong>”.</p></li>
<li><p>After you have stopped the recording, set any <strong>PNG</strong> file as a cover image for the recorded file, using the procedure explained in section <a href="#changing-the-cover">Changing the cover</a>.</p></li>
</ol>
<p>The image below shows how a chapter aware player will display and handle chapter markers found in a MKV file. The file also uses the default cover image. This is the <a target="_blank" href="https://sourceforge.net/projects/mpc-hc/">Media Player Classic</a> on Windows 7.</p>
<p><a href="https://members.hellug.gr/sng/pyradio/pyradio-chapters.gif" target="_blank"><img src="https://members.hellug.gr/sng/pyradio/pyradio-chapters.gif" alt="PyRadio Chapters" /></a></p>
<h4 id="mkvtoolnix-installation">MKVToolNix installation</h4>
<p>Why would I want to install yet another package / program, you may ask.</p>
<p>Here’s why:</p>
<ol type="1">
<li><p>Through <strong>MKVToolNix</strong> it is possible to have the songs titles embedded in the recorded file itself.</p></li>
<li><p>If the player used to reproduce the recorded file is chapters aware (most are), you can also navigate to the songs; their titles will be availabe at the <strong>Chapters</strong> menu (wherever the application chooses to place it).</p></li>
<li><p>If your player of choice for <strong>PyRadio</strong> is <strong>MPlayer</strong>, you really should take the time to install <strong>MKVToolNix</strong>.<br />
<br />
The reason is that <strong>MPlayer</strong> will dump the audio data it receives to the file without any alteration. This means that even though the saved file will have the <em>mkv</em> extension, the file will not be a valid Mastroka file; it will be an MP3, a FLAC, a AAC or whatever encoding is used by the station.<br />
<br />
Using <strong>MKVToolNix</strong> to add chapters to the file will actually create a valid <strong>mkv</strong> file.</p></li>
</ol>
<p>Having said that, let’s see how to install <strong>MKVToolNix</strong>.</p>
<h5 id="linux">Linux</h5>
<p>On <strong>Linux</strong> you will have no problem installing the package; all distros will include it, either as <em>mkvtoolnix</em>, or <em>mkvtoolnix-cli</em> or whatever.</p>
<p>Just make sure that after the installation you can execute <strong>mkvmerge</strong> from a terminal.</p>
<h5 id="macos">MacOS</h5>
<p>On <strong>MacOS</strong>, it all depends on your System Version, i guess.</p>
<p>First try to use <a target="_blank" href="https://brew.sh/">HomeBrew</a>:</p>
<pre>brew install mkvtoolnix</pre>
<p>I do not know if using <a target="_blank" href="https://brew.sh/">HomeBrew</a> for the installation will place <strong>mkvmerge</strong> into your PATH, but if it does, you are done.</p>
<p>I was not able to install it on <em>Catalina</em> using <a href="">HomeBrew</a>, so I ended up using the AppImage from <a target="_blank" href="https://mkvtoolnix.download/downloads.html#macosx">MKVToolNix</a>. Just make sure you download the right version for your system.</p>
<p>Then, since the installed application was not in the PATH (so that <strong>PyRadio</strong> finds <strong>mkvmerge</strong>), I just executed (in a terminal):</p>
<pre>sudo find / -name mkvmerge</pre>
<p>and ended up with</p>
<pre>/System/Volumes/Data/Applications/MKVToolNix-54.0.0.app/Contents/MacOS/mkvmerge
/Applications/MKVToolNix-54.0.0.app/Contents/MacOS/mkvmerge</pre>
<p>Since I do not know the difference between the first and second result, I will just use the second one, just because it is shorter :)</p>
<p>So, finally:</p>
<pre>mkdir -p ~/.config/pyradio/data
echo '#!/bin/bash' > ~/.config/pyradio/data/mkvmerge
echo '/Applications/MKVToolNix-54.0.0.app/Contents/MacOS/mkvmerge "$@"' >> ~/.config/pyradio/data/mkvmerge
chmod +x ~/.config/pyradio/data/mkvmerge</pre>
<h5 id="windows">Windows</h5>
<p>For <strong>Windows 10</strong> and <strong>11</strong> you have two options; either install the package provided by <a target="_blank" href="https://mkvtoolnix.download/">MKVToolNix</a>, or use the portable version.</p>
<p>If you decide to go with the later option, please read on.</p>
<p>For <strong>Window 7</strong> (or <strong>Windows 10</strong> and <strong>11</strong> portable installation), this is what you do:</p>
<ol type="1">
<li><p>Download the <strong>7z</strong> file provided by <a target="_blank" href="https://github.com/jpsdr/MKVToolnix-QT5-Windows-7/releases">MKVToolNix for Windows 7</a>.<br />
<br />
If you have decided to use one of the <strong>portable</strong> versions of <a target="_blank" href="https://mkvtoolnix.download/">MKVToolNix</a> on <strong>Windows 10</strong> or <strong>11</strong>, download that <strong>7z</strong> file instead.</p></li>
<li><p>“Install” it in <strong>PyRadio Configuration Folder</strong>.<br />
<br />
To do that, either press “<em>\o</em>” in <strong>PyRadio</strong>, or execute pyradio -od, to open the configuration folder in the File Explorer.</p></li>
<li><p>Create a folder named “<strong>mkvtoolnix</strong>”</p></li>
<li><p>Extract the <strong>7z</strong> file you previously downloaded, in the “<strong>mkvtoolnix</strong>” folder.</p></li>
</ol>
<h3 id="files-location">Files location</h3>
<p>The file produced by the recording function will be placed in the <strong>recordings</strong> directory.</p>
<p>If <strong>MKVToolNix</strong> is not installed, the file will be downloaded in this directory and will not be altered by <strong>PyRadio</strong>.</p>
<p>If <strong>MKVToolNix</strong> is installed, a “<em>tmp_</em>” prefix will be added to the recorded filename, which will be removed after chapters addition.</p>
<p style="margin: 1.5em 4em 0 4em; text-indent: -2.5em;"><strong>Note:</strong> On <strong>Windows</strong>, if <strong>MKVToolNix</strong> is installed, a dedicated routine will be executed at program’s startup to remove all “<em>tmp_</em>” recorded files.</p>
<h3 id="pausing-playback">Pausing playback</h3>
<p>After you have started recording a station, <strong>PyRadio</strong> will connect to it and start downloading the station data and at the same time will produce sound for you to hear what’s downloaded.</p>
<p>You can then press “<strong>Space</strong>” to pause the playback, but still continue downloading the station’s data.</p>
<p>Pressing “<strong>Space</strong>” again will resume playback from where it left off.</p>
<p>As a consequence, listening to the end of a show that you have paused for say 10 minutes, and then stopping the station (both playback and recording), the file recorded will have an excess of 10 minutes of data, past the end of the actual show.</p>
<p>Finally, please keep in mind that all other keys relevant to starting, stopping and restarting a station’s playback remain the same; only the behavior of the “<strong>Space</strong>” key has changed when recording is on.</p>
<h2 id="post-recording">Post recording <span style="padding-left: 10px;"><sup style="font-size: 50%"><a href="#" title="Go to top of the page">Top</a></sup></span></h2>
<p>After recording a station, there are some action one may want to perform on the recorded file:</p>
<ol type="1">
<li><p>change the cover image provided by <strong>PyRadio</strong></p></li>
<li><p>correct the timing of captured chapters</p></li>
</ol>
<h3 id="changing-the-cover">Changing the cover</h3>
<p>As already stated, <strong>PyRadio</strong> will embed a <strong>cover</strong> to every recording (provided that <a target="_blank" href="https://mkvtoolnix.download/">MKVToolNix</a> is installed).</p>
<p>The default image is a PNG file named “<strong>cover.png</strong>” located under the <strong>data</strong> folder in the configuration directory.</p>
<p>One can change this cover image using the following command:</p>
<pre>pyradio -mkv recorded.mkv -scv image.png</pre>
<p>Both <strong>recorded.mkv</strong> and <strong>image.png</strong> can be inserted either as an absolute path/filename or as a relative one. In the later case, the relevant file can either be in the current directory or under the “<strong>recordings</strong>” folder.</p>
<h3 id="correcting-chapter-markers">Correcting chapter markers</h3>
<p><strong>PyRadio</strong> does provide a way to correct these misplaced chapter markers.</p>
<p>The way to do it is:</p>
<ol type="1">
<li><p>extract a <strong>SRT</strong> file from a recorded <em>MKV</em> file, containing the chapter names as subtitles.</p></li>
<li><p>edit the <em>SRT</em> file and correctly place the subtitles.</p></li>
<li><p>insert the <em>SRT</em> file to the original <strong>MKV</strong> file, transforming the subtitles timing and test to chapters.</p></li>
</ol>
<p>The following image shows this procedure.</p>
<p><a href="https://members.hellug.gr/sng/pyradio/mkv-srt-to-chapters.png" target="_blank"><img style="width: 250px" src="https://members.hellug.gr/sng/pyradio/mkv-srt-to-chapters.png" alt="MKV SRT to Chapters" /></a></p>
<p>In detail:</p>
<h4 id="extract-the-srt">1. Extract the SRT</h4>
<p>Execute the command:</p>
<pre>pyradio -mkv file.mkv -srt</pre>
<p>The file produced by this command will be named <strong>file.srt</strong> (the input file name, after replacing the “<em>mkv</em>” extension with the “<em>srt</em>” extension).</p>
<h4 id="edit-the-srt-file">2. Edit the SRT file</h4>
<p>At this point, the SRT file can be edited with any Subtitle Editor, and subtitles’ timing can be adjusted, entries added or deleted, etc.</p>
<p>Although any Subtitle Editor will do, I would recommend using <a target="_blank" href="https://github.com/SubtitleEdit/subtitleedit/releases">Subtitle Edit</a> to edit the subtitles. The only reason is that this free (open source) program is capable of displaying the waveform of the edited file, which is very helpful in our case, since there is no video stream in the recorded files. Although this is a Windows program, it does run on Linux as well; for more info please refer to <a target="_blank" href="https://www.nikse.dk/subtitleedit/help#linux">Subtitle Edit on Linux</a>.</p>
<h4 id="srt-to-chapters">3. SRT to Chapters</h4>
<p>After the SRT file has been edited, it can be “inserted” into the original <strong>MKV</strong> file. This will actually convert the subtitle entries to chapter marker entries and insert them to the <strong>MKV</strong> file, replacing the older ones.</p>
<p>The command to run is:</p>
<pre>pyradio -mkv file.mkv -ach</pre>
<h2 id="listing-recordings-and-the--mkv-command-line-option">Listing recordings and the -mkv command line option <span style="padding-left: 10px;"><sup style="font-size: 50%"><a href="#" title="Go to top of the page">Top</a></sup></span></h2>
<p>The <strong>-mkv</strong> command line option used above, will specify the <strong>MKV</strong> file to use with subsequent commands, but there is a problem here; recorded file names are too complicated to pass as arguments, written by hand or otherwise.</p>
<p><strong>PyRadio</strong> addresses this issue by accepting a <strong>number</strong> instead of a file name as a parameter to <strong>-mkv</strong>; this number is actually the index of the required file in the alphabetically sorted list of existing files.</p>
<p>To get the <strong>index</strong> number, one would just use the <strong>-lr</strong> command line option:</p>
<pre>$ pyradio -lr
List of files under recordings
┏━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
┃ # ┃ Name ┃
┡━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┩
│ 1 │ 2023-11-02 17-06-03 Lounge (Illinois Street Lounge - SomaFM).mkv │
│ 2 │ 2023-11-02 14-37-17 Pop (PopTron! - SomaFM).mkv │
│ 3 │ 2023-10-31 20-15-41 ΕΡΑ - Κέρκυρα (Περιφερειακός σταθμός).mkv │
│ 4 │ 2023-10-31 15-22-57 Celtic Sounds.mkv │
│ 5 │ 2023-10-31 11-14-43 La Top - 107.7 FM - Grupo Invosa.mkv │
└───┴──────────────────────────────────────────────────────────────────┘</pre>
<p>This way, the command:</p>
<pre>pyradio -mkv '2023-11-02 17-06-03 Lounge (Illinois Street Lounge - SomaFM).mkv' -srt</pre>
<p>could actually be inserted as</p>
<pre>pyradio -mkv 1 -srt</pre>
<p>In this case, <strong>1</strong> is the index of the file in the list provided by the <strong>-lr</strong> command.</p>
<p>As a convenience, negative numbers can also be used; <strong>-1</strong> means the last file, <strong>-2</strong> the second to last, etc. This way, to work with the last recorded file, one would just use “<strong>-mkv -1</strong>” on all the necessary commands.</p>
</body>
</html>