You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -24,7 +28,7 @@ PHP package to parse audio files metadata, with [JamesHeinrich/getID3](https://g
24
28
| MKA | ✅ | Matroska |`matroska`|_Cover not supported_|
25
29
| MKV | ✅ | Matroska |`matroska`|_Cover not supported_|
26
30
| APE | ❌ | Monkey's Audio |||
27
-
| MP3 | ✅ | MPEG audio layer 3 |`id3v1`,`id3v2`||
31
+
| MP3 | ✅ | MPEG audio layer 3 |`id3v2`,`id3v1`||
28
32
| MP4 | ✅ | Digital multimedia container format |`quicktime`||
29
33
| M4A | ✅ | mpeg-4 audio |`quicktime`||
30
34
| M4B | ✅ | Audiobook |`quicktime`||
@@ -44,13 +48,38 @@ PHP package to parse audio files metadata, with [JamesHeinrich/getID3](https://g
44
48
45
49
You want to add a format? [See FAQ](#faq)
46
50
47
-
##Requirements
51
+
### Updatable formats
48
52
49
-
- PHP >= 8.1
53
+
`JamesHeinrich/getID3` can update some formats, but not all.
54
+
55
+
> - ID3v1 (v1 & v1.1)
56
+
> - ID3v2 (v2.3, v2.4)
57
+
> - APE (v2)
58
+
> - Ogg Vorbis comments (need `vorbis-tools`)
59
+
> - FLAC comments
60
+
61
+
| Format | Notes |
62
+
| :----: | :-------------------: |
63
+
| FLAC |_Cover not supported_|
64
+
| MP3 ||
65
+
| OGG |_Cover not supported_|
66
+
67
+
### Convert properties
68
+
69
+
`Audio::class` convert some properties to be more readable.
70
+
71
+
| ID3 type | Original | New property |
72
+
| :------: | :------------: | :-----------: |
73
+
|`id3v2`|`band`|`albumArtist`|
74
+
|`id3v2`|`track_number`|`trackNumber`|
50
75
51
76
## About
52
77
53
-
Audio files can use different formats, this package aims to provide a simple way to read them with [JamesHeinrich/getID3](https://github.com/JamesHeinrich/getID3). The `JamesHeinrich/getID3` package is excellent to read metadata from audio files, but output is just an array, current package aims to provide a simple way to read audio files with a beautiful API.
78
+
Audio files can use different formats, this package aims to provide a simple way to read them with [`JamesHeinrich/getID3`](https://github.com/JamesHeinrich/getID3). The `JamesHeinrich/getID3` package is excellent to read metadata from audio files, but output is just an array, current package aims to provide a simple way to read audio files with a beautiful API.
$audio->audio(); // `?AudioMetadata` with audio metadata
96
135
$audio->cover(); // `?AudioCover` with cover metadata
97
136
```
98
137
138
+
### Update
139
+
140
+
You can update audio files metadata with `Audio::class`, but not all formats are supported. [See supported formats](#updatable-formats)
141
+
142
+
```php
143
+
$audio = Audio::get('path/to/audio.mp3');
144
+
145
+
// you can use file content
146
+
$cover = file_get_contents('path/to/cover.jpg');
147
+
// or file path
148
+
$cover = 'path/to/cover.jpg';
149
+
150
+
$tag = $audio->update()
151
+
->setTitle('New Title')
152
+
->setArtist('New Artist')
153
+
->setAlbum('New Album')
154
+
->setGenre('New Genre')
155
+
->setYear('2022')
156
+
->setTrackNumber('2/10')
157
+
->setAlbumArtist('New Album Artist')
158
+
->setComment('New Comment')
159
+
->setComposer('New Composer')
160
+
->setCreationDate('2021-01-01')
161
+
->setDescription('New Description')
162
+
->setDiscNumber('2/2')
163
+
->setEncodingBy('New Encoding By')
164
+
->setEncoding('New Encoding')
165
+
->setIsCompilation(false)
166
+
->setLyrics('New Lyrics')
167
+
->setStik('New Stik')
168
+
->setCover($cover)
169
+
->save();
170
+
```
171
+
172
+
Some properties are not supported by all formats, for example `MP3` can't handle `lyrics` or `stik` properties, if you try to update these properties, they will be ignored.
173
+
99
174
### Extras
100
175
101
176
Audio files format metadata with different methods, `JamesHeinrich/getID3` offer to check these metadatas by different methods. In `extras` property of `Audio::class`, you will find raw metadata from `JamesHeinrich/getID3` package, like `id3v2`, `id3v1`, `riff`, `asf`, `quicktime`, `matroska`, `ape`, `vorbiscomment`...
102
177
103
178
If you want to extract specific field which can be skipped by `Audio::class`, you can use `extras` property.
104
179
105
180
```php
106
-
$audio = Audio::read('path/to/audio.mp3');
181
+
$audio = Audio::get('path/to/audio.mp3');
107
182
$extras = $audio->extras();
108
183
109
184
$id3v2 = $extras['id3v2'] ?? [];
110
185
```
111
186
112
-
### ID3
113
-
114
-
Data from `JamesHeinrich/getID3` package with formatting.
115
-
116
-
```php
117
-
$audio = Audio::read('path/to/audio.mp3');
118
-
119
-
$audio->id3()->raw(); // `array` with raw metadata
120
-
$audio->id3()->item(); // `?Id3Item` with item metadata
In `Audio::class`, you have a property `extras` which contains all raw metadata, if `JamesHeinrich/getID3` support this field, you will find it in this property.
0 commit comments