HLS:无法播放下载的 Apple 流副本
HLS: failing to play a downloaded copy of Apple's stream
编辑
我的问题现在已经解决了(见下文),大家可以使用这个脚本下载苹果的bipbop等m3u8流
原始问题
我创建了这个不错的脚本来下载 Apple 的 BipBop 示例 HLS 流。但是我无法播放它。如果你帮我解决这个问题,我们都可以享受这个脚本:
#!/bin/bash
unset PROMPT_COMMAND
set -x
URL=https://devimages.apple.com.edgekey.net/streaming/examples/bipbop_16x9/bipbop_16x9_variant.m3u8
MANIFESTNAME=$(basename $URL)
LOCAL_MANIFEST=$MANIFESTNAME
URLPREF=$(dirname $URL)
wget $URL -O $LOCAL_MANIFEST
cat $LOCAL_MANIFEST | grep "#EXT-X-STREAM-INF:" -A1 | grep m3u8 > all_playlists.txt
cat $LOCAL_MANIFEST | grep "#EXT-X-MEDIA.*URI" | sed -e 's_.*URI=\"\(.*\)\".*__' >> all_playlists.txt
#this will yield files which we already downloaded, but we want the index file itself
cat $LOCAL_MANIFEST | grep "#EXT-X-I-FRAME-STREAM-INF.*URI" | sed -e 's_.*URI=\"\(.*\)\".*__' >> all_playlists.txt
while read playList; do
FOLDER=$(dirname $playList)
PL_NAME=$(basename $playList)
LOCAL_PL=$FOLDER/$PL_NAME
mkdir -p $FOLDER 2> /dev/null
PL_URL=$URLPREF/$playList
echo "PL_URL=$PL_URL"
TSL=${FOLDER}_TSList.txt
wget $PL_URL -O $LOCAL_PL
echo "LOCAL_PL=$LOCAL_PL"
cat $LOCAL_PL | grep -v "^#" | uniq > $TSL
echo "====== media list ======="
cat $TSL
echo "========================="
#TS is actually any media file
while read ts; do
TS_NAME=$URLPREF/$FOLDER/$ts
LOCAL_TS=$FOLDER/$ts
echo $TS_NAME
if [ -s $LOCAL_TS ]; then
echo "Already exists. skiping."
else
wget $TS_NAME -O $LOCAL_TS
fi
done < $TSL
rm $TSL
done < all_playlists.txt
rm all_playlists.txt
find . -name Thumbs.db -exec rm {} \;
流准备就绪后,我 运行 使用 Python 的 http 服务器的 http 服务器:
http-server -p 8090
然后尝试使用此命令播放:
open http://localhost:8090/bipbop_16x9_variant.m3u8 -a Safari
http 服务器显示请求正常:
[12:24:51] "GET /bipbop_16x9_variant.m3u8" "Mozilla/5.0 (Macintosh..."
[12:24:51] "GET /gear1/prog_index.m3u8" "Mozilla/5.0 (Macintosh..."
[12:24:52] "GET /gear1/main.ts" "Mozilla/5.0 (Macintosh..."
[12:24:52] "GET /subtitles/eng_forced/prog_index.m3u8" "Mozilla/5.0 (Macintosh..."
[12:24:52] "GET /subtitles/eng_forced/fileSequence0.webvtt" "Mozilla/5.0 (Macintosh..."
[12:24:52] "GET /gear0/prog_index.m3u8" "Mozilla/5.0 (Macintosh..."
[12:24:52] "GET /gear0/main.aac" "Mozilla/5.0 (Macintosh..."
[12:24:52] "GET /subtitles/eng_forced/fileSequence1.webvtt" "Mozilla/5.0 (Macintosh..."
但 Safari 无法播放流,显示“缺少插件”消息...
有什么想法吗???我们需要此流用于 iOS 开发...
感谢@libertyernie 的评论,这个问题现在已经解决了。实际上我自己也在怀疑这个问题:Python 的 http-server 模块不是用于提供 m3u8 流的正确工具,因为它无法针对正确的内容类型进行配置。
更好的工具是 Lighttpd。
安装:
brew install lighttpd
现在创建一个配置文件lighttpd.conf:
server.document-root = "<full-path-no-~>/bipbop"
server.port = 8090
mimetype.assign = (
".html" => "text/html",
".txt" => "text/plain",
".jpg" => "image/jpeg",
".png" => "image/png",
".m3u8" => "application/vnd.apple.mpegurl",
".ts" => "video/MP2T"
)
最后两行对我们的成功至关重要。现在我们可以 运行 我们的流服务器:
lighttpd -D -f lighttpd.conf
现在我们可以打开http://localhost:8090/bipbop_16x9_variant.m3u8并观看直播了。
编辑
我的问题现在已经解决了(见下文),大家可以使用这个脚本下载苹果的bipbop等m3u8流
原始问题
我创建了这个不错的脚本来下载 Apple 的 BipBop 示例 HLS 流。但是我无法播放它。如果你帮我解决这个问题,我们都可以享受这个脚本:
#!/bin/bash
unset PROMPT_COMMAND
set -x
URL=https://devimages.apple.com.edgekey.net/streaming/examples/bipbop_16x9/bipbop_16x9_variant.m3u8
MANIFESTNAME=$(basename $URL)
LOCAL_MANIFEST=$MANIFESTNAME
URLPREF=$(dirname $URL)
wget $URL -O $LOCAL_MANIFEST
cat $LOCAL_MANIFEST | grep "#EXT-X-STREAM-INF:" -A1 | grep m3u8 > all_playlists.txt
cat $LOCAL_MANIFEST | grep "#EXT-X-MEDIA.*URI" | sed -e 's_.*URI=\"\(.*\)\".*__' >> all_playlists.txt
#this will yield files which we already downloaded, but we want the index file itself
cat $LOCAL_MANIFEST | grep "#EXT-X-I-FRAME-STREAM-INF.*URI" | sed -e 's_.*URI=\"\(.*\)\".*__' >> all_playlists.txt
while read playList; do
FOLDER=$(dirname $playList)
PL_NAME=$(basename $playList)
LOCAL_PL=$FOLDER/$PL_NAME
mkdir -p $FOLDER 2> /dev/null
PL_URL=$URLPREF/$playList
echo "PL_URL=$PL_URL"
TSL=${FOLDER}_TSList.txt
wget $PL_URL -O $LOCAL_PL
echo "LOCAL_PL=$LOCAL_PL"
cat $LOCAL_PL | grep -v "^#" | uniq > $TSL
echo "====== media list ======="
cat $TSL
echo "========================="
#TS is actually any media file
while read ts; do
TS_NAME=$URLPREF/$FOLDER/$ts
LOCAL_TS=$FOLDER/$ts
echo $TS_NAME
if [ -s $LOCAL_TS ]; then
echo "Already exists. skiping."
else
wget $TS_NAME -O $LOCAL_TS
fi
done < $TSL
rm $TSL
done < all_playlists.txt
rm all_playlists.txt
find . -name Thumbs.db -exec rm {} \;
流准备就绪后,我 运行 使用 Python 的 http 服务器的 http 服务器:
http-server -p 8090
然后尝试使用此命令播放:
open http://localhost:8090/bipbop_16x9_variant.m3u8 -a Safari
http 服务器显示请求正常:
[12:24:51] "GET /bipbop_16x9_variant.m3u8" "Mozilla/5.0 (Macintosh..."
[12:24:51] "GET /gear1/prog_index.m3u8" "Mozilla/5.0 (Macintosh..."
[12:24:52] "GET /gear1/main.ts" "Mozilla/5.0 (Macintosh..."
[12:24:52] "GET /subtitles/eng_forced/prog_index.m3u8" "Mozilla/5.0 (Macintosh..."
[12:24:52] "GET /subtitles/eng_forced/fileSequence0.webvtt" "Mozilla/5.0 (Macintosh..."
[12:24:52] "GET /gear0/prog_index.m3u8" "Mozilla/5.0 (Macintosh..."
[12:24:52] "GET /gear0/main.aac" "Mozilla/5.0 (Macintosh..."
[12:24:52] "GET /subtitles/eng_forced/fileSequence1.webvtt" "Mozilla/5.0 (Macintosh..."
但 Safari 无法播放流,显示“缺少插件”消息...
有什么想法吗???我们需要此流用于 iOS 开发...
感谢@libertyernie 的评论,这个问题现在已经解决了。实际上我自己也在怀疑这个问题:Python 的 http-server 模块不是用于提供 m3u8 流的正确工具,因为它无法针对正确的内容类型进行配置。
更好的工具是 Lighttpd。
安装:
brew install lighttpd
现在创建一个配置文件lighttpd.conf:
server.document-root = "<full-path-no-~>/bipbop"
server.port = 8090
mimetype.assign = (
".html" => "text/html",
".txt" => "text/plain",
".jpg" => "image/jpeg",
".png" => "image/png",
".m3u8" => "application/vnd.apple.mpegurl",
".ts" => "video/MP2T"
)
最后两行对我们的成功至关重要。现在我们可以 运行 我们的流服务器:
lighttpd -D -f lighttpd.conf
现在我们可以打开http://localhost:8090/bipbop_16x9_variant.m3u8并观看直播了。