microcreat

microcreat

0个粉丝

36

问答

0

专栏

0

资料

microcreat  发布于  2013-01-07 09:15:13
采纳率 0%
36个问答
12464

live555移植笔记三 ubuntu下保存接收的RTSP数据并保存

 

[i=s] 本帖最后由 microcreat 于 2013-1-7 09:21 编辑 [/i]

在有上面的2个例子在ubuntu下面的成功的例子后,虽然能够播放了,但是想保存数据文件怎办? 看了下代码,结果发现,只有加一个参数就可以讲数据保存为文件: 一,首先打开RTSP服务器: root@microcreat:/workdir/private/live/mediaServer# pwd /workdir/private/live/mediaServer root@microcreat:/workdir/private/live/mediaServer# ls COPYING in_demo.264 Makefile.head DynamicRTSPServer.cpp live555MediaServer Makefile.tail DynamicRTSPServer.hh live555MediaServer.cpp version.hh DynamicRTSPServer.o live555MediaServer.o in.264 Makefile

root@microcreat:/workdir/private/live/mediaServer# ./live555MediaServer LIVE555 Media Server version 0.75 (LIVE555 Streaming Media library version 2012.09.27). Play streams from this server using the URL rtsp://192.168.196.128/ where is a file present in the current directory. Each file's type is inferred from its name suffix: ".264" => a H.264 Video Elementary Stream file ".aac" => an AAC Audio (ADTS format) file ".ac3" => an AC-3 Audio file ".amr" => an AMR Audio file ".dv" => a DV Video file ".m4e" => a MPEG-4 Video Elementary Stream file ".mkv" => a Matroska audio+video+(optional)subtitles file ".mp3" => a MPEG-1 or 2 Audio file ".mpg" => a MPEG-1 or 2 Program Stream (audio+video) file ".ts" => a MPEG Transport Stream file (a ".tsx" index file - if present - provides server 'trick play' support) ".wav" => a WAV Audio file ".webm" => a WebM audio(Vorbis)+video(VP8) file See http://www.live555.com/mediaServer/for additional documentation. (We use port 80 for optional RTSP-over-HTTP tunneling, or for HTTP live streaming (for indexed Transport Stream files only).) 二,然后另外开一个终端: root@microcreat:/workdir/private/live/testProgs# pwd /workdir/private/live/testProgs root@microcreat:/workdir/private/live/testProgs# ls COPYING testMPEG1or2AudioVideoToDarwin.cpp in.264 testMPEG1or2AudioVideoToDarwin.o Makefile testMPEG1or2ProgramToTransportStream Makefile.head testMPEG1or2ProgramToTransportStream.cpp Makefile.tail testMPEG1or2ProgramToTransportStream.o microcreat-1-video-H264-1 testMPEG1or2Splitter microcreat-video-H264-1 testMPEG1or2Splitter.cpp MPEG2TransportStreamIndexer testMPEG1or2Splitter.o MPEG2TransportStreamIndexer.cpp testMPEG1or2VideoReceiver MPEG2TransportStreamIndexer.o testMPEG1or2VideoReceiver.cpp openRTSP testMPEG1or2VideoReceiver.o openRTSP.cpp testMPEG1or2Video.sdp openRTSP.o testMPEG1or2VideoStreamer out.ts testMPEG1or2VideoStreamer.cpp playCommon.cpp testMPEG1or2VideoStreamer.o playCommon.hh testMPEG2TransportReceiver playCommon.o testMPEG2TransportReceiver.cpp playSIP testMPEG2TransportReceiver.o playSIP.cpp testMPEG2Transport.sdp playSIP.o testMPEG2TransportStreamer sapWatch testMPEG2TransportStreamer.cpp sapWatch.cpp testMPEG2TransportStreamer.o sapWatch.o testMPEG2TransportStreamTrickPlay testAMRAudioStreamer testMPEG2TransportStreamTrickPlay.cpp testAMRAudioStreamer.cpp testMPEG2TransportStreamTrickPlay.o testAMRAudioStreamer.o testMPEG4VideoStreamer testDVVideoStreamer testMPEG4VideoStreamer.cpp testDVVideoStreamer.cpp testMPEG4VideoStreamer.o testDVVideoStreamer.o testMPEG4VideoToDarwin testGSMStreamer.cpp testMPEG4VideoToDarwin.cpp testH264VideoStreamer testMPEG4VideoToDarwin.o testH264VideoStreamer.cpp testOnDemandRTSPServer testH264VideoStreamer.o testOnDemandRTSPServer.cpp testH264VideoToTransportStream testOnDemandRTSPServer.o testH264VideoToTransportStream.cpp testRelay testH264VideoToTransportStream.o testRelay.cpp testMP3Receiver testRelay.o testMP3Receiver.cpp testReplicator testMP3Receiver.o testReplicator.cpp testMP3.sdp testReplicator.o testMP3Streamer testRTSPClient testMP3Streamer.cpp testRTSPClient.cpp testMP3Streamer.o testRTSPClient.o testMP3-using-ADUs.sdp testWAVAudioStreamer testMPEG1or2AudioVideo.sdp testWAVAudioStreamer.cpp testMPEG1or2AudioVideoStreamer testWAVAudioStreamer.o testMPEG1or2AudioVideoStreamer.cpp vobStreamer testMPEG1or2AudioVideoStreamer.o vobStreamer.cpp testMPEG1or2AudioVideoToDarwin vobStreamer.o root@microcreat:/workdir/private/live/testProgs# ./openRTSP -F microcreat- rtsp://192.168.196.128/in.264 microcreat debug Opening connection to 192.168.196.128, port 554... ...remote connection opened Sending request: OPTIONS rtsp://192.168.196.128/in.264RTSP/1.0 CSeq: 2 User-Agent: ./openRTSP (LIVE555 Streaming Media v2012.09.27)

