Chinaunix首页 | 论坛 | 博客
  • 博客访问: 2691731
  • 博文数量: 505
  • 博客积分: 1552
  • 博客等级: 上尉
  • 技术积分: 2514
  • 用 户 组: 普通用户
  • 注册时间: 2007-09-23 18:24
文章分类

全部博文(505)

文章存档

2019年(12)

2018年(15)

2017年(1)

2016年(17)

2015年(14)

2014年(93)

2013年(233)

2012年(108)

2011年(1)

2009年(11)

分类: LINUX

2013-03-06 09:12:13

用Live555 中的openRTSP 保存H264文件很简单

但是发现器保存的h264文件并不能直接被vcl 播放

 

同一个rtsp源 用vcl保存的h264文件就可以直接被播放

 

经过研究 发现是 openRTSP没有把SDP 中已经包括的SPS &PPS数据保存到文件中

 

vcl保存的h264文件的前2个00 00 00 01 数据 也就是 SPS &PPS 复制到 openRTSP保存的文件最前头就可以播放了

 

 

修改方法:

  1. else if (strcmp(subsession->mediumName(), "video") == 0 &&  
  2.     (strcmp(subsession->codecName(), "H264") == 0)) {  
  3.   // For H.264 video stream, we use a special sink that insert start_codes:  
  4.   unsigned int num=0;  
  5.   SPropRecord * sps=parseSPropParameterSets(subsession->fmtp_spropparametersets(),num);  
  6.   fileSink = H264VideoFileSink::createNew(*env, outFileName,  
  7.                      fileSinkBufferSize, oneFilePerFrame);  
  8.   struct timeval tv={0,0};  
  9.   unsigned char start_code[4] = {0x00, 0x00, 0x00, 0x01};  
  10.   fileSink-> addData(start_code, 4, tv);  
  11.   fileSink->addData(sps[0].sPropBytes,sps[0].sPropLength,tv);  
  12.   fileSink-> addData(start_code, 4, tv);  
  13.   fileSink->addData(sps[1].sPropBytes,sps[1].sPropLength,tv);  
  14.   delete[] sps;  
  15. else {  
阅读(2910) | 评论(2) | 转发(1) |
给主人留下些什么吧!~~

zvi_yam2013-04-11 14:22:35

也就是说,H264VideoFileSink 类已经做了这件事情了。

zvi_yam2013-04-11 14:20:16

朋友,貌似不对呀。你看看 live/liveMedia/H264VideoFileSink.cpp 这个文件的 line:65 ~75,

  if (!fHaveWrittenFirstFrame) {
    // If we have PPS/SPS NAL units encoded in a "sprop parameter string", prepend these to the file:
    unsigned numSPropRecords;
    SPropRecord* sPropRecords