⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 fenice-howto.html

📁 linuxUNIX下跑的一套服务端程序
💻 HTML
📖 第 1 页 / 共 3 页
字号:
    audio/video streams compatible with Fenice</h1>    <div style="margin-left: 2em">        <br>    </div>    <h1 id="47" name="47" class="book-h2">3.1. MP3 audio    streams</h1>    <div style="margin-left: 2em">        <p>The next command shows how to create MP3 files        compatible with Fenice.<br>        In this example the well-know mp3-encoder named lame        (<a href=        "http://lame.sourceforge.net/">http://lame.sourceforge.net</a>)        is used.<br></p>        <div class="codeblock">            <code>$ lame -b 128 --resample 44.1 output.mp3 &lt;            inputaudiofile</code>        </div>    </div>    <h1 id="48" name="48" class="book-h2">3.2. MPEG 1 and 2    elementary video streams</h1>    <div style="margin-left: 2em">        <p>The next commands shows how to create MPEG 1 and 2        elementary video streams compatible with Fenice.</p>        <p>The well-know mpeg-encoder named mpeg2enc (<a href=        "http://mjpeg.sourceforge.net/">http://mjpeg.sourceforge.net/</a>)        and the multimedia player MPlayer (<a href=        "http://mplayerhq.hu">http://mplayerhq.hu</a>) are used in        this example.<br></p>        <div class="codeblock">            <code>$ mplayer -noframedrop -vo yuv4mpeg<br>            $ cat stream.yuv | mpeg2enc -v 0 -a 2 -b 200 -f 0 -F 25            -R 2 -c -s -g -G 10 -o outfile.mpg</code>        </div>    </div>    <h1 id="55" name="55" class="book-h2">3.3. Automating the    creation of the streams: a script</h1>    <div style="margin-left: 2em">        <p>The following script can be used to split an MPEG-1 or        MPEG-2 system stream into an elementary video stream and an        audio stream.</p>        <p>MPlayer is used to split the system stream while        mpeg2enc and lame are used to encode the elementary        respectively.<br></p>        <div class="codeblock">            <code>#!/bin/bash<br>            #<br>            # mjpegtools-lame.sh 0.1<br>            # A demultiplexing and transcoding script for Fenice,            the Open Media Streaming Server<br>            #<br>            # Copyleft 2005 - Francesco Varano            &lt;francesco.varano_at_polito.it&gt;<br>            #<br>            # This script is free software; you can redistribute it            and/or modify<br>            # it under the terms of the GNU General Public License            as published by<br>            # the Free Software Foundation; either version 2 of the            License, or<br>            # (at your option) any later version.<br>            #<br>            # This script is distributed in the hope that it will            be useful,<br>            # but WITHOUT ANY WARRANTY; without even the implied            warranty of<br>            # MERCHANTABILITY or FITNESS FOR A PARTICULAR            PURPOSE.&nbsp;&nbsp;See the<br>            # GNU General Public License for more details.<br>            #<br>            # You should have received a copy of the GNU General            Public License<br>            # along with this script; if not, write to the Free            Software<br>            # Foundation, Inc., 59 Temple Place, Suite 330, Boston,            MA&nbsp;&nbsp;02111-1307&nbsp;&nbsp;USA<br>            # #<br>            #--&gt; encoding variables &lt;--#<br>            asr="44.1" # audio sample rate<br>            abitrate="128" # audio bitrate<br>            vbitrate="200" # video bitrate<br>            framerate=""<br>            aspect="2"<br>            if [ -n "$aspect" ]; then<br>            &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;aspect="-a            $aspect"<br>            fi<br>            if [ -n "$framerate" ]; then<br>            &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;framerate="-F            $framerate"<br>            fi<br>            if [ -n "$vbitrate" ]; then<br>            &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;vbitrate="-b            $vbitrate"<br>            fi<br>            #--&gt; variables &lt;--#<br>            AUDIO="audiodump.wav"<br>            VIDEO="stream.yuv"<br>            # MPLAYER_CMD="mplayer -noframedrop -vo yuv4mpeg            -nosound -v -osdlevel 0"<br>            MPLAYER_CMD="mplayer -noframedrop -vo yuv4mpeg -ao pcm            -waveheader -v -osdlevel 0"<br>            MPEG2ENC_CMD="mpeg2enc -v 0 $aspect $vbitrate -f 0            $framerate -R 2 -c -s -g 10 -G 10 -o"<br>            LAME_CMD="lame -b $abitrate --resample $asr"<br>            # DENOISE="cat -" # OR:<br>            DENOISE="yuvdenoise"<br>            if [ -z $1 ]; then<br>            &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;echo<br>            &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;echo            "$0: You must provide a filename..."<br>            &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;echo            "Exiting."<br>            &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;echo<br>            &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;exit            1<br>            fi<br>            infile=`basename $1`<br>            outfile=${infile%.*}<br>            i=0<br>            while [ -e $outfile.mpg ] || [ -e $outfile.mp3 ];            do<br>            &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;outfile=${infile%.*}_$i<br>            &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;let            i++<br>            done<br>            echo -ne "Outputting:\n\tVideo to $outfile.mpg\n\tAudio            to $outfile.mp3\n"<br>            rm -f $VIDEO<br>            mkfifo -m 660 $VIDEO<br>            echo "launching: $MPLAYER_CMD"<br>            $MPLAYER_CMD $1 &amp;<br>            $DENOISE &lt; $VIDEO | $MPEG2ENC_CMD $outfile.mpg<br>            wait<br>            $LAME_CMD - $outfile.mp3 &lt; $AUDIO<br>            rm -f $VIDEO<br>            rm -f $AUDIO<br>            echo -ne "Outputting:\n\tVideo to $outfile.mpg\n\tAudio            to $outfile.mp3\n"<br>            echo</code>        </div>    </div>    <h1 id="36" name="36" class="book-h1">4. How to create the SD    description</h1>    <div style="margin-left: 2em">        <br>    </div>    <h1 id="58" name="58" class="book-h2">4.1. Global SD Tags</h1>    <div style="margin-left: 2em">        <p>Global tags are referred to the whole session. Allowed        global tags are: <em>stream, stream_end, twin</em>;        <em>stream\stream_end</em> are the start\end-point of the        media description, while <em>twin</em> indicates the twin        resource used in redirect message (i.e.for load balancing        between two or more servers).</p>        <p>The general structure of a SD description is:<br></p>        <div class="codeblock">            <code>twin            rtsp://twin_server:rtsp_port/twin_resource.sd<br>            stream<br>            &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;insert here            the description (see te following pages)<br>            stream_end</code>        </div>    </div>    <h1 id="49" name="49" class="book-h2">4.2. MP3 audio    streams</h1>    <div style="margin-left: 2em">        <p>The follow text is an SD file audio.sd used to stream        the file audio.mp3:</p>        <div class="codeblock">            <code>stream<br>            &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;default_presentation<br>            &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;priority            1<br>            &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;file_name            audio.mp3<br>            &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;media_source            stored<br>            &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;payload_type            14<br>            &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;clock_rate            90000<br>            &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;audio_channels            2<br>            &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;encoding_name            MPA<br>            &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;sample_rate            44100<br>            &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;coding_type            frame<br>            &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;frame_len            26.12<br>            stream_end</code>        </div><br>        Now, if a client wants this resource it must use an url as        this: <tt>rtsp://server_ip_or_name:port/audio.sd</tt> where        port is the RTSP port set in <tt>fenice.conf</tt>.        <p>Note: you must store <tt>audio.mp3</tt> and        <tt>audio.sd</tt> into the root directory set in        <tt>fenice.conf</tt>.</p>    </div>    <h1 id="50" name="50" class="book-h2">4.3. MPEG 1 and 2    elementary video stream</h1>    <div style="margin-left: 2em">        <p>Otherwise the video.sd file to stream an elementary        video stream (MPEG1 or 2) is:<br></p>        <div class="codeblock">            <code>stream<br>            &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;file_name            video.mpg<br>            &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;priority            1<br>            &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;media_source            stored<br>            &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;payload_type            32<br>            &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;clock_rate            90000<br>            &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;encoding_name            MPV<br>            &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;coding_type            frame<br>            &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;frame_rate            25<br>            &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;byte_per_pckt            1900<br>            stream_end</code>        </div>    </div>    <h1 id="51" name="51" class="book-h2">4.4. MP3 audio + MPEG    videostreams</h1>    <div style="margin-left: 2em">        <p>If you want an audio/video stream (mp3/mpg):<br></p>        <div class="codeblock">            <code>stream<br>            &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;file_name            audio.mp3<br>            &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;aggregate            movie<br>            &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;priority            1<br>            &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;media_source            stored<br>            &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;payload_type

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -