跳轉到內容

Puredyne/流媒體音訊和影片

來自華夏公益教科書

待辦事項

Liquid Soap

[編輯 | 編輯原始碼]

待辦事項

ffmpeg2theora

[編輯 | 編輯原始碼]

執行一次

mkfifo stream.ogv

然後要流式傳輸,執行這兩行

dvgrab - | ffmpeg2theora -f dv -x 352 -y 288 -v 7 -o stream.ogv - &
cat stream.ogv | oggfwd icecast.example.org 8000 password /stream.ogv

如果編碼速度比即時速度慢,並且你的 CPU 核心已滿載,請調整大小和質量(-v)以降低。如果你的 CPU 負載低於 50% 並且影片流暢但難看,請將它們提高。如果編碼跟不上即時速度,則你的流式傳輸會中斷。觀察 Shell 中的第二個計時器 - 它們都應該幾乎處於相同的值。

待辦事項

你可以線上流式傳輸你的影片:FreeJ 使用 Ogg/Theora 編解碼器進行編碼並廣播到 Icecast 伺服器。

在流式傳輸音訊通道時,你還需要執行一個 Jack 守護程序並將它連線到 FreeJ 輸出。

在流式傳輸期間,還可以即時儲存影片的本地副本。以下是一個指令碼示例

<syntaxhighlight lang="text"> // 音訊輸入透過 Jack 從執行的其他應用程式獲取

// 埠名稱 緩衝區大小 取樣率

audio = new AudioJack("alsaplayer", 2048, 44100);

// 酌情調整以下值,請參閱 Jack 文件


// 建立一個影片編碼器物件

// 值 1-100 影片質量 影片位元率 音訊質量 音訊位元率

encoder = new VideoEncoder(10, 64000, 0, 24000);

// 將音訊通道新增到編碼的影片中

encoder.add_audio(audio);


// 配置編碼器以透過 Icecast 伺服器流式傳輸

encoder.stream_host("giss.tv");

encoder.stream_port(8000);

encoder.stream_title("testing new freej");

encoder.stream_username("source");

encoder.stream_password("2t645");

encoder.stream_mountpoint("freej-test.ogg");

// 在執行的 FreeJ 引擎上註冊編碼器

register_encoder(encoder);

// 開始網路流式傳輸

encoder.start_stream();

// 將流式傳輸記錄到本地檔案

encoder.start_filesave('Video/freej-test.ogg');

</syntaxhighlight lang="text">

我們可以將上面的程式碼貼上到一個指令碼中,並使用 freej -j stream.js 執行它。

除了調整此指令碼以適應各種帳戶外,還可以將它作為更大型 FreeJ 指令碼的一部分來包含,以將多個源與文字和效果混合,甚至可以透過 MIDI、OSC 或操縱桿來控制它。

Gstreamer

[編輯 | 編輯原始碼]

用於僅聲音佇列 

gst-launch-0.10 alsasrc ! audio/x-raw-int,rate=44100,channels=2,depth=16 ! queue ! audioconvert ! vorbisenc quality=0.8 ! oggmux ! tee name=tt \
! queue ! filesink location=artsbirthday-day3-$datenum.ogg tt. ! queue ! shout2send ip=x.x.x.x port=8000 password=mypass mount=mount.ogg

用於火線影片 

gst-launch-0.10 videomixer name=mix ! ffmpegcolorspace ! video/x-raw-yuv ! queue ! theoraenc quality=32 name=venc \
  oggmux name=mux ! tee name=tt ! queue ! filesink location=streamfile.ogg \
  tt. ! queue ! shout2send mount=/stream.ogg port=8000 password=xxx ip=xxx \
  alsasrc ! queue ! audioconvert ! vorbisenc name=aenc aenc. ! mux. \
  venc. ! mux. \
  dv1394src do-timestamp=true typefind=true ! queue ! dvdemux ! dvdec ! queue ! videorate ! videoscale ! ffmpegcolorspace ! video/x-raw-yuv, width=352, height=288,framerate=15/1 ! videobox left=0 top=0 border-alpha=0 ! mix.

替代方法

gst-launch-0.10 v4l2src device=/dev/video0 ! video/x-raw-yuv,width=320,height=240 ! queue ! videorate ! video/x-raw-yuv,framerate=25/2 \ 
! videoscale ! video/x-raw-yuv,width=320,height=240 ! ffmpegcolorspace ! tee name=tscreen ! queue ! autovideosink tscreen. ! queue \
! theoraenc quality=16 ! queue ! oggmux name=mux osssrc device=/dev/dsp ! audio/x-raw-int,rate=22050,channels=1 ! queue ! audioconvert z \
! vorbisenc quality=0.2 ! queue ! mux. mux. ! queue ! shout2send ip=giss.tv port=8000 password=PASS mount=YOURMOUNTPOINT.ogg

流媒體社群和資源

[編輯 | 編輯原始碼]

GISS 是一個由志願者運營的非商業性網路,使用自由軟體建立,用於免費媒體。 http://giss.tv

華夏公益教科書