Received 152 new bytes of response data. Received a complete OPTIONS response: RTSP/1.0 200 OK CSeq: 2 Date: Mon, Jan 07 2013 01:12:21 GMT Public: OPTIONS, DESCRIBE, SETUP, TEARDOWN, PLAY, PAUSE, GET_PARAMETER, SET_PARAMETER

Sending request: DESCRIBE rtsp://192.168.196.128/in.264 RTSP/1.0 CSeq: 3 User-Agent: ./openRTSP (LIVE555 Streaming Media v2012.09.27) Accept: application/sdp

Received 658 new bytes of response data. Received a complete DESCRIBE response: RTSP/1.0 200 OK CSeq: 3 Date: Mon, Jan 07 2013 01:12:21 GMT Content-Base: rtsp://192.168.196.128/in.264/ Content-Type: application/sdp Content-Length: 495

v=0 o=- 1357521141391924 1 IN IP4 192.168.196.128 s=H.264 Video, streamed by the LIVE555 Media Server i=in.264 t=0 0 a=tool:LIVE555 Streaming Media v2012.09.27 a=type:broadcast a=control:* a=range:npt=0- a=x-qt-text-nam:H.264 Video, streamed by the LIVE555 Media Server a=x-qt-text-inf:in.264 m=video 0 RTP/AVP 96 c=IN IP4 0.0.0.0 b=AS:500 a=rtpmap:96 H264/90000 a=fmtp:96 packetization-mode=1;profile-level-id=42001E;sprop-parameter-sets=Z0IAHpWoLQSZ,aFOPIA== a=control:track1

Opened URL "rtsp://192.168.196.128/in.264", returning a SDP description: v=0 o=- 1357521141391924 1 IN IP4 192.168.196.128 s=H.264 Video, streamed by the LIVE555 Media Server i=in.264 t=0 0 a=tool:LIVE555 Streaming Media v2012.09.27 a=type:broadcast a=control:* a=range:npt=0- a=x-qt-text-nam:H.264 Video, streamed by the LIVE555 Media Server a=x-qt-text-inf:in.264 m=video 0 RTP/AVP 96 c=IN IP4 0.0.0.0 b=AS:500 a=rtpmap:96 H264/90000 a=fmtp:96 packetization-mode=1;profile-level-id=42001E;sprop-parameter-sets=Z0IAHpWoLQSZ,aFOPIA== a=control:track1

Created receiver for "video/H264" subsession (client ports 42010-42011) Sending request: SETUP rtsp://192.168.196.128/in.264/track1RTSP/1.0 CSeq: 4 User-Agent: ./openRTSP (LIVE555 Streaming Media v2012.09.27) Transport: RTP/AVP;unicast;client_port=42010-42011

Received 209 new bytes of response data. Received a complete SETUP response: RTSP/1.0 200 OK CSeq: 4 Date: Mon, Jan 07 2013 01:12:21 GMT Transport: RTP/AVP;unicast;destination=192.168.196.128;source=192.168.196.128;client_port=42010-42011;server_port=6970-6971 Session: 60BFBE6B

