流媒体,本地视频切割

首先要下载streamingtools_beta173_signed.dmg并进行安装

然后再终端,进入要切割的文件的文件夹,输入mediafilesegmenter -f 要保存的文件名/要切割的文件名

切割完后--要保存的文件-里会有一大推文件其中.m3u8就是我们要加载的,把切割好的整个文件夹放到我们的本地服务器里然后可以用html的格式进行实时播放html格式为

<html>

    <head>

        <title>HTTP Live Streaming Example</title>

    </head>

    <body>

        <video src="http://127.0.0.1/stream/hls/prog_index.m3u8"

            width="300" height="300"  controls="controls" >

        </video>

    </body>

</html>

/stream/hls/是文件夹名字prog_index.m3u8是要播放的整个文件

我们在工程输入这么一行代码就行

- (void)viewDidLoad

{

    [super viewDidLoad];

    self.webView.scrollView.scrollEnabled = NO;

     NSString *htmlPath = [[NSBundle mainBundle] pathForResource:@"video" ofType:@"html"];

NSURL *bundleUrl = [NSURL fileURLWithPath:[[NSBundle mainBundle] bundlePath]];

    NSError *error = nil;

    

NSString *html = [[NSString alloc] initWithContentsOfFile:htmlPath encoding: NSUTF8StringEncoding error:&error];

       if (error == nil) {//数据加载没有错误情况下

        [self.webView loadHTMLString:html baseURL:bundleUrl];

    }

    

}

posted on 2014-12-14 15:56  潘柏信  阅读(289)  评论(0编辑  收藏  举报