顯示具有 多媒體 標籤的文章。 顯示所有文章
顯示具有 多媒體 標籤的文章。 顯示所有文章

2017年11月21日 星期二

[多媒體] mp4 to jpeg

最近很常把影片轉成圖檔
ffmpeg -i input.mp4 output_%03d.jpg

這還沒試過 QQ
ffmpeg -r 1/4 -i %03d.jpg -vcodec copy -qscale 1 copy.avi

2017年11月8日 星期三

2016年10月30日 星期日

[多媒體] 用Wireshark錄Vodeo Straming

使用 Wireshark 這神兵利器錄 Video Straming 真是太容易了, 我之前是用 follow stream 後再儲存, 後續還要再處理檔案標題頗麻煩

現在有找到更簡單的方法, 直接這樣做吧

File > Export > Objects > HTTP

將 streaming 的結果儲存下來就可以了

Reference: WIRESHARK – EXTRACT VIDEO FROM CAPTURE FILE

2016年6月18日 星期六

[Tips] 擷取framebuffer畫面

大部分嵌入式系統都會實做 framebuffer 的驅動程式介面, 如 /dev/fb0

因此要擷取畫面最簡單的方式就是
$ cat /dev/fb0 > fb.raw

再將畫面倒回去
$ sudo cp fb.raw /dev/fb0

但要注意幾點

1. framebuffer 是記憶體 raw data, 因此存檔的結果是一連串的16進位數值, 因此無法使用一般的看圖軟體開啟, 但可以透過 imagemagick 裡的 display 工具顯示(需指定顯示的解析度)
$ display -size 1024x768 rgb:fb.raw


2. 因此還原成一般的 jpg 或是 png 格式需指定 color-depth 和解析度
如果是 24-bit 可以使用 imagemagick 裡的 convert 工具
$ convert -depth 8 -size 640x480 rgb:fb.raw -channel RGB -separate -swap 0,2 -combine fb.png

如果是 16-bit, 可以使用 iraw2png 這支 perl 程式
#!/usr/bin/perl -w
 
$w = shift || 240;
$h = shift || 320;
$pixels = $w * $h;
 
open OUT, "|pnmtopng" or die "Can't pipe pnmtopng: $!\n";
 
printf OUT "P6%d %d\n255\n", $w, $h;
 
while ((read STDIN, $raw, 2) and $pixels--) {
   $short = unpack('S', $raw);
   print OUT pack("C3",
      ($short & 0xf800) >> 8,
      ($short & 0x7e0) >> 3,
      ($short & 0x1f) << 3);
}
 
close OUT;
執行 iraw2png 程式:
$ python iraw2png 640 480 fb.png

之後就可以用 gpicview 之類的軟體開啟 png 檔案了
$ gpicview fb.png

reference:
* Working with Frame Buffers
* How to do a framebuffer screenshot
* Convert raw BGRA framebuffer to RGB png file (有條件限制使用)

2015年11月4日 星期三

[多媒體] SDL教學

最近在看 SDL, 找到這篇還不錯
http://lazyfoo.net/tutorials/SDL/

2012年1月7日 星期六

[多媒體] Setup Video Streaming in Linux

VLC is a free and open source cross-platform multimedia player and framework that plays most multimedia files as well as DVD, Audio CD, VCD, and various streaming protocols.

environment:
* server: ubuntu 10.04 (192.168.104.131)
* client: ubuntu 10.04 (192.168.104.1)

1. launch VLC
server$ vlc

1.1 choose "Media" -> "Advanced Open File..."

1.2 in "File Selection", press "Add..." to choose your media file, then set "Stream"

1.3 check the path of media is correct and press "Next"

1.4 in "Destinations", choose "HTTP" and press "Add"

1.5 set HTTP output port as default "8080", path as default "/"

1.6 set Miscellaneous Options as default and press "Stream"


2. receive video streaming via SMPlayer
client$ smplayer

2.1 choose "Open" -> "URL..."

2.2 fill in URL with http://server:8080/

2.3 play



reference:
* 架設HTTP Streaming Servrer
* Live Streaming Using C

2011年7月5日 星期二

[多媒體] Setup Audio Streaming Service on Ubuntu (Icecast2+Ices2)

Due to a requirement of project, I tried to setup an audio streaming service before. I choose Icecast as my streaming server, and Ices2 to generates Ogg Vorbis sources for Icecast2 to stream. The details are as follows.

environment:
* server: ubuntu 10.04 (192.168.104.131)
* client: ubuntu 10.04 (192.168.104.1)

Icecast is free server software for streaming multimedia. Ices comes in two flavors, the 0.x flavor which supports sending an MP3 stream to an icecast server, and the 2.x flavor which supports sending an Ogg Vorbis stream to an icecast server. In summary, Icecast is a streaming server, and streamer, likes ices or darkice, providers streaming content.
Ices comes in two flavors, the 0.x flavor which supports sending an MP3 stream to an icecast server, and the 2.x flavor which supports sending an Ogg Vorbis stream to an icecast server.

1. Setup Icecast(2)
1.1 install required libraries
server$ sudo apt-get install icecast2
server$ sudo /etc/init.d/icecast2 start
icecast2 daemon disabled - read /etc/default/icecast2.

1.2 enable icecast2
server$ sudo vim /etc/default/icecast2
# Edit /etc/icecast2/icecast.xml and change at least the passwords.
# Change this to true when done to enable the init.d script
ENABLE=true

