2014年2月28日 星期五

下載香港電台節目重溫方法

Update: 2015-5-17 更新並整理內容
===========================

方法1:使用 internet download manager 下載
方法2:使用 ffmpeg 下載
方法3:使用 LiveStreamer 下載
方法4:使用 Download manager 下節目的 playlists 中的多個 ts 檔案
方法5:自行寫 program 解釋 HLS (HTTP Live Streaming),並下載檔案 (待寫)
方法6:編寫script並使用 ffmpeg、LiveStreamer下載


方法1:使用 internet download manager
========================================== 
internet download manager 能下載所有playlist中所有 ts 檔案並自動合併成單一檔案



refs: http://forum4.hkgolden.com/view.aspx?type=SW&message=5226138


方法2:使用 ffmpeg 下載
=====================

第一步下載 ffmpeg
http://www.ffmpeg.org/download.html

以下以 windows 為例子,Mac /Linux 下載方法細節自行推敲吧。


第二步到要重溫節目聲音檔案網頁,打開重溫節目的 Rthk player 網頁

第三步檢視原始碼
找出要下載的 playlist 網址

講東講西為例子,打開獨立 Rthk player 網頁

下載完整全部份網址
 
下載第一部份網址
 
下載第二部份網址

「命令提示字元」 MS-DOS Command Prompt 下輸入

ffmpeg -i "http://stmw.rthk.hk/aod/_definst_/radio/archive/radio1/happydaily/mp3/mp3:20140128.mp3/playlist.m3u8?wowzaplaystart=0&wowzaplayduration=2398000" -acodec mp3 OutputTest12345.mp3


等待數分鐘後便完成下載 (轉錄 stream),檔名為 OutputTest12345.mp3 (自訂的檔案名)


方法3:使用 LiveStreamer 下載
=========================
livestreamer 介紹
http://www.videohelp.com/tools/livestreamer

用法例子 
http://stream-recorder.com/forum/download-audio-streamed-jwplayer-t19521.html

以 windows 版的 LiveStremer 為例,下載以下節目

講東講西 - 任性

先下載 LiveStreamer ,解壓

「命令提示字元」 MS-DOS Command Prompt 下輸入

Step 1
============================================================
livestreamer "hlsvariant://stmw3.rthk.hk/aod/_definst_/radio/archive/radio1/Free_as_the_wind/mp3/mp3:20150327.mp3/playlist.m3u8"  best -o 20150327.ts

Step 2
============================================================
再使用ffmpeg轉換 ts file為 mp3 file,去除一些不必要的 header data

ffmpeg -i "20150327.ts" -c:a copy "20150327.mp3"




方法4:使用 Download manager 下節目的 playlists 中的多個 ts 檔案
=====================================================
待寫,暫時參考
http://blog.sina.com.cn/s/blog_571e0fe40101hrvo.html


方法5:自行寫 program 解釋 HLS (HTTP Live Streaming),並下載檔案 (待寫)
 ============================================================
- 什麼是 HTTP Live Streaming
- 什麼是 M3U、M3U8 file
- M3U8 格式
- note 一些細節
港台使用串流server軟件為 Wowza Media Server 3 Perpetual Edition 3.6.4 build9641
串流時 load balance到幾個不同server,下載串流網址其實互通的,一個 down 機時,可改用另一個server

http://stmw.rthk.hk
http://stmw1.rthk.hk
http://stmw2.rthk.hk
http://stmw3.rthk.hk

現成解釋 HLS 工具或script,e.g.
gohls - HTTP Live Streaming (HLS) downloader written in Golang
https://github.com/kz26/gohls 

 hlsclient
Client to download all files from HLS streams
This is a simple Python HTTP Live Streaming Client. It consumes a list of remote playlists, and saves all needed files to serve the playlist locally: the key, segments, and a modified m3u8 with paths normalized.

10 則留言:

Unknown 提到...

但系用ffmpeg经常会出错或者中间停住唔郁,down唔到完整嘅节目哦

XXXXXX 筆記簿 提到...

用舊version ffmpeg + 自訂script download
http://www.sendspace.com/file/2t67o2

匿名 提到...

找不到檔案http://www.sendspace.com/file/2t67o2

可否再Share多一次, THANKS

Unknown 提到...

請問可否再 share 多一次? 因已 download 唔到。 Thanks

匿名 提到...

請問舊版是指哪個版本?
https://github.com/FFmpeg/FFmpeg/releases?after=n0.10.7

匿名 提到...

http://ffmpeg.zeranoe.com/builds/win64/static/

北川明一 提到...

今日因為想keep番林保全嘅訪問搵到呢度
剛試了1.2.11版本可以順利完成

Win32版本
http://ffmpeg.zeranoe.com/builds/win32/static/ffmpeg-1.2.11-win32-static.7z

Win64版本
http://ffmpeg.zeranoe.com/builds/win64/static/ffmpeg-1.2.11-win64-static.7z

北川明一 提到...

wowzaplaystart 同 wowzaplayduration 係用milliseconds嚟計
最簡單方法係google輸入112 minutes = milliseconds
就會得到答案係6720000 milliseconds

匿名 提到...

我用ffmpeg方法下載港台節目, 開啟Command Prompt並輸入
ffmpeg -i "http://stmw.rthk.hk/aod/_definst_/radio/archive/radio1/happydaily/mp3/mp3:20140128.mp3/playlist.m3u8?wowzaplaystart=0&wowzaplayduration=2398000" -acodec mp3 OutputTest12345.mp3

但網址輸入到一半就無法再輸入了, 請問為什麼會這樣? 哪兒出錯了?

匿名 提到...

原來我執行錯誤, 可以打全網址了, 不過總是出現這句
"ffmpeg 不是內部或外部命令、可執行的程式或批次檔"
請問又怎解決呢?