Audio file format with metadata supporting tagging? - audio

I would like to create a media player reading/writing all music metadata directly from the files. The MP3 format's id3 metadata already has most of the info like artist, song title, album name, but if you want to tag music with custom tags like "atmospheric", "feel-good-music", "road-trip", you need an external database that will attribute tags to filenames.
Is there a music format with reasonable size (not PCM WAV for example) that incorporates metadata including multiple tags? The word "tag" is often used for the ID3 Tag, making it difficult to find information on Google about actual tagging, and I only end up with MP3 ID3 pages.

You can use MP3 with ID3v2 which has — besides the standard fields you've already mentioned — support for TXXX frames. These frames are a textual mapping between keys and values which allow for arbitrary values stored in the files.
From the ID3v2 specification
4.2.6. User defined text information frame
This frame is intended for one-string text information concerning the
audio file in a similar way to the other "T"-frames. The frame body
consists of a description of the string, represented as a terminated
string, followed by the actual string. There may be more than one
"TXXX" frame in each tag, but only one with the same description.
<Header for 'User defined text information frame', ID: "TXXX">
Text encoding $xx
Description <text string according to encoding> $00 (00)
Value <text string according to encoding>
In your example, a valid TXXX frame would use, e.g., STYLE as description and atmospheric as actual value. If you're on Windows, you can try the Windows player foobar2000 and the tag editor Mp3tag (full disclosure: I'm the developer of Mp3tag).

Matroska supports most anything. It has a well-defined set of tags and is also extensible for you to add your own if needed.
https://www.matroska.org/technical/specs/tagging/index.html
It also supports pretty much any codec you throw at it.

Related

Building m3u8 playlist with mp4 files

I own a digital receiver which could also play IPTV channels (m3u8). I want to build my own local IPTV station to be able to watch a video playlist on TV. I configured a computer as a web server. Now, I am trying to build the m3u8 playlist. I tried to add the video files (mp4) to a blank m3u8 file.
#EXTM3U
file1.mp4
file2.mp4
The problem is that my IPTV player only plays file1.mp4 then stops. I am new to hls, however I would like to avoid to convert all my videos to hls with ts segments.
Are there any ways to make it working? Thank you!
While the first mp4 is recognized and played correctly, it isn't the 'correct' type of mp4 file to be played in this type of playlist. They need to be encoded as 'Fragmented MPEG-4' files. I'm suspecting that each file needs to contain a bit of information about the next segment.
From RFC 8216:
3.3. Fragmented MPEG-4
MPEG-4 Fragments are specified by the ISO Base Media File Format
[ISOBMFF]. Unlike regular MPEG-4 files that have a Movie Box
('moov') that contains sample tables and a Media Data Box ('mdat')
containing the corresponding samples, an MPEG-4 Fragment consists of
a Movie Fragment Box ('moof') containing a subset of the sample table
and a Media Data Box containing those samples. Use of MPEG-4
Fragments does require a Movie Box for initialization, but that Movie
Box contains only non-sample-specific information such as track and
sample descriptions.
A Fragmented MPEG-4 (fMP4) Segment is a "segment" as defined by
Section 3 of [ISOBMFF], including the constraints on Media Data Boxes
in Section 8.16 of [ISOBMFF].
The Media Initialization Section for an fMP4 Segment is an ISO Base
Media File that can initialize a parser for that Segment.
Broadly speaking, fMP4 Segments and Media Initialization Sections
are [ISOBMFF] files that also satisfy the constraints described in
this section.
The Media Initialization Section for an fMP4 Segment MUST contain a
File Type Box ('ftyp') containing a brand that is compatible with
'iso6' or higher. The File Type Box MUST be followed by a Movie Box.
The Movie Box MUST contain a Track Box ('trak') for every Track
Fragment Box ('traf') in the fMP4 Segment, with matching track_ID.
Each Track Box SHOULD contain a sample table, but its sample count
MUST be zero. Movie Header Boxes ('mvhd') and Track Header Boxes
('tkhd') MUST have durations of zero. A Movie Extends Box ('mvex')
MUST follow the last Track Box. Note that a Common Media Application
Format (CMAF) Header [CMAF] meets all these requirements.

