Galina Mihaylova & Anton Ivanov

Editing M3U and M3U8 files

Editing M3U and M3U8 files
Editing M3U and M3U8 files

Editing M3U and M3U8 files

M3U and M3U8 files (which is the version using UTF-8 encoding for better support for different characters) are the main playlist formats used in IPTV.

Here are the basic rules (tags) and operands (attributes) that you will need to edit these files:

Basic rules and structure of M3U/M3U8 for IPTV
  1. Start tag

Every M3U/M3U8 playlist must start with the required tag:

  • #EXTM3U
    • Rule: Always on the first line. Indicates that the file is an extended M3U playlist, which allows the use of additional tags such as #EXTINF.
  1. Record definition (channel)

Each channel or media stream is defined by two basic lines:

A. Information tag

  • #EXTINF: <duration>, <channel name>
    • Rule: This tag provides information about the entry that follows.
    • Operands:
      • <duration>: For IPTV, 0 or -1 is usually used, since the duration is unknown or unlimited.
      • <channel name>: The name that will be displayed to the user.
    • Additional attributes (operands) in #EXTINF:
      • tvg-id=”<identifier>”: A unique identifier for the channel, which is used by the electronic program guide (EPG) to match the channel to the correct broadcast. Important for EPG.
      • tvg-name=”<name>”: Alternative name, sometimes used for matching.
      • group-title=”<group>”: Defines the group/category (e.g. “Bulgarian”, “News”, “Sports”) in which the channel will be displayed in the player. Very important for organization.
      • tvg-logo=”<URL to logo>”: Direct URL to the channel logo image.

B. Stream URL

  • <Media stream URL>
    • Rule: This line always follows directly after the corresponding #EXTINF line.
    • Operands: This is the direct HTTP/HTTPS/RTSP/UDP address to the media stream (channel) itself.
Example structure and editing

Code snippet

#EXTM3U

#EXTINF:0 tvg-id=”ext” group-title=”Bulgarian”,BG | Alfa TV

http://012345x.com:999/wzw84zrZyW/FxVvvV4kbP/25184

#EXTINF:0 tvg-id=”ext” group-title=”Bulgarian”,BG | 24 Kitchen HD

http://012345x.com:999/wzw84zrZyW/FxVvvV4kbP/25283

#EXTINF:0 tvg-id=”ext” group-title=”Bulgarian”,BG | amc

How to edit
  1. Change group (category):
    • If you want “Beta TV” to be in group “Local”, change:
      • to
      • group-title=”Bulgarian”
      • to
      • group-title=”Local”
  2. Change name:
    • If you want it to be “Beta Television”, change:
      • BG | Beta TV
      • on
      • Beta Television
  3. Adding a Logo:
    • To add a logo (if you know the URL), add the tvg-logo attribute:
      • #EXTINF:0 tvg-id=”ext” group-title=”Bulgarian”,BG | Beta TV
      • on
      • #EXTINF:0 tvg-id=”ext” group-title=”Bulgarian” tvg-logo=”https://url-to-logo.com/beta.png”,BG | Beta TV
  4. Add a new channel:
    • You need the stream URL and add it at the end (or wherever makes sense), following the same structure:

Code snippet

#EXTINF:0 tvg-id=”nova.bg” group-title=”News”,Nova News HD

http://url.of.the.new.stream/nova-news.m3u8

Other important tags

Less commonly used but useful tags (usually placed at the beginning of the file):

  • #EXTGRP:<group name>: Sometimes used to define the group before the list of channels in it. group-title in #EXTINF is the more common and preferred method.
  • #EXTVLCOPT:<settings>: To pass specific settings to VLC or compatible players.
  • #EXTIMG:<URL>: Rarely used for a background image.
In short

Editing is reduced to changing the text in the #EXTINF tag attributes (group-title, tvg-id, tvg-logo, name) or changing the URL of the stream that follows. Make sure there are no blank lines or wrong characters, especially if you are using an M3U8 file that requires UTF-8 encoding for proper display of Cyrillic.

To add a comment that makes the file more readable, use the extended tag symbol, but with unknown name after it. IPTV players usually ignore tags that they do not recognize.

The most common and de facto accepted way to comment is:

#

#COMMENT: or #EXT-COMMENT:

#REM (from ‘Remark’)

How to use comments

Simply start the line with #, followed by any name or directly the text of the comment:

Code snippet

#EXTM3U

# This line is a comment and will be ignored.

#EXTINF:0 tvg-id=”nova.bg” group-title=”Bulgarian News”,Nova TV HD

http://url-kõm-nova.m3u8

# —————– SPORTS CHANNELS —————–

#EXTINF:0 group-title=”Sports” tvg-id=”max.sport.1″,Max Sport 1 HD

http://url-to-max-sport-1.m3u8

In the above example:

  1. # This line is a comment and will be ignored.
  2. # —————– SPORTS CHANNELS —————–

These lines are for visual structuring only when editing and will not affect the playback of the playlist.

EPG (Electronic Program Guide) and logos

The tvg-id identifiers and the URL addresses for the logos (tvg-logo) are not standardized by a central authority, but are defined by the EPG data provider (XMLTV source).

To have a working EPG and logos, you need to do the following:

  1. Find an EPG data source (XMLTV)

You need to find a URL to a file that contains the program of Bulgarian channels, usually in XMLTV format. This file defines which tvg-id corresponds to which channel.

  • Popular community sources: Commonly used community-supported projects collect and format EPG data for different regions. Search for “XMLTV Bulgaria” or “IPTV EPG source Bulgaria”.
    • Example: A common source that can be looked at is https://iptv-epg.org/files/epg-bg.xml.gz (or similar community projects).
  1. Compare tvg-id

Once you have the EPG source, you need to see what id (which corresponds to the tvg-id in your M3U) is used for each channel in this XML file.

Structure in the XMLTV file:

XML

<channel id=”bnt1.bg”>

<display-name>BNT 1</display-name>

<icon src=”http://url-kum-logoto/bnt1.png” />

</channel>

In the above example:

  • tvg-id in your M3U playlist should be: bnt1.bg
  • The logo URL (tvg-logo) can be taken from the icon src attribute if your player does not download it automatically.

What to do:

  1. Select EPG Source: If your IPTV player supports EPG URL input, enter the address of the XMLTV file (e.g. https://iptv-epg.org/files/epg-bg.xml.gz).
  2. Edit M3U: Edit your M3U file by specifying the same tvg-id identifiers that are defined in the XMLTV file.

Example of compliance:

M3U Playlist XMLTV EPG File
#EXTINF:0 tvg-id=”bnt1.bg”,BNT 1 <channel id=”bnt1.bg”>
#EXTINF:0 tvg-id=”nova.bg”, Nova TV <channel id=”nova.bg”>
#EXTINF:0 tvg-id=”btv.bg”,bTV <channel id=”btv.bg”>
About the logo (tvg-logo)

Regarding logos, they are defined in two ways:

  1. Automatically from EPG: Most modern IPTV players (such as Tivimate, IPTV Smarters) automatically retrieve the logo URLs from the attribute <icon src=”…”> in the XMLTV file you entered.
  2. Manually in M3U: If the player does not do it automatically, you need to add a tvg-logo attribute to each channel in your M3U:

#EXTINF:0 tvg-id=”bnt1.bg” tvg-logo=”http://url-to-logo/bnt1.png”,BNT 1

Conclusion

The best place to find the correct tvg-ids is by finding and opening a current XMLTV source for Bulgaria and using the identifiers defined within it. Since these sources are community-maintained, they are the most reliable for matching EPG data.

 

Leave a comment

Your email address will not be published. Required fields are marked *