Darwin Streamer是Apple的開源RTSP伺服器,採用APSL(Apple Public Source License)許可協議,可在免費商業使用。
1.下載安裝
最新的6.0.3版本只提供源碼和mac os上的二進位檔案,在windows上用vs無法編譯通過。所以使用5.5.5版本 DarwinStreamingSrvr5.5.5-Windows.exe http://static.macosforge.org/dss/downloads/DarwinStreamingSrvr5.5.5-Windows.exe 解壓下載的檔案, 執行目錄中的install.bat進行安裝,安裝過程中會提供輸入管理使用者名和密碼,也可以在安裝完成後再設定。 還需要安裝perl解析器, 下載:http://downloads.activestate.com/ActivePerl/releases/5.14.2.1402/ActivePerl-5.14.2.1402-MSWin32-x86-295342.msi 2.管理配置開啟cmd設定管理使用者名及密碼:
C:\Program Files\Darwin Streaming Server>perl WinPasswdAssistant.plDarwin Streaming Server SetupIn order to administer the Darwin Streaming Server you must create an administrator user [Note: The adminPlease enter a new administrator user name: gavinYou must also enter a password for the administrator user [Note: The administrator password cannot contaiPlease enter a new administrator Password: 123456Re-enter the new administrator password: 123456Setup Complete!
啟動用於管理伺服器的web伺服器C:\Program Files\Darwin Streaming Server>perl streamingadminserver.pl現在在瀏覽器中輸入http://127.0.0.1:1220/,登入管理介面,遠程登入時需要驗證帳戶在管理介面中,General Settings版面設定視頻檔案存放目錄,預設為C:\Program Files\Darwin Streaming Server\Movies使用ffplay測試一下內建的樣本 ffplay rtsp://192.168.9.80/sample_300kbit.mp43.MP4檔案的流化測試發現,只能播放darwin內建的樣本檔案,自己找的*.mp4檔案都不能播放。google發現,需要對MP4檔案hint。關於hint,有一段英文解釋:
Hint tracks are a series of instructions in a mp4 container file that tell a server how to transmit packets. Hint tracks always refer to another track, most likely an audio or video media track. This series of instructions tells the server when to send the packet, what type of RTP header to add, if there is any extra data in the packet, and how much data to send in the packet. To save on space, a hint can contain a pointer to the media track, instead of duplicating that data. It will also tell what SDP to add for the track that is referenced. So a file that is hinted should have a media track, and an associated hint track for that media track. There are some mp4 container files that just have hint tracks - these are called "fat hints" and are usually not playable locally. These are illegal in ISMA, so we won 't talk about them.
大致的意思是,hint是mp4檔案中的軌道,包含了RTP傳輸所使用的資訊,其實就是建立一個索引。網上都說用mp4box可以對mp4檔案進行流化操作, http://www.videohelp.com/tools/mp4box。mp4box的功能非常多,支援3gp、mp4、avi、mp3等多種檔案格式的轉換及其它操作,不過它沒有轉碼能力,詳細使用參考http://gpac.wp.institut-telecom.fr/mp4box/mp4box-documentation/。不過最後悲劇的發現,出錯了:
F:\Video>mp4box -hint 3.mp4Hinting file with Path-MTU 1450 BytesCannot create hinter (Feature Not Supported) Error: Feature Not Supported
又找了一個名為mp4creator的工具,http://mp4creator.sourceforge.net/download/index.htm
F:\Video>mp4creator -list Gucci.mp4Track Type Info1 video H264 Baseline@3, 24.920 secs, 2407 kbps, 800x608 @ 25.000000 fps2 audio MPEG-4 AAC LC, 24.938 secs, 126 kbps, 44100 HzF:\Video>mp4creator -hint Gucci.mp4MP4ERROR: FindTrackIndex: Track id 0 doesn't existmp4creator: couldn't create hint track, no media samples出錯了!!!試試對單個軌道進行hintF:\Video>mp4creator -hint=1 Gucci.mp4MP4ERROR: MP4File::FindIntegerProperty: no such property - moov.trak[0].mdia.minf.stbl.stsd.*.esds.decConfigDescr.objectTypeIdMP4ERROR: MP4File::FindIntegerProperty: no such property - moov.trak[2].mdia.minf.stbl.stsd.*.esds.decConfigDescr.objectTypeIdF:\Video>mp4creator -list Gucci.mp4Track Type Info1 video H264 Baseline@3, 24.920 secs, 2407 kbps, 800x608 @ 25.000000 fps2 audio MPEG-4 AAC LC, 24.938 secs, 126 kbps, 44100 Hz3 hint Payload H264 for track 1雖然hint過程中,有錯誤提示但還是成功添加了hint軌道F:\Video>mp4creator -hint=2 Gucci.mp4MP4ERROR: MP4File::FindIntegerProperty: no such property - moov.trak[0].mdia.minf.stbl.stsd.*.esds.decConfigDescr.objectTypeIdMP4ERROR: MP4File::FindIntegerProperty: no such property - moov.trak[2].mdia.minf.stbl.stsd.*.esds.decConfigDescr.objectTypeIdMP4ERROR: MP4File::FindIntegerProperty: no such property - moov.trak[3].mdia.minf.stbl.stsd.*.esds.decConfigDescr.objectTypeIdF:\Video>mp4creator -list Gucci.mp4Track Type Info1 video H264 Baseline@3, 24.920 secs, 2407 kbps, 800x608 @ 25.000000 fps2 audio MPEG-4 AAC LC, 24.938 secs, 126 kbps, 44100 Hz3 hint Payload H264 for track 14 hint Payload mpeg4-generic for track 2
對音視頻軌道單獨進行hint才能成功,提示的錯誤暫時不明白是什麼原因,不過用vlc2.0測試過,轉換後的視頻能正常播放。但是用ffplay和mplay播放時,均存在問題。mp4creator還有許多功能,內建的usage資訊如下:F:\Video>mp4creator
usage: mp4creator <options> <mp4-file>
Options:
-aac-old-file-format Use old file format with 58 bit adts headers
-aac-profile=[2|4] Force AAC to mpeg2 or mpeg4 profile
-allow-avi-files Allow avi files
-calcH263Bitrates Calculate and add bitrate information
-create=<input-file> Create track from <input-file>
input files can be of type: .263 .aac .ac3 .amr .mp3 .divx .mp4v .m4v .cmp .xvid .chap
-encrypt[=<track-id>] Encrypt a track, also -E
-extract=<track-id> Extract a track
-delete=<track-id> Delete a track
-force3GPCompliance Force making the file 3GP compliant. This disables ISMA compliance.
-forceH263Profile=<profile> Force using H.263 Profile <profile> (default is 0)
-forceH263Level=<level> Force using H.263 level <level> (default is 10)
-H263CbrTolerance=<value> Define H.263 CBR tolerance of [value] (default: 10%)
-hint[=<track-id>] Create hint track, also -H
-interleave Use interleaved audio payload format, also -I
-list List tracks in mp4 file
-make-isma-10-compliant Insert bifs and od tracks required for some ISMA players (also -i)
-mpeg4-video-profile=<level> Mpeg4 video profile override
-mtu=<size> Maximum Payload size for RTP packets in hint track
-optimize Optimize mp4 file layout
-payload=<payload> Rtp payload type
(use 3119 or mpa-robust for mp3 rfc 3119 support)
-rate=<fps> Video frame rate, e.g. 30 or 29.97
-qth=<height> Set a new height for QuickTime display
-qtw=<width> Set a new width for QuickTime display
-timescale=<ticks> Time scale (ticks per second)
-use64bits Use for large files
-use64bitstime Use for 64 Bit times (not QT player compatible)
-variable-frame-rate Enable variable frame rate for mpeg4 video
-verbose[=[1-5]] Enable debug messages
-version Display version information