Setup "video/H264" subsession (client ports 42010-42011) Created output file: "microcreat-video-H264-1" Sending request: PLAY rtsp://192.168.196.128/in.264/RTSP/1.0 CSeq: 5 User-Agent: ./openRTSP (LIVE555 Streaming Media v2012.09.27) Session: 60BFBE6B Range: npt=0.000-

Received 184 new bytes of response data. Received a complete PLAY response: RTSP/1.0 200 OK CSeq: 5 Date: Mon, Jan 07 2013 01:12:21 GMT Range: npt=0.000- Session: 60BFBE6B RTP-Info: =rtsp://192.168.196.128/in.264/track1;seq=45374;rtptime=2776738273

Started playing session Receiving streamed data (signal with "kill -HUP 2050" or "kill -USR1 2050" to terminate)... Received RTCP "BYE" on "video/H264" subsession (after 9 seconds) Sending request: TEARDOWN rtsp://192.168.196.128/in.264/RTSP/1.0 CSeq: 6 User-Agent: ./openRTSP (LIVE555 Streaming Media v2012.09.27) Session: 60BFBE6B

Received 65 new bytes of response data. Received a complete TEARDOWN response: RTSP/1.0 200 OK CSeq: 6 Date: Mon, Jan 07 2013 01:12:30 GMT

root@microcreat:/workdir/private/live/testProgs# ls microcreat* -l -rw-r--r-- 1 root root 2389166 2013-01-07 09:12 microcreat-video-H264-1 这样就可以看到生成的文件了。 三,用mplayer验证此文件是否能够播放: root@microcreat:/workdir/private/live/testProgs# mplayer microcreat-video-H264-1

OK,可以正常播放!

说明: 可能会有疑问,为什么文件名是这样的呢? 跟踪代码就可以看到这个问题: 打开: vim playCommon.cpp

............................. // Create an output file for each desired stream: char outFileName[1000]; if (singleMedium == NULL) { // Output file name is // "--" static unsigned streamCounter = 0; snprintf(outFileName, sizeof outFileName, "%s%s-%s-%d", fileNamePrefix, subsession->mediumName(), subsession->codecName(), ++streamCounter); } else { sprintf(outFileName, "stdout"); } .............................

可以看到最后的文件名由几部分组成: filename-prefix medium_name codec_name counter microcreat video H264 1 其实执行这个demo程序,会自动保存为一个默认的名字,实际上已经源码已经做了这个方面的处理了!

我来回答
回答3个
时间排序
认可量排序

microcreat

0个粉丝

36

问答

0

专栏

0

资料

microcreat 2014-01-01 11:43:11
认可0
哈哈,想不到我的帖子变亮了!

ebaina_

0个粉丝

82

问答

40

专栏

0

资料

ebaina_ 2014-01-03 13:06:46
认可0
[quote][url=forum.php?mod=redirect&goto=findpost&pid=5826&ptid=1623]microcreat 发表于 2014-1-1 11:43[/url]
哈哈,想不到我的帖子变亮了![/quote]

必须得亮起来。

呆呆

0个粉丝

0

问答

0

专栏

0

资料

呆呆 2016-08-10 01:08:41
认可0
live555是啥?
或将文件直接拖到这里
悬赏:
E币
网盘
* 网盘链接:
* 提取码:
悬赏:
E币

Markdown 语法

  • 加粗**内容**
  • 斜体*内容*
  • 删除线~~内容~~
  • 引用> 引用内容
  • 代码`代码`
  • 代码块```编程语言↵代码```
  • 链接[链接标题](url)
  • 无序列表- 内容
  • 有序列表1. 内容
  • 缩进内容
  • 图片![alt](url)
+ 添加网盘链接/附件

Markdown 语法

  • 加粗**内容**
  • 斜体*内容*
  • 删除线~~内容~~
  • 引用> 引用内容
  • 代码`代码`
  • 代码块```编程语言↵代码```
  • 链接[链接标题](url)
  • 无序列表- 内容
  • 有序列表1. 内容
  • 缩进内容
  • 图片![alt](url)
举报反馈

举报类型

  • 内容涉黄/赌/毒
  • 内容侵权/抄袭
  • 政治相关
  • 涉嫌广告
  • 侮辱谩骂
  • 其他

详细说明

易百纳技术社区