Limiting DICOM tags

I am trying to limit the DICOM tags, which are retained, by using
for key in keys:
if key.upper() not in {'0028|0010','0028|0011'}:
image_slice.EraseMetaData(key)
in Python 3.6 where image_slice is of type SimpleITK.SimpleITK.Image
I then use
image_slice.GetMetaDataKeys()
to see what tags remain and they are the tags I selected. I then save the image with
writer.SetFileName(outputDir+os.path.basename(sliceFileNames[i]))
writer.Execute(image_slice)
where outputDir is the output directory name and os.path.basename(sliceFileNames[i]) is the DICOM image name. However, when I open the image, with Weasis or with MIPAV, I notice that there are a lot more tags than were in image_slice. For example, there is
(0002,0001) [OB] FileMetaInformationVersion: binary data
(0002,0002) [UI] MediaStorageSOPClassUID:
(0002,0003) [UI] MediaStorageSOPInstanceUID:
(0008,0020) [DA] StudyDate: (which is given the date that the file was created)
I was wondering how, and where these additional tags were added.
The group 2 tags you are seeing are meta data tags, that are always written while writing the dataset. Unless "regular" tags, which start with group 8, these group 2 tags do not belong to the dataset itself, but contain information about the encoding/writing of the dataset, like the transfer syntax - more information can be found in the DICOM standard, part 10. They will be recreated on saving a dataset to a file, otherwise, the DICOM file would not be valid.
About the rest of the tags I can only guess, but they are probably written by the software because they are mandatory DICOM tags and have been missing in the dataset. StudyDate is certainly a mandatory tag, so adding it if it is missing is correct, if the data is seen as derived data (which it usually is if you are manipulating it with ITK). I guess the other tags that you didn't mention are also mandatory tags.
Someone with more SimpleITK knowledge can probably add more specific information.

Is it possible to add custom metadata tags to music files?

I am working on a music player application and I'm not happy with the current standard for music tags. I would like to extend on the current ones. Is it possible to add custom metadata tags to audio files (MP3, OGG, FLAC, WAV)? Obviously only my application could read this metadata. Would adding custom metadata corrupt the files so they can't be played correctly by other players?
Yes, most tagging formats support custom tags.
ID3 allows TXXX.
FLAC and Vorbis Comments both allow tags with any name (it's not really prescribed in the same way ID3 is).
You can do it with MP4 if you use XMP to contain the tags: How can I embed metadata into a custom XMP field with exiftool?
Any other software that cannot work because a custom tag is set has bigger problems!

Add custom XMP Tags

I am looking for a tool or a way (.NET) to add custom XMP fields. Also, can someone explain the purpose of needing to know if the XMP tag is a textfield, textarea or a select?
XMP is written inside files as an XML packet or as a separate XML file. The XMP specification uses a subset of RDF/XML. So you could look at (RDF/)XML manipulation tools.
For embedded XPackets however, the packet length needs to be calculated and written at the start of the packet, so it may help to have a purpose built library. Adobe provides an XMP SDK (C++) for that.
XMP supports several content types for fields, like Text, Number or URL. Text fields, for example, could be restricted to values from a controlled vocabulary, for which it may make sense to use a select or dropdown form element in a GUI.

Is there anyway to get ID3 metadata from an MP3 or Vorbis comments from Ogg via the HTML5 audio element?

Mozilla Developer Center's HTML5 media guide describes an event for audio and video elements called "loadedmetadata". Is there anyway to get the metadata for files? I am writing an HTML5 extension for Google Chrome and I don't know what the metadata for the audio files I'm creating a player for beforehand.
Edit: This question seems to be kicking everyone's ass. :/
According to this you can use filereader.readAsBinaryString(file); to get the binary data of the ID3 tag.
filereader.readAsBinaryString(file); will asynchronously return a binary string with each byte represented by an integer in the range [0..255]. This is useful for binary manipulations of a file’s data, for example to look for ID3 tags in an MP3 file, or to look for EXIF data in a JPEG image.

Resources