WD MBL 분류

WD My Book Live에서 MMS프로토콜 라디오 녹음하기

컨텐츠 정보

본문

1. 라디오가 저장 될 폴더 생성


임의로 radio라는 폴더로 admin만 접근 가능하게 생성하였습니다.





이후 과정은 마이 클라우드의 그것과 거의 똑같습니다.


패키지 몇개만 설치하는 거구요 ㅎㅎ




2. 관련 필수 패키지를 설치합니다.



apt-get install rtmpdump libav-tools ffmpeg


MyBookLive:~# apt-get install rtmpdump libav-tools ffmpeg

Reading package lists... Done

Building dependency tree

Reading state information... Done

rtmpdump is already the newest version.

libav-tools is already the newest version.

ffmpeg is already the newest version.

0 upgraded, 0 newly installed, 0 to remove and 302 not upgraded.

MyBookLive:~# 



이미 설치가 되어있다면 위와 같이 뜰 것입니다.




3. mimms 및 python 패키지 설치



apt-get install mimms


위 명령어로 mimms 패키지를 설치합니다.



MyBookLive:~# apt-get install mimms

Reading package lists... Done

Building dependency tree

Reading state information... Done

The following extra packages will be installed:

  libmms0 python-support

The following NEW packages will be installed:

  libmms0 mimms python-support

0 upgraded, 3 newly installed, 0 to remove and 302 not upgraded.

Need to get 86.0kB of archives.

After this operation, 302kB of additional disk space will be used.

Do you want to continue [Y/n]? y

Get:1 http://ftp.us.debian.org wheezy/main libmms0 0.6.2-3 [41.6kB]

Get:2 http://ftp.us.debian.org wheezy/main python-support 1.0.15 [33.6kB]

Get:3 http://ftp.us.debian.org wheezy/main mimms 3.2.2-1 [10.7kB]

Fetched 86.0kB in 4s (17.4kB/s)

Selecting previously deselected package libmms0.

