エントリー

ubuntu用segmenterの作成

参考:

https://github.com/carsonmcdonald/HTTP-Live-Video-Stream-Segmenter-and-Distributor/wiki/Install-on-Ubuntu-10.10

(追加:こちらが最適)
http://blog.kyri0s.org/post/1406637341/free-live-video-streaming-with-http-live-streaming

(追記:2012.10.10)
segmenter(http://svn.assembla.com/svn/legend/segmenter/ から取得、バージョン?)について
・ffmpegのモジュールを利用していて最新のffmpegではインタフェースの相違がある
・旧ffmpeg(2009-12-02)のモジュールを使用することによりmakeは可能
・makeできてもffmpeg以外のライブラリとの整合性もあるのか結果動作不安定

よって最新のffmpegのインタフェースに合わせるよう修正してみる

●OS: Ubuntu 10.04.4 LTS

●ffmpeg: version N-45221-g25f44b0
(以下作成)
参考:https://wiki.ubuntulinux.jp/UbuntuTips/Application/HowToInstallAndUseLatestFFmpegAndX264


ffmpeg version N-45221-g25f44b0 Copyright (c) 2000-2012 the FFmpeg developers
built on Oct 10 2012 17:10:42 with gcc 4.4.3 (Ubuntu 4.4.3-4ubuntu5.1)
configuration: --enable-gpl --enable-version3 --enable-nonfree --enable-postproc --enable-libfaac --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libtheora --enable-libvorbis --enable-libx264 --enable-libxvid --enable-x11grab --enable-libmp3lame --enable-libvpx
libavutil 51. 74.100 / 51. 74.100
libavcodec 54. 65.100 / 54. 65.100
libavformat 54. 31.100 / 54. 31.100
libavdevice 54. 3.100 / 54. 3.100
libavfilter 3. 19.102 / 3. 19.102
libswscale 2. 1.101 / 2. 1.101
libswresample 0. 16.100 / 0. 16.100
libpostproc 52. 1.100 / 52. 1.100
Hyper fast Audio and Video encoder
usage: ffmpeg [options] [[infile options] -i infile]... {[outfile options] outfile}...

Use -h to get full help or, even better, run 'man ffmpeg'

●segmenter: http://svn.assembla.com/svn/legend/segmenter/
(変更箇所)


28c28
< output_stream = av_new_stream(output_format_context, 0);
---
> output_stream = avformat_new_stream(output_format_context, 0);
53c53
< case CODEC_TYPE_AUDIO:
---
> case AVMEDIA_TYPE_AUDIO:
65c65
< case CODEC_TYPE_VIDEO:
---
> case AVMEDIA_TYPE_VIDEO:
231c231
< ret = av_open_input_file(&ic, input, ifmt, 0, NULL);
---
> ret = avformat_open_input(&ic, input, ifmt, NULL);
237c237
< if (av_find_stream_info(ic) < 0) {
---
> if (avformat_find_stream_info(ic, NULL) < 0) {
242c242
< ofmt = guess_format("mpegts", NULL, NULL);
---
> ofmt = av_guess_format("mpegts", NULL, NULL);
260c260
< case CODEC_TYPE_VIDEO:
---
> case AVMEDIA_TYPE_VIDEO:
265c265
< case CODEC_TYPE_AUDIO:
---
> case AVMEDIA_TYPE_AUDIO:
276,279c276,279
< if (av_set_parameters(oc, NULL) < 0) {
< fprintf(stderr, "Invalid output format parameters ");
< exit(1);
< }
---
> // if (av_set_parameters(oc, NULL) < 0) {
> // fprintf(stderr, "Invalid output format parameters ");
> // exit(1);
> // }
281c281
< dump_format(oc, 0, output_prefix, 1);
---
> av_dump_format(oc, 0, output_prefix, 1);
288c288
< if (avcodec_open(video_st->codec, codec) < 0) {
---
> if (avcodec_open2(video_st->codec, codec, NULL) < 0) {
293c293
< if (url_fopen(&oc->pb, output_filename, URL_WRONLY) < 0) {
---
> if (avio_open(&oc->pb, output_filename, AVIO_FLAG_WRITE) < 0) {
298c298
< if (av_write_header(oc)) {
---
> if (avformat_write_header(oc, NULL)) {
320c320
< if (packet.stream_index == video_index && (packet.flags & PKT_FLAG_KEY)) {
---
> if (packet.stream_index == video_index && (packet.flags & AV_PKT_FLAG_KEY)) {
331,332c331,332
< put_flush_packet(oc->pb);
< url_fclose(oc->pb);
---
> avio_flush(oc->pb);
> avio_close(oc->pb);
352c352
< if (url_fopen(&oc->pb, output_filename, URL_WRONLY) < 0) {
---
> if (avio_open(&oc->pb, output_filename, AVIO_FLAG_WRITE) < 0) {
382c382
< url_fclose(oc->pb);
---
> avio_close(oc->pb);

(makefile:ldは基本的にffmpegに合わせればよい)


all: segmenter
gcc -Wall -g segmenter.c -o segmenter
-I/usr/local/inlcude -L/usr/local/lib
-lavformat -lavcodec -lavutil
-lfaac -lmp3lame -lx264 -lvpx
-lxvidcore -lvorbisenc -ltheoraenc -ltheoradec
-lopencore-amrwb -lopencore-amrnb
-lm -lbz2 -lz

clean:
rm segmenter

install: segmenter
cp segmenter /usr/local/bin/

uninstall:
rm /usr/local/bin/segmenter

●動作確認
・完全な検証が困難なんでx86版での結果とサイズを比べてみたら問題なさそう
・vlcで再生できたし、なんとか動作しているように思える
・tsファイルの分割は一時的な物なので視聴できているので一応OK

(更に追記:2012.10.10)
M3U8 segmenter is an Apple HTTP Live Segmenter というのを発見
http://m3u8-segmenter.inodes.org/

ソースを取ってきて最新ffmpegでmakeしてみた
異常?メッセージが出ているが正常に終了しているようだ

尚、オプションスイッチが変更されているので利用時は注意


Usage: m3u8-sementer [OPTION]...

HTTP Live Streaming - Segments TS file and creates M3U8 index.
-i, --input FILE TS file to segment (Use - for stdin)
-d, --duration SECONDS Duration of each segment (default: 10 seconds)
-p, --output-prefix PREFIX Prefix for the TS segments, will be appended
with -1.ts, -2.ts etc
-m, --m3u8-file FILE M3U8 output filename
-u, --url-prefix PREFIX Prefix for web address of segments, e.g. http://example.org/video/
-n, --num-segment NUMBER Number of segments to keep on disk
-h, --help This help

こちらのほうが安心して使えるかな?

とりあえず、終了

ページ移動

コメント

  • コメントはまだありません。

コメント登録

  • コメントを入力してください。
登録フォーム
名前
メールアドレス
URL
コメント
閲覧制限
投稿キー(スパム対策に、投稿キー を半角で入力してください。)

ユーティリティ

検索

エントリー検索フォーム
キーワード

新着コメント

過去ログ

Feed