1.3 start icecast2
server$ sudo /etc/init.d/icecast2 start
Starting icecast2: Starting icecast2
Detaching from the console
icecast2.


2. Icecast2 + Ices2
2.1 install required libraries & setup environment
server$ sudo apt-get install ices2
server$ sudo mkdir /var/log/ices
server$ sudo mkdir -p /etc/ices2/music

2.2 modified default value (or not)
server$ sudo cp /usr/share/doc/ices2/examples/ices-playlist.xml /etc/ices2
server$ sudo vim /etc/ices2/ices-playlist.xml
<password>hackme</password>                         # modified me (or not)
<mount>/example1.ogg</mount>                        # modified me (or not)
<param name="file">/etc/ices2/playlist.txt</param>  # modified me

2.3 add playlist
server$ sudo cp /path/to/my_song_1.ogg /path/to/my_song_2.ogg /etc/ices2/music
server$ sudo ices2 /etc/ices2/ices-playlist.xml
server$ sudo vim /etc/ices2/playlist.txt
/etc/ices2/music/my_song_1.ogg
/etc/ices2/music/my_song_2.ogg

2.4 modified script of icecast2 to fit with ices
server$ sudo vim /etc/init.d/icecast2
#! /bin/sh
### BEGIN INIT INFO
# Provides:          icecast2
# Required-Start:    $remote_fs $network
# Required-Stop:     $remote_fs
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: Starts the icecast audio streaming server daemon
### END INIT INFO
#
# icecast2
#
#       Written by Miquel van Smoorenburg .
#       Modified for Debian 
#       by Ian Murdock .
#
#       Further modified by Keegan Quinn 
#       for use with Icecast 2
#

PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
DAEMON=/usr/bin/icecast2
NAME=icecast2
DESC=icecast2
ICES=/usr/bin/ices2                           # add this line
ICES_CONFIGFILE=/etc/ices2/ices-playlist.xml  # add this line

test -x $DAEMON || exit 0

# Defaults
CONFIGFILE="/etc/icecast2/icecast.xml"
CONFIGDEFAULTFILE="/etc/default/icecast2"
USERID=icecast2
GROUPID=icecast
ENABLE="false"

# Reads config file (will override defaults above)
[ -r "$CONFIGDEFAULTFILE" ] && . $CONFIGDEFAULTFILE

if [ "$ENABLE" != "true" ]; then
    echo "$NAME daemon disabled - read $CONFIGDEFAULTFILE."
    exit 0
fi

set -e

case "$1" in
    start)
        echo -n "Starting $DESC: "
        start-stop-daemon --start --quiet --chuid $USERID:$GROUPID \
            --exec $DAEMON -- -b -c $CONFIGFILE
        echo "$NAME."
        ;;
    stop)
        echo -n "Stopping $DESC: "
        # Send TERM after 5 seconds, wait at most 30 seconds.
        start-stop-daemon --stop --oknodo --retry TERM/5/0/30 --quiet --exec $DAEMON
        echo "$NAME."
        ;;
    reload|force-reload)
        echo "Reloading $DESC configuration files."
        start-stop-daemon --stop --signal 1 --quiet --exec $DAEMON
        ;;
    restart)
        echo -n "Restarting $DESC: "
        # Send TERM after 5 seconds, wait at most 30 seconds.
        start-stop-daemon --stop --oknodo --retry TERM/5/0/30 --quiet --exec $DAEMON
        start-stop-daemon --start --quiet --chuid $USERID:$GROUPID \
            --exec $DAEMON -- -b -c $CONFIGFILE
        echo "$NAME."
        ;;
    *)
        echo "Usage: $0 {start|stop|restart|reload|force-reload}" >&2
        exit 1
        ;;
esac

exit 0

2.5 start ices2
server$ sudo ices2 /etc/ices2/ices-playlist.xml

2.6 receive audio streaming via browser
client$ firefox -url http://192.168.104.131:8000/example1.ogg


reference:
* The Linux MP3 & Ogg HOWTO : Streaming Servers and Web Interfaces
* The Linux MP3-HOWTO : Streaming MP3's.
* Ogg Vorbis Streaming: ices2 HOWTO
* Run Your Own Webradio Station With Icecast2 And Ices2 (part1)
* Run Your Own Webradio Station With Icecast2 And Ices2 (part2)

If you want to choose Apache + Musicindex as your streaming server, there are some references helps
* Stream your music with musicindex
* README of musicindex
* HowTo stream mp3 ogg mp4 files with Apache2 libapache2 mod musicindex

2011年5月1日 星期日

[多媒體] VLC Multicast Streaming

最近在弄一些網路串流的東西,有時候會拿VLC先做測試
想用VLC收multicast的streaming,只要下
vlc udp://@server.ip:port

如果連不上,大概需要注意幾件事是否正確
1.IGMP的版本,通常需支援v2以上的版本才行
2.Reverse Path Filtering需要關閉
3.Routing需要設對

總而言之,寫了簡單的shell script幫助快速設定
#!/bin/bash
# force IMGP v2
echo 2 > /proc/sys/net/ipv4/conf/eth0/force_igmp_version

# set no reverse path lookup
echo 0 > /proc/sys/net/ipv4/conf/eth0/rp_filter

# set multicast route
route add -net 224.0.0.0 netmask 224.0.0.0 dev eth0

reference:
* UDP multicast playing and VLC
* [SOLVED] Multicast & mythtv tuning issues with kernel>2.6.30