Mailinglist Archive: opensuse (2803 mails)
| < Previous | Next > |
Re: [opensuse] A question for the BASH gurus
- From: Rodney Baker <rodney.baker@xxxxxxxxxxxx>
- Date: Tue, 22 Jul 2008 08:20:58 +0930
- Message-id: <200807220820.58244.rodney.baker@xxxxxxxxxxxx>
On Sun, 13 Jul 2008 04:11:50 David Bolt wrote:
Thanks, David. ffmpeg doesn't actually need the -f parameter to set the output
format - it will auto-detect from the output file extension (which means that
the script can automatically handle video as well as audio-only streams).
That being said, I might play with adding a couple of optional command line
parameters to specify output format details if needed. That could make it
easy to download and convert to pal dvd format in one step :-).
Regards,
--
===================================================
Rodney Baker VK5ZTV
rodney.baker@xxxxxxxxxxxx
===================================================
The rhino is a homely beast,
For human eyes he's not a feast.
Farewell, farewell, you old rhinoceros,
I'll stare at something less prepoceros.
-- Ogden Nash
[...snip...]
A simple way would be to write a script to do it and just pass the URL
and output name to it. That way you can hide the various steps away and
only need to worry about the one command.
You might want to add in a bit more error-checking, but something like
this should do:
#!/bin/bash
URL="$1"
OUTPUT="$2"
# make sure there's an input and an output specified
#
[ -z "${URL}" -o -z "${OUTPUT}" ] && exit
# check for pre-existing output file and abort if present
#
[ -s "${OUTPUT}" ] && exit 1
# get a temporary filename
#
TEMPFILE=$(mktemp)
# and then use it to create named pipe
#
rm "${TEMPFILE}"
mkfifo "${TEMPFILE}"
# have ffmpeg read from the named pipe, write the mp3 as 160kbits, and
# background it. Redirect stdin so it doesn't try reading from the
# keyboard.
#
ffmpeg -f rm -i "${TEMPFILE}" -f mp3 -ab 160k "${OUTPUT}" </dev/null &
# have mplayer read the stream from the supplied URL and dump
# it to the named pipe
#
mplayer -dumpstream -dumpfile "${TEMPFILE}" -playlist "${URL}"
# remove the pipe
#
rm "${TEMPFILE}"
# and quit
#
exit 0
Thanks, David. ffmpeg doesn't actually need the -f parameter to set the output
format - it will auto-detect from the output file extension (which means that
the script can automatically handle video as well as audio-only streams).
That being said, I might play with adding a couple of optional command line
parameters to specify output format details if needed. That could make it
easy to download and convert to pal dvd format in one step :-).
Regards,
--
===================================================
Rodney Baker VK5ZTV
rodney.baker@xxxxxxxxxxxx
===================================================
The rhino is a homely beast,
For human eyes he's not a feast.
Farewell, farewell, you old rhinoceros,
I'll stare at something less prepoceros.
-- Ogden Nash
| < Previous | Next > |