Kubuntu НОВОСТИ   СКАЧАТЬ   ВИКИ   FAQ   СООБЩЕСТВО   О САЙТЕ  

Watch iPhone or iPad streaming in Mplayer or VLC

scripts / watch_iPhone_streaming_in_Mplayer_or_VLC

These bash scripts allow You to watch and record iPhone or iPad streaming in Mplayer2:

#!/bin/bash

## Usage: apple-stream-mplayer.sh httm://example.com/watch.m3u8 
## If You want to record the stream during playback, apply `rec` as the second parameter.

UA='Mozilla/5.0 (iPad; U; CPU OS 3_2_1 like Mac OS X; en-us) AppleWebKit/531.21.10 (KHTML, like Gecko) Mobile/7B405'
Title="Stream - $$"
DATE="$(date +%s)"
PLNK="$1"

while [[ ! $(wget -O - -U "$UA" -t 1 -nc -nv "$PLNK" | grep '\.ts') ]]
  do
    if [[ ! `echo "$PLNK" | grep http` ]]
      then
        BP="$(dirname $1)/"
      else BP=""
    fi
    PLNK="$BP$(wget -U "$UA" -O - "$PLNK" | grep -m 1 '\.m3u8')"
  done

PL="$(wget -O - -U "$UA" -t 1 -nc -nv "$PLNK" | grep '\.ts')"

if [[ ! `echo "$PL" | grep http` ]]
  then
    B="-B $(dirname $PLNK)/"
fi

mplayer -title "$Title" -softvol -vf screenshot --really-quiet <(

if [[ "$2" == "rec" ]]
  then
    while [[ `pgrep -f "$Title"` ]]
      do
        echo "$PL" | wget -i - -U "$UA" -t 1 -nv $B -O - | tee -a "Stream-$DATE.ts"
        PL="$(comm -13 <(echo "$PL") <(wget -O - -U "$UA" -t 1 -nc -nv "$PLNK" | grep '\.ts') )"
      done
  else
    while [[ `pgrep -f "$Title"` ]]
      do
        echo "$PL" | wget -i - -U "$UA" -t 1 -nv $B -O - 
        PL="$(comm -13 <(echo "$PL") <(wget -O - -U "$UA" -t 1 -nc -nv "$PLNK" | grep '\.ts') )"
      done
fi   
)

Or if You prefer VLC:

#!/bin/bash

## Usage: apple-stream-vlc.sh httm://example.com/watch.m3u8 
## If You want to record the stream during playback, apply `rec` as the second parameter.

UA='Mozilla/5.0 (iPad; U; CPU OS 3_2_1 like Mac OS X; en-us) AppleWebKit/531.21.10 (KHTML, like Gecko) Mobile/7B405'
Title="Stream - $$"
DATE="$(date +%s)"
PLNK="$1"

while [[ ! $(wget -O - -U "$UA" -t 1 -nc -nv "$PLNK" | grep '\.ts') ]]
  do
    if [[ ! `echo "$PLNK" | grep http` ]]
      then
        BP="$(dirname $1)/"
      else BP=""
    fi
    PLNK="$BP$(wget -U "$UA" -O - "$PLNK" | grep -m 1 '\.m3u8')"
  done

PL="$(wget -O - -U "$UA" -t 1 -nc -nv "$PLNK" | grep '\.ts')"

if [[ ! `echo "$PL" | grep http` ]]
  then
    B="-B $(dirname $PLNK)/"
fi

vlc --video-title "$Title" --no-one-instance -I dummy <(

if [[ "$2" == "rec" ]]
  then
    while [[ `pgrep -f "$Title"` ]]
      do
        echo "$PL" | wget -i - -U "$UA" -t 1 -nv $B -O - | tee -a "Stream-$DATE.ts"
        PL="$(comm -13 <(echo "$PL") <(wget -O - -U "$UA" -t 1 -nc -nv "$PLNK" | grep '\.ts') )"
      done
  else
    while [[ `pgrep -f "$Title"` ]]
      do
        echo "$PL" | wget -i - -U "$UA" -t 1 -nv $B -O - 
        PL="$(comm -13 <(echo "$PL") <(wget -O - -U "$UA" -t 1 -nc -nv "$PLNK" | grep '\.ts') )"
      done
fi   
)

For playing just open remote .m3u8 playlist:

apple-stream-mplayer.sh 'http://tvrain-video.ngenix.net/mobile/TVRain1_ipad.stream/playlist.m3u8'

And if You want to record the stream during playback, add rec as the second parameter:

apple-stream-mplayer.sh 'http://tvrain-video.ngenix.net/mobile/TVRain1_ipad.stream/playlist.m3u8' rec

По русски

Теги:

Последнее изменение: 2012-03-07 23:50:40, BrainFucker - [ Изменения статьи ] [ История wiki ]

Kubuntu and Ubuntu are registered trademarks of Canonical Ltd.
Kubuntu и Ubuntu являются зарегистрированными торговыми марками Canonical Ltd.
Powered by Django framework Powered by Sphene Community Tools