http live streaming ,m3u8 文件有没有开源的解析代码?

LENOVO_ 2012-05-14 04:01:31
近日需要用到这个功能,但是m3u8 是 m3u 的扩展,有EXT-X-STREAM-INF 这个字段,
是另一个 m3u8文件的地址,也就是说编程的话要递归进去。

需要用 C 语言完成这个功能,我看到这个是 java 实现的。

我查找 vlc 的代码里面只有解析 标准 m3u 文件的代码
只有 对 #EXTINF 进行了处理。


//Open and parse a M3U file:
int M3U_open(char *fileName){
FILE *f;
char lineText[512];
char chrLength[20];
char title[264];
struct M3U_songEntry *singleEntry;
int playListCount = lPlayList.songCount;

f = fopen(fileName, "rt");
if (f == NULL){
//Error opening file:
return(-1);
}

while(fgets(lineText, 256, f) != NULL){
if (!strncmp(lineText, "#EXTINF:", 8)){
//Length and title:
splitSongInfo(lineText, chrLength, title);
}else if (!strncmp(lineText, "#EXTM3U", 7)){
//Nothing to do. :)
}else if (strlen(lineText) > 2){
//Store song info:
singleEntry = &lPlayList.songs[playListCount++];
strncpy(singleEntry->fileName, lineText, 263);
singleEntry->fileName[263] = '\0';
if ((int)singleEntry->fileName[strlen(singleEntry->fileName) - 1] == 10 || (int)singleEntry->fileName[strlen(singleEntry->fileName) - 1] == 13 ){
singleEntry->fileName[strlen(singleEntry->fileName) - 1] = '\0';
}
if ((int)singleEntry->fileName[strlen(singleEntry->fileName) - 1] == 10 || (int)singleEntry->fileName[strlen(singleEntry->fileName) - 1] == 13 ){
singleEntry->fileName[strlen(singleEntry->fileName) - 1] = '\0';
}

if (strlen(title)){
strncpy(singleEntry->title, title, 263);
}else{
getFileName(singleEntry->fileName, singleEntry->title);
}
singleEntry->title[263] = '\0';
singleEntry->length = atoi(chrLength);
if (playListCount == MAX_SONGS){
break;
}
}
}
fclose(f);

lPlayList.modified = 0;
lPlayList.songCount = playListCount;
strcpy(lPlayList.fileName, fileName);
return(0);
}




我想有没有同学可以提供下 C 语言实现的开源库地址,我拿来用用。
...全文
775 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
yinjie33 2014-09-04
  • 打赏
  • 举报
回复
楼主实现了吗
LENOVO_ 2012-05-14
  • 打赏
  • 举报
回复
ffmpeg 没去看,细挑起来太过复杂。

找到个

httplive.c: HTTP Live Streaming stream filter

里面有解析的代码,嵌套地址的事情我自己处理下。
伊娃码力 2012-05-14
  • 打赏
  • 举报
回复
你可以看看ffmpeg里面有没。

69,381

社区成员

发帖
与我相关
我的任务
社区描述
C语言相关问题讨论
社区管理员
  • C语言
  • 花神庙码农
  • 架构师李肯
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