HLS: не удается воспроизвести загруженную копию потока Apple

РЕДАКТИРОВАТЬ

Теперь мой вопрос решен (см. ниже), и каждый может использовать этот скрипт для загрузки потоков m3u8, таких как Bipbop от Apple

ORIG ВОПРОС

Я создал этот хороший скрипт для загрузки Apple bipbop sample HLS stream. Однако я не могу играть. Если вы поможете мне решить эту проблему, мы все сможем наслаждаться этим сценарием:

#!/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="(.*)".*_

EDIT

My question is now solved (see below), and everybody can use this script to download m3u8 streams like Apple's bipbop

ORIG QUESTION

I have created this nice script to download Apple's BipBop sample HLS stream. However I'm failing to play it. If you help me solving this issue, we can all enjoy this script:

#!/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="(.*)".*_1_' >> 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="(.*)".*_1_' >> 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 {} ;

When the stream is ready, I run an http server using Python's http server:

http-server -p 8090

and then try to play using this command:

open http://localhost:8090/bipbop_16x9_variant.m3u8 -a Safari

The http server shows normal requests:

[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..."

But Safari is failing to play the stream, showing a "Missing Plug-in" message...

Any idea please ??? we need this stream for iOS development...

_' >> 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="(.*)".*_

EDIT

My question is now solved (see below), and everybody can use this script to download m3u8 streams like Apple's bipbop

ORIG QUESTION

I have created this nice script to download Apple's BipBop sample HLS stream. However I'm failing to play it. If you help me solving this issue, we can all enjoy this script:

#!/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="(.*)".*_1_' >> 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="(.*)".*_1_' >> 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 {} ;

When the stream is ready, I run an http server using Python's http server:

http-server -p 8090

and then try to play using this command:

open http://localhost:8090/bipbop_16x9_variant.m3u8 -a Safari

The http server shows normal requests:

[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..."

But Safari is failing to play the stream, showing a "Missing Plug-in" message...

Any idea please ??? we need this stream for iOS development...

_' >> 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 {} ;

Когда поток готов, я запускаю http-сервер, используя http-сервер Python:

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.

1 ответ

  1. Так что благодаря комментарию @libertyernie эта проблема теперь решена. На самом деле я сам подозревал эту проблему: модуль http-сервера Python не является правильным инструментом для обслуживания потоков 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 и смотреть поток.