(Reading database ...

dpkg: warning: files list file for package `ramlog' missing, assuming 


package has no files currently installed.


dpkg: warning: files list file for package `libparted0' missing, assuming 


package has no files currently installed.

(Reading database ... 18967 files and directories currently installed.)

Unpacking libmms0 (from .../libmms0_0.6.2-3_powerpc.deb) ...

Selecting previously deselected package python-support.

Unpacking python-support (from .../python-support_1.0.15_all.deb) ...

Selecting previously deselected package mimms.

Unpacking mimms (from .../archives/mimms_3.2.2-1_all.deb) ...

Processing triggers for man-db ...

Setting up libmms0 (0.6.2-3) ...

Setting up python-support (1.0.15) ...

Setting up mimms (3.2.2-1) ...

Processing triggers for python-support ...

MyBookLive:~#


대략 위와 비슷하게 진행됩니다.




그리고 python 패키지도 설치해줍니다.


apt-get install python



MyBookLive:~# apt-get install python

Reading package lists... Done

Building dependency tree

Reading state information... Done

The following extra packages will be installed:

  libexpat1 libncursesw5 libssl1.0.0 python-minimal python2.5

  python2.5-minimal python2.7 python2.7-minimal

Suggested packages:

  python-doc python-tk python2.5-doc binfmt-support python2.7-doc

Recommended packages:

  libgpm2

The following NEW packages will be installed:

  libssl1.0.0 python2.7 python2.7-minimal

The following packages will be upgraded:

  libexpat1 libncursesw5 python python-minimal python2.5 python2.5-minimal

6 upgraded, 3 newly installed, 0 to remove and 296 not upgraded.

Need to get 10.4MB of archives.

After this operation, 16.4MB of additional disk space will be used.

Do you want to continue [Y/n]? y

Get:1 http://ftp.us.debian.org wheezy/main libncursesw5 5.9-10 [132kB]

Get:2 http://ftp.us.debian.org wheezy/main libssl1.0.0 1.0.1e-2 [1183kB]

Get:3 http://ftp.us.debian.org wheezy/main libexpat1 2.1.0-1 deb7u1 


[142kB]

Get:4 http://ftp.us.debian.org wheezy/main python2.7-minimal 2.7.3-6 


[1753kB]

Get:5 http://ftp.us.debian.org wheezy/main python2.7 2.7.3-6 [2639kB]

Get:6 http://ftp.us.debian.org squeeze/main python2.5 2.5.5-11 [3009kB]

Get:7 http://ftp.us.debian.org squeeze/main python2.5-minimal 2.5.5-11 


[1285kB]

Get:8 http://ftp.us.debian.org wheezy/main python 2.7.3-4 deb7u1 [181kB]

Get:9 http://ftp.us.debian.org wheezy/main python-minimal 2.7.3-4 deb7u1 


[42.8kB]

Fetched 10.4MB in 13s (754kB/s)

Preconfiguring packages ...

(Reading database ...

dpkg: warning: files list file for package `ramlog' missing, assuming 


package has no files currently installed.


dpkg: warning: files list file for package `libparted0' missing, assuming 


package has no files currently installed.

(Reading database ... 19016 files and directories currently installed.)

Preparing to replace libncursesw5 5.7 20081213-1 (using 


.../libncursesw5_5.9-10_powerpc.deb) ...

Unpacking replacement libncursesw5 ...

Selecting previously deselected package libssl1.0.0.

Unpacking libssl1.0.0 (from .../libssl1.0.0_1.0.1e-2_powerpc.deb) ...

Preparing to replace libexpat1 2.0.1-4 lenny3 (using .../libexpat1_2.1.0-


1 deb7u1_powerpc.deb) ...

Unpacking replacement libexpat1 ...

Selecting previously deselected package python2.7-minimal.

Unpacking python2.7-minimal (from .../python2.7-minimal_2.7.3-


6_powerpc.deb) ...

Selecting previously deselected package python2.7.

Unpacking python2.7 (from .../python2.7_2.7.3-6_powerpc.deb) ...

Preparing to replace python2.5 2.5.2-15 lenny1 (using .../python2.5_2.5.5


-11_powerpc.deb) ...

Unpacking replacement python2.5 ...

Preparing to replace python2.5-minimal 2.5.2-15 lenny1 (using 


.../python2.5-minimal_2.5.5-11_powerpc.deb) ...

Unpacking replacement python2.5-minimal ...

Preparing to replace python 2.5.2-3 (using .../python_2.7.3-


4 deb7u1_all.deb) ...

running python pre-rtupdate hooks for python2.7...

Unpacking replacement python ...

Preparing to replace python-minimal 2.5.2-3 (using .../python-


minimal_2.7.3-4 deb7u1_all.deb) ...

Unpacking replacement python-minimal ...

Processing triggers for man-db ...

Setting up libncursesw5 (5.9-10) ...

Setting up libssl1.0.0 (1.0.1e-2) ...

Setting up libexpat1 (2.1.0-1 deb7u1) ...

Setting up python2.7-minimal (2.7.3-6) ...

Linking and byte-compiling packages for runtime python2.7...

Setting up python2.7 (2.7.3-6) ...

Setting up python2.5-minimal (2.5.5-11) ...

Setting up python2.5 (2.5.5-11) ...

Setting up python-minimal (2.7.3-4 deb7u1) ...

Setting up python (2.7.3-4 deb7u1) ...

Linking and byte-compiling packages for runtime python2.7...

running python rtupdate hooks for python2.7...

running python post-rtupdate hooks for python2.7...

Linking and byte-compiling packages for runtime python2.7...

Processing triggers for python-support ...

MyBookLive:~#



대략 위와 같이 설치됩니다.



reboot


위 명령어를 내려 재부팅을 해줍니다.




4. 녹음 스크립트 작성하기


mms 프로토콜을 지원하는 인터넷 라디오가 많기 때문에


각각의 방송에 맞게 스크립트를 작성하면 됩니다.


예를 들어 MBC FM4U를 녹음하고 싶다면



nano /DataVolume/EBSradio/mbc_fm4u.sh



위 명령어로 들어가서



#!/bin/bash

RADIO_ADDR="mms://211.181.136.136/livefm


PROGRAM_NAME=$1

RECORD_MINS=$(($2))

DEST_DIR=$3

TEMP=/DataVolume/EBSradio/`date %Y%m%d-%H%M`


REC_DATE=`date %Y%m%d-%H%M`


OUTPUT_FILENAME=$PROGRAM_NAME"_"$REC_DATE.mp3

mimms -t $RECORD_MINS $RADIO_ADDR $TEMP > /dev/null 2>&1

ffmpeg -i $TEMP -f mp3 -ab 128k $OUTPUT_FILENAME > /dev/null 2>&1


rm $TEMP


mkdir -p $DEST_DIR

mv $OUTPUT_FILENAME $DEST_DIR



위 내용을 그대로 붙여넣기 하고 


컨트롤 O, 엔터, 컨트롤 X를 하여 저장 후 닫습니다.


위에 빨간색으로 표시한 부분이 mms 주소가 들어갈 부분입니다.



chmod 755 /DataVolume/EBSradio/mbc_fm4u.sh


위 명령어로 실행 권한을 줍니다.





하나만 더 예를 들면, SBS 파워FM의 경우 



nano /DataVolume/EBSradio/sbs_pwfm.sh


위와 같이 알아보기 쉽게 파일 이름을 정하고



#!/bin/bash

RADIO_ADDR="mms://114.108.140.39/magicfm_live


PROGRAM_NAME=$1

RECORD_MINS=$(($2))

DEST_DIR=$3

TEMP=/DataVolume/EBSradio/`date %Y%m%d-%H%M`


REC_DATE=`date %Y%m%d-%H%M`


OUTPUT_FILENAME=$PROGRAM_NAME"_"$REC_DATE.mp3

mimms -t $RECORD_MINS $RADIO_ADDR $TEMP > /dev/null 2>&1

ffmpeg -i $TEMP -f mp3 -ab 128k $OUTPUT_FILENAME > /dev/null 2>&1


rm $TEMP


mkdir -p $DEST_DIR

mv $OUTPUT_FILENAME $DEST_DIR



위 내용을 그대로 붙여넣기 하고 


컨트롤 O, 엔터, 컨트롤 X를 하여 저장 후 닫습니다.



chmod 755 /DataVolume/EBSradio/sbs_pwfm.sh


위 명령어로 권한을 줍니다.



빨간색 주소보면 아시겠죠? 


다른 방송도 마찬가지로 sh 파일을 생성하고 해당 주소를 넣으면 됩니다.



5. 테스트하기


잘 되는지 테스트 해봐야겠죠?


/DataVolume/EBSradio/mbc_fm4u.sh mbc_test 1 /shares/radio/mbc


위 명령어를 내리면 1분동안 녹음을 하고 MP3로 변환합니다.


변환하는 시간은 녹음시간의 1/3 정도 됩니다.


1분 녹음의 경우 변환하는데 20초 정도가 소요되며, 20분 녹음하면 6~7분 정도 


소요됩니다.


변환하는 동안엔 CPU 사용률이 100%가 됩니다.


RTMP 프로토콜의 경우 M4A로 저장하면 순식간에 변환이 가능하나,


mms의 경우 mp3로 변환하지 않으면 파일이 깨지더군요;;



/shares/radio/mbc


위 폴더로 들어가보면 해당 파일이 mbc_test_20140207-0835.mp3 이런 식으로 저


장됨을 볼 수 있습니다.


1분에 대략 1MB 정도 됩니다.




6. 스케쥴 작업 넣기


녹음할 때마다 SSH 접속해서 명령을 내리면 귀찮겠죠?


그래서 자동으로 작업을 수행하게 CRON을 쓸 것입니다.


스케쥴러 강좌는


http://www.wsgvet.com/bbs/board.php?bo_table=iomega&wr_id=200


위 링크의 5번에 있으니 참조하시면 됩니다.


간단하게 예를 들면


00 18 * * * /DataVolume/EBSradio/mbc_fm4u.sh BCS_Music_Camp 120 /shares/radio/mbc


위와 같이 넣으면 매일 오후 6시부터 2시간 동안 녹음을 하게 됩니다.


20분까지는 해봤는데 2시간은 해보질 않아서 잘 될지 모르겠네요.



이상 mms 라디오 녹음 강좌를 마칩니다.

관련자료

  • 서명
    우성짱의 NAS를 운영하고 있습니다.

    저의 즐거움이 여러분의 즐거움이면 좋겠습니다.

댓글 0
등록된 댓글이 없습니다.
전체 99 / 4 페이지
RSS

최근글


새댓글


알림 0