Linux - GeneralThis Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Dumping video stream with mplayer32 and script (now with added proxy server issue)
I'm trying to capture a video stream using a script in Ubuntu 6.10 amd64 using mplayer32. This is what I have so far:
Code:
#!/bin/bash
DONE="false"
echo `date +%F` `date +%R`": Started" >> /home/rayj/m6/log.txt
if [ ! -d /home/rayj/m6/`date +%Y` ]
then
mkdir /home/rayj/m6/`date +%Y`
chmod 777 /home/rayj/m6/`date +%Y`
fi
if [ ! -d /home/rayj/m6/`date +%Y`/`date +%B` ]
then
mkdir /home/rayj/m6/`date +%Y`/`date +%B`
fi
if [ ! -f /home/rayj/m6/`date +%Y`/`date +%B`/`date +%d_%A`.asf ]
then
echo `date +%F` `date +%R`": Trying to create "`date +%d_%A`".asf" >> /home/rayj/m6/log.txt
mplayer32 -playlist http://www.m6.fr/content/video/info/asx/National12_00_`date +%d%m%y`.asx -dumpstream -dumpfile /home/rayj/m6/`date +%Y`//`date +%B`//`date +%d_%A`.asf
DONE="true"
fi
FILESIZE=$(stat -c%s "/home/rayj/m6/"`date +%Y`"/"`date +%B`"/"`date +%d_%A`".asf")
if [ ! -f /home/rayj/m6/`date +%Y`/`date +%B`/`date +%d_%A`.asf ]
then
echo `date +%F` `date +%R`": Could not create "`date +%d_%A`".asf" >> /home/rayj/m6/log.txt
elif [ $FILESIZE -lt 45000000 ]
then
echo `date +%F` `date +%R`": File looks incomplete - re-doing." >> /home/rayj/m6/log.txt
rm /home/rayj/m6/`date +%Y`/`date +%B`/`date +%d_%A`.asf
mplayer32 -playlist http://www.m6.fr/content/video/info/asx/National12_00_`date +%d%m%y`.asx -dumpstream -dumpfile /home/rayj/m6/`date +%Y`//`date +%B`//`date +%d_%A`.asf
elif [ $DONE != "true" ]
then
echo `date +%F` `date +%R`": "`date +%d_%A`".asf already exists" >> /home/rayj/m6/log.txt
fi
echo `date +%F` `date +%R`": Completed" >> /home/rayj/m6/log.txt
echo "" >> /home/rayj/m6/log.txt
This is run by cron every hour of every weekday, the crontab entry looking like this:
Code:
0 * * * 1,2,3,4,5 /home/rayj/m6/m6.sh
My problem is this: if I run the script in a terminal as me (i.e. not sudo) it works absolutely fine. However, when cron runs it, or if I run it from nautilus (not in a terminal window) it won't actually write the file. I'll get this in the log:
Code:
2007-02-28 22:00: Started
2007-02-28 22:00: Trying to create 28_Wednesday.asf
2007-02-28 22:16: Could not create 28_Wednesday.asf
2007-02-28 22:16: Completed
Sometimes it will have taken time between start and end, sometimes not, and both times no file will have been created. The folder it's writing to and the script both have 777 permissions. Does anyone have any ideas what's going wrong?
well i'd suggest ensuring that you can see your variables fully, rather than just logging part of it. set the entire final filename to a variable and use that single variable in both the log entry and the executed command. most likely i'd have to assume that there's a permissions issue. are you running this under the right crontab? you might like to log other things like whoami to the log file and such, to check you really are the right user.
you could have been using roots crontab or something, but then if it was root, they'd have access anyway.
oh of course the other thing i forgot, which is probably, definitely, most useful of all would be mplayer's own output... mplayer -etc blah 2>&1 > mplayer.log
thinking more about mplayer, i *think* it actually by default attaches to video and sound outputs and then doesn't use them on dumping. you might want to try -vo null and -ao null to not look for alsa / X access etc... just a guess.
Thanks for all your help so far. With the modifications suggested so far, this is what I get in the main log:
Code:
2007-03-05 15:49: Started
2007-03-05 15:49: User running: rayj
2007-03-05 15:49: Stream path: http://www.m6.fr/content/video/info/asx/National12_00_050307.asx
2007-03-05 15:49: Trying to create /home/rayj/m6/2007/March/05_Monday.asf
2007-03-05 15:49: Could not create /home/rayj/m6/2007/March/05_Monday.asf
2007-03-05 15:49: Completed
And this is what I get in the mplayer log:
Code:
MPlayer 2:0.99+1.0pre7try2+cvs20060117-0ubuntu8 (C) 2000-2006 MPlayer Team
CPU: Advanced Micro Devices Athlon 64/FX Sledgehammer,San Diego,Venice (Family: 15, Stepping: 1)
CPUflags: MMX: 1 MMX2: 1 3DNow: 1 3DNow2: 1 SSE: 1 SSE2: 1
Compiled with runtime CPU detection.
STREAM_HTTP(1), URL: http://www.m6.fr/content/video/info/asx/National12_00_050307.asx
Resolving www.m6.fr for AF_INET6...
Resolving www.m6.fr for AF_INET...
Connecting to server www.m6.fr[192.136.30.15]: 80...
STREAM_ASF, URL: http://www.m6.fr/content/video/info/asx/National12_00_050307.asx
Resolving www.m6.fr for AF_INET6...
Resolving www.m6.fr for AF_INET...
Connecting to server www.m6.fr[192.136.30.15]: 80...
STREAM_HTTP(2), URL: http://www.m6.fr/content/video/info/asx/National12_00_050307.asx
Resolving www.m6.fr for AF_INET6...
Resolving www.m6.fr for AF_INET...
Connecting to server www.m6.fr[192.136.30.15]: 80...
Which I've just realised is quite interesting - I'm running from behind a proxy server and if I use the terminal, that part looks like this:
Code:
MPlayer 2:0.99+1.0pre7try2+cvs20060117-0ubuntu8 (C) 2000-2006 MPlayer Team
CPU: Advanced Micro Devices Athlon 64/FX Sledgehammer,San Diego,Venice (Family: 15, Stepping: 1)
CPUflags: MMX: 1 MMX2: 1 3DNow: 1 3DNow2: 1 SSE: 1 SSE2: 1
Compiled with runtime CPU detection.
STREAM_HTTP(1), URL: http://www.m6.fr/content/video/info/asx/National12_00_050307.asx
Resolving 172.16.250.1 for AF_INET6...
Couldn't resolve name for AF_INET6: 172.16.250.1
Connecting to server 172.16.250.1[172.16.250.1]: 8080...
Cache size set to 320 KBytes
Then it goes about the business of capturing the stream. So it's not picking up the proxy server properly. I have it set both in the network proxy settings (System > Preferences > Network Proxy) and in a config file I forget the name of at the moment (it's not .bashrc or .bash_profile in my home directory).
EDIT: It's actually in /etc/bash.bashrc. I have HTTP_PROXY and FTP_PROXY set
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.