如何将SYLT标签添加到mp3文件中



我想在mp3格式的歌曲中添加同步歌词。我正在使用诱变剂模块来做这件事。虽然我可以毫无问题地添加不同步的歌词,但我似乎无法让SYLT工作。这是代码

aud = ID3("C:\Music\Ghost.mp3")
aud.add(SYLT(encoding=Encoding.UTF8, format=2, type=1, text=sl))
aud.save()

其中";sl";是如下所示的格式列表

sl = [("lyric", millisecond), ("lyric", millisecond), ("lyric", millisecond)]

有人能指导我解决这个问题吗?如果有人能把我带向正确的方向,我将不胜感激。你的解释不需要用python。请随意用你熟悉的任何语言解释。提前谢谢。

附言:抱歉英语不好。它不是我的母语。

我从另一篇文章中了解到了这一点,并发现它以毫秒(1秒=1000毫秒(为单位存储位置。

以下是如何操作的基本示例:

from mutagen.id3 import ID3, SYLT, Encoding
filename = '/Users/JayRizzo/Music/Tom MacDonald - Angels (Explicit).mp3'
tag = ID3(filename)
sync_lrc = [
("It's not the liquor I'm addicted to, it's feeling brave",                                          1000),
("The feeling of not feeling the pain",                                                              2000),
("I been on and off the bottle, I put oxys up my nostrils, believe me",                              3000),
("You do anything to breathe before you suffocate",                                                  4000),
("I couldn't stop it, staying clean was not an option",                                              5000),
("I was tryna be myself but being me was such a problem",                                            6000),
("I just wanted to be Thomas, but Thomas was at the bottom of a hole he dug",                        7000),
("And getting comfortable inside a coffin, ay",                                                      8000),
("He locked it and swallowed the key, he caught up, forgot all his dreams",                          9000),
("Robbed outta calm and became embalmed in a toxic routine",                                        10000),
("Beer was the escape but I got stuck escaping",                                                    11000),
("Whiskey was the blanket in the coldest basement",                                                 12000),
("Way before the fame, I was wasted",                                                               13000),
("Freezing, doing anything I could to keep the flame lit",                                          14000),
("To anyone going through the same shit",                                                           15000),
("Heaven's got enough angels, you need to stay here",                                               16000),
("And I can't make you stay but sometimes going ain't a choice",                                    17000),
("And every choice you make is one that you didn't avoid",                                          18000),
("Crash the whip and ditch the car, burn a bridge, follow the stars",                               19000),
("You'll find monsters in the dark but nothing's worth it till it's hard",                          20000),
("Sometimes it's hard to see things clear (through your tears)",                                    21000),
("But anywhere is way better than here (fight your fears)",                                         22000),
("It's not the liquor I'm addicted to, it's feeling tough",                                         23000),
("When you get bullied half your life you feel weak like you just ain't enough",                    24000),
("Then you have a couple drinks and you catch a buzz",                                              25000),
("And finally have the courage to defend yourself and throw a punch",                               26000),
("And that adrenaline goes straight into your brain and blood",                                     27000),
("Addicted to the confidence, it's practically the greatest drug",                                  28000),
("Chasing dragons every night in all the latest clubs",                                             29000),
("What used to be your favorite thing somehow became a dangerous crutch",                           30000),
("It was what it was",                                                                              31000),
("And that's the thing, it can happen to like any of us",                                           32000),
("I had great parents, tight friends, strong walls, nice threads",                                  33000),
("Good school, good looking, good grades, time spent",                                              34000),
("Being normal only lasted for a while",                                                            35000),
("One bad choice sparked a downward spiral",                                                        36000),
("I've spent half my life tryna climb outta that hole",                                             37000),
("Heaven's got angels, we need you at home",                                                        38000),
("And I can't make you stay but sometimes going ain't a choice",                                    39000),
("And every choice you make is one that you didn't avoid",                                          40000),
("Crash the whip and ditch the car, burn a bridge, follow the stars",                               41000),
("You'll find monsters in the dark but nothing's worth it till it's hard",                          42000),
("Sometimes it's hard to see things clear (through your tears)",                                    43000),
("But anywhere is way better than here (fight your fears)",                                         44000),
("It ain't the liquor we're addicted to, it's everything else",                                     45000),
("The happiness we had but we forget how it felt",                                                  46000),
("We been drinking with the devil 'cause we're going through hell",                                 47000),
("Pray to God for a little bit of help",                                                            48000),
("Man, I been there, I did those things, I drank those drinks",                                     49000),
("I took those pills, I puked in sinks",                                                            50000),
("And the truth ain't pretty, listen up, it's a tough one",                                         51000),
("You get saved by your angels or become one",                                                      52000),
("Crash the whip and ditch the car, burn a bridge, follow the stars",                               53000),
("You'll find monsters in the dark but nothing's worth it till it's hard",                          54000),
("Sometimes it's hard to see things clear (through your tears)",                                    55000),
("But anywhere is way better than here (fight your fears)",                                         56000)
]
tag.setall("SYLT", [SYLT(encoding=Encoding.UTF8, lang='eng', format=2, type=1, text=sync_lrc)])
tag.save(v2_version=4)
print(tag.get('SYLT::eng'))

返回以下内容:

# [1000ms]: It's not the liquor I'm addicted to, it's feeling brave
# [2000ms]: The feeling of not feeling the pain
# [3000ms]: I been on and off the bottle, I put oxys up my nostrils, believe me
# [4000ms]: You do anything to breathe before you suffocate
# [5000ms]: I couldn't stop it, staying clean was not an option
# [6000ms]: I was tryna be myself but being me was such a problem
# [7000ms]: I just wanted to be Thomas, but Thomas was at the bottom of a hole he dug
# [8000ms]: And getting comfortable inside a coffin, ay
# [9000ms]: He locked it and swallowed the key, he caught up, forgot all his dreams
# [10000ms]: Robbed outta calm and became embalmed in a toxic routine
# [11000ms]: Beer was the escape but I got stuck escaping
# [12000ms]: Whiskey was the blanket in the coldest basement
# [13000ms]: Way before the fame, I was wasted
# [14000ms]: Freezing, doing anything I could to keep the flame lit
# [15000ms]: To anyone going through the same shit
# [16000ms]: Heaven's got enough angels, you need to stay here
# [17000ms]: And I can't make you stay but sometimes going ain't a choice
# [18000ms]: And every choice you make is one that you didn't avoid
# [19000ms]: Crash the whip and ditch the car, burn a bridge, follow the stars
# [20000ms]: You'll find monsters in the dark but nothing's worth it till it's hard
# [21000ms]: Sometimes it's hard to see things clear (through your tears)
# [22000ms]: But anywhere is way better than here (fight your fears)
# [23000ms]: It's not the liquor I'm addicted to, it's feeling tough
# [24000ms]: When you get bullied half your life you feel weak like you just ain't enough
# [25000ms]: Then you have a couple drinks and you catch a buzz
# [26000ms]: And finally have the courage to defend yourself and throw a punch
# [27000ms]: And that adrenaline goes straight into your brain and blood
# [28000ms]: Addicted to the confidence, it's practically the greatest drug
# [29000ms]: Chasing dragons every night in all the latest clubs
# [30000ms]: What used to be your favorite thing somehow became a dangerous crutch
# [31000ms]: It was what it was
# [32000ms]: And that's the thing, it can happen to like any of us
# [33000ms]: I had great parents, tight friends, strong walls, nice threads
# [34000ms]: Good school, good looking, good grades, time spent
# [35000ms]: Being normal only lasted for a while
# [36000ms]: One bad choice sparked a downward spiral
# [37000ms]: I've spent half my life tryna climb outta that hole
# [38000ms]: Heaven's got angels, we need you at home
# [39000ms]: And I can't make you stay but sometimes going ain't a choice
# [40000ms]: And every choice you make is one that you didn't avoid
# [41000ms]: Crash the whip and ditch the car, burn a bridge, follow the stars
# [42000ms]: You'll find monsters in the dark but nothing's worth it till it's hard
# [43000ms]: Sometimes it's hard to see things clear (through your tears)
# [44000ms]: But anywhere is way better than here (fight your fears)
# [45000ms]: It ain't the liquor we're addicted to, it's everything else
# [46000ms]: The happiness we had but we forget how it felt
# [47000ms]: We been drinking with the devil 'cause we're going through hell
# [48000ms]: Pray to God for a little bit of help
# [49000ms]: Man, I been there, I did those things, I drank those drinks
# [50000ms]: I took those pills, I puked in sinks
# [51000ms]: And the truth ain't pretty, listen up, it's a tough one
# [52000ms]: You get saved by your angels or become one
# [53000ms]: Crash the whip and ditch the car, burn a bridge, follow the stars
# [54000ms]: You'll find monsters in the dark but nothing's worth it till it's hard
# [55000ms]: Sometimes it's hard to see things clear (through your tears)
# [56000ms]: But anywhere is way better than here (fight your fears)

到目前为止,似乎没有出现在iTunes、QuickTime或VLC中。

最新更新