通过HTTP直播流从MP3提取ID3标签 [英] Extracting ID3 tags from MP3 over HTTP Live Streaming

查看:179
本文介绍了通过HTTP直播流从MP3提取ID3标签的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我从一个困难的时间提取ID3信息从通过Live HTTP Streaming流式传输的MP3(使用Wowza媒体服务器,如果有人好奇)。我知道标签(现在的相册标签和专辑的艺术品标签)正在适当地嵌入每个文件段,因为当我手动下载它们可以看到他们在每个段中列出的 .m3u 由服务器生成的索引文件。

I've been having quite a difficult time extracting ID3 information from an MP3 being streamed over Live HTTP Streaming (using the Wowza media server, if anyone is curious). I know that the tags (right now the album tag and the album artwork tag) are being properly embedded in each of the file segments because when I download them manually I can see them in each segment as listed in the .m3u index file generated by the server.

我使用 AVFoundation 这样,我就这样设置:

I am using the AVFoundation classes to do this, and I have it setup as such:

- (void)initializeAudioStream {
    NSURL *streamUrl = [NSURL URLWithString:self.urlField.text];
    AVPlayerItem *playerItem = [AVPlayerItem playerItemWithURL:streamUrl];
    self.musicPlayer = [AVPlayer playerWithPlayerItem:playerItem];
    self.musicPlayer.actionAtItemEnd = AVPlayerActionAtItemEndNone;
    [self.musicPlayer addObserver:self forKeyPath:@"status" options:NSKeyValueObservingOptionNew context:NULL];
}

一旦我的KVO方法被触发,我开始玩 self.musicPlayer ,我调用 addPeriodicTimeObserverForInterval 每1/4秒。正是在这种方法,我试图提取ID3元数据。

Once my KVO method is triggered, I start playing self.musicPlayer and I call addPeriodicTimeObserverForInterval on it for each 1/4 second. It is in this method that I try to extract the ID3 metadata.

我已经尝试了一切我可以想到的事情,以实现这一点,包括打印出

I have tried everything I can think of on the iOS side of things to accomplish this, including printing out

self.musicPlayer.currentItem.asset.commonMetadata

,并且迭代每个 AVAssetTrack 实例并打印出它们的元数据。 p>

as well as iterating over each of the AVAssetTrack instances and printing out their metadata.

for (AVAssetTrack *track in self.musicPlayer.currentItem.asset.tracks) {
    NSLog(@"Media type of track: %@", track.mediaType);
    NSLog(@"Track metadata: %@", track.commonMetadata);
}

有趣的是,资产总是说它有2个音轨。当我打印出他们的 mediaType 属性,我得到soun的第一个和tmet的第二个。我的假设是,第一轨道是音频数据本身,第二轨道是元数据。但是,我只看到一个空数组在 commonMetadata

What's interesting is that the asset always says it has 2 tracks. When I print out their mediaType property I get "soun" for the first one and "tmet" for the second. My assumption is that the first track is the audio data itself and the second track is metadata. However, I only ever see an empty array in commonMetadata.

我也检查属性的状态使用 statusOfValueForKey:error ,并且 commonMetadata 键总是以 AVKeyValueStatusLoaded

I also check the status of the properties using statusOfValueForKey:error on the tracks, and the commonMetadata key always comes back as AVKeyValueStatusLoaded.

任何想法?我在这里完全失去了。

Any ideas? I'm at a complete loss here.

此外,我目前正在运行这个通过运行iOS 4.2.1的iPhone 4模拟器。

Also, I am currently running this through the iPhone 4 simulator running iOS 4.2.1. I can't yet put it on a device since Apple is still approving my company's developer account.

推荐答案

我不能使用<$您可能希望尝试在 AVPlayerItem 上使用 timedMetadata : / p>

Instead of using commonMetadata you might want to try using timedMetadata on the AVPlayerItem:

[playerItem addObserver:self forKeyPath:@"timedMetadata" options:NSKeyValueObservingOptionNew context:NULL];

这篇关于通过HTTP直播流从MP3提取ID3标签的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