LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This 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


Reply
  Search this Thread
Old 03-02-2007, 03:56 AM   #1
josno
LQ Newbie
 
Registered: Mar 2006
Posts: 18

Rep: Reputation: 0
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?

Last edited by josno; 03-05-2007 at 09:55 AM.
 
Old 03-03-2007, 02:47 AM   #2
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417

Rep: Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985
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.
 
Old 03-03-2007, 04:42 AM   #3
josno
LQ Newbie
 
Registered: Mar 2006
Posts: 18

Original Poster
Rep: Reputation: 0
What do you mean the right crontab? I added it using crontab -e. Good idea on the variables - I'll try them out
 
Old 03-03-2007, 05:56 AM   #4
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417

Rep: Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985
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
 
Old 03-03-2007, 05:57 AM   #5
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417

Rep: Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985
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.
 
Old 03-05-2007, 09:54 AM   #6
josno
LQ Newbie
 
Registered: Mar 2006
Posts: 18

Original Poster
Rep: Reputation: 0
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

Last edited by josno; 03-05-2007 at 09:58 AM.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
dumping mysql db script with dates markehb Linux - Software 2 04-23-2006 10:11 PM
Need to stream video on RH. Ideas/Help? devinnull Linux - Software 1 12-20-2005 06:53 PM
mplayer stream dumping error mukesh Linux - Software 6 12-13-2005 08:47 AM
Novell is dumping KDE, so I'll be dumping SuSE KimVette SUSE / openSUSE 10 11-12-2005 08:09 PM
stream video from samba? greenthing Linux - Software 14 06-12-2005 01:41 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 01:10 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration