You are not logged in.

#1 2008-01-10 16:20:28

harry
Member
Registered: 2007-06-25
Posts: 24

bash script to dumpstream many files simultaneously with mplayer

hi guys

i have a problem which i´m sure can be solved with the power of bash scripting tongue
unfortunately i´m no bash scripting guru and all my experiments failed so far neutral

the problem:

i have a file in which are links(streaminglinks)
mplayer offers the funtion to dump such a stream with simply issuing

mplayer -dumpstream mms://path/to/video -dumpfile video1

for example.

now i want mplayer to download this streams specified in the links-file automatically.

basically all it required is a bash script which goes through the link file and generates a command like mplay -dumpstream <link> -dumpfile video<n>
(where n is the nth link) and execute it.maybe there a even simpler solutions
well since i´m not that experienced with bashscripting i can´t solve that problem at my self....


i´m grateful for any help

Offline

#2 2008-01-10 17:55:33

kraluz
Member
From: Aveiro, Portugal
Registered: 2008-01-01
Posts: 30

Re: bash script to dumpstream many files simultaneously with mplayer

you can do it this way:

#!/bin/bash

urls=(`cat $1`) # Loads contents of file (first arg of this script)
url_no=${#urls[@]} # Counts urls

for ((i=0; i<$url_no; ++i )) # a tipical for loop
do
        mplayer -dumpstream ${urls[$i]} -dumpfile video${i}
done

Offline

#3 2008-01-10 19:29:25

Gilneas
Member
From: Netherlands
Registered: 2006-10-22
Posts: 320

Re: bash script to dumpstream many files simultaneously with mplayer

You could also try it with awk

awk '
BEGIN { i=0 }
{ i++
system( "mplayer -dumpstream \"" $0 "\" -dumpfile video" i ) }' < file_with_urls

Offline

#4 2008-01-11 12:15:02

harry
Member
Registered: 2007-06-25
Posts: 24

Re: bash script to dumpstream many files simultaneously with mplayer

hey guys

thx for the two scripts.
my approach was nearly the same as your´s kraluz with the difference that it doesn´t work big_smile

but they both have a little blemish tongue
they download the files sequentially not simultaneously hmm
how could that be realised

thx in advance

Offline

#5 2008-01-11 12:41:38

Gilneas
Member
From: Netherlands
Registered: 2006-10-22
Posts: 320

Re: bash script to dumpstream many files simultaneously with mplayer

You could run the mplayer command in the background.
in the for loop version: mplayer -dumpstream ${urls[$i]} -dumpfile video${i} &
in the awk version: system( "mplayer -dumpstream \"" $0 "\" -dumpfile video" i " &" )

Offline

#6 2008-01-11 18:17:56

harry
Member
Registered: 2007-06-25
Posts: 24

Re: bash script to dumpstream many files simultaneously with mplayer

wohoo thx, this works great smile

think i will have a further look at awk. looks interesting

thx you two

Offline

Board footer

Powered by FluxBB