您的位置:首页 > 理论基础 > 计算机网络

关于Http Live Streaming 的一点儿记录

2012-04-12 16:18 573 查看
此文合并到本人的文章
如何用nginx+ffmpeg实现苹果HLS协议
http://blog.csdn.net/deltatang/article/details/7931827
------------------------------------------------------------------------------------------------------------------------------------------------------
http://developer.android.com/guide/appendix/media-formats.html
andorid 的支持。

以下的内容是最初开始的资料,基本没有啥子价值,可以略过了:)

---------------------------------------------------

HLS协议文档

HTTP Live Streamingdraft-pantos-http-live-streaming
http://tools.ietf.org/html/draft-pantos-http-live-streaming-00
hls 是apple 开发的,主要是解决ios 视频播放问题。将文件切成很多小片来播放,为了 可以动态切换码流,并且播放不会占用很多资源。

切片属于内存的索引文件映射,实际物理视频文件是完整的一个。

多码率可以理解为索引文件对特定时间点的多个码率文件access位置的记录。

ios对单次下载的视频文件最大大小进行了限制,如果单个mp4文件大小超出,可能面临无法播放的问题。所以必须走hls才能保证正常播放。

adobe 为了和hls 对抗 所以才有了 hds,并且有了fmp4 这种文件格式。

有两个工作:

1. a tool —— 生成索引

2. b tool —— 提供http的服务

一个开源项目
http://smoothstreaming.code-shop.com/trac
下载的有:

SET ver=1.4.24
wget http://smoothstreaming.code-shop.com/download/apache_mod_smooth_streaming-%ver%.tar.gz wget http://smoothstreaming.code-shop.com/download/nginx_mod_smooth_streaming-%ver%.tar.gz wget http://smoothstreaming.code-shop.com/download/ffmpeg_ism-%ver%.tar.gz wget http://smoothstreaming.code-shop.com/download/mp4split-%ver%.tar.gz[/code] 
adobe 官方的dev media server 有链接数限制
http://sourceforge.net/apps/mediawiki/osmf.adobe/index.php?title=Customizing_HTTP_Dynamic_Streaming http://sourceforge.net/apps/mediawiki/osmf.adobe/index.php?title=Dynamic_Streaming http://sourceforge.net/apps/mediawiki/osmf.adobe/index.php?title=Flash_Media_Manifest_%28F4M%29_File_Format http://osmf.org http://sourceforge.net/apps/mediawiki/osmf.adobe/index.php?title=Main_Page

Converting H.264 MPEG4 to TS with ffmpeg

http://www.shortword.net/blog/2009/12/18/converting-h-264-mpeg4-to-ts-with-ffmpeg/

Where in the mp4 file structure is the duration of it?

http://stackoverflow.com/questions/3057157/anyone-familiar-with-mp4-data-structure

FFMPEG API

http://ffmpeg.org/documentation.html
http://wiki.aasimon.org/doku.php?id=ffmpeg:ffmpeg#ffmpeg_api_documentation

An ffmpeg and SDL Tutorial

or

How to Write a Video Player in Less Than 1000 Lines

http://dranger.com/ffmpeg/
http://stackoverflow.com/search?page=2&tab=relevance&q=libavformat%20split%20mp4 http://stackoverflow.com/questions/3663797/mp4-container-writer-in-java

HLS vs. HDS – What Is the Difference and Why You Should Care

http://www.overdigital.com/2011/12/27/hls-vs-hds-what-is-the-difference-and-why-you-should-care/

How to seek in FFmpeg C/C++

http://stackoverflow.com/questions/5261658/how-to-seek-in-ffmpeg-c-c

bool seekMs(int tsms)
{
//printf("**** SEEK TO ms %d. LLT: %d. LT: %d. LLF: %d. LF: %d. LastFrameOk: %d\n",tsms,LastLastFrameTime,LastFrameTime,LastLastFrameNumber,LastFrameNumber,(int)LastFrameOk);

// Convert time into frame number
DesiredFrameNumber = ffmpeg::av_rescale(tsms,pFormatCtx->streams[videoStream]->time_base.den,pFormatCtx->streams[videoStream]->time_base.num);
DesiredFrameNumber/=1000;

return seekFrame(DesiredFrameNumber);
}

bool seekFrame(ffmpeg::int64_t frame)
{

//printf("**** seekFrame to %d. LLT: %d. LT: %d. LLF: %d. LF: %d. LastFrameOk: %d\n",(int)frame,LastLastFrameTime,LastFrameTime,LastLastFrameNumber,LastFrameNumber,(int)LastFrameOk);

// Seek if:
// - we don't know where we are (Ok=false)
// - we know where we are but:
//    - the desired frame is after the last decoded frame (this could be optimized: if the distance is small, calling decodeSeekFrame may be faster than seeking from the last key frame)
//    - the desired frame is smaller or equal than the previous to the last decoded frame. Equal because if frame==LastLastFrameNumber we don't want the LastFrame, but the one before->we need to seek there
if( (LastFrameOk==false) || ((LastFrameOk==true) && (frame<=LastLastFrameNumber || frame>LastFrameNumber) ) )
{
//printf("\t avformat_seek_file\n");
if(ffmpeg::avformat_seek_file(pFormatCtx,videoStream,0,frame,frame,AVSEEK_FLAG_FRAME)<0)
return false;

avcodec_flush_buffers(pCodecCtx);

DesiredFrameNumber = frame;
LastFrameOk=false;
}
//printf("\t decodeSeekFrame\n");

return decodeSeekFrame(frame);

return true;
}


html content type for HLS:

//mimetype.assign = ( ".m3u8" => "application/x-mpegURL", ".ts" => "video/MP2T" )

@see
http://stackoverflow.com/questions/3209243/iphone-http-streaming-m3u8-and-ts-files-how-to-create-using-ffmpeg
切分音频的帖子
http://ffmpeg.arrozcru.org/forum/viewtopic.php?f=8&t=1259
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: