video recording in mplayer


joachim

Member
Joined
May 22, 2013
Messages
404
I use to record tv in mplayer when I have time to do by hand so I can start some minutes earlier and stop a bit later because the given time is not always correct. But for recordings at night I used kaffeine with the schedule.
Now I have problems when sometimes start/stop is not what EPG is showing. So there is something missing at
the beginning or end. How can I start and stop mplayer at wanted times ? Start is no problem with at command but how to stop when I don't know the PID? Or can I get PID somehow by script when mplayer is running.
Mplayer also will not need as much resources as kaffeine.

Thanks for help

Joachim
 

lukey

Rare Species
Joined
Jun 17, 2015
Messages
496
Location
Germany
In the at command enter:

mplayer <whatever options you want> &
pid=$!
sleep <how many seconds to wait>
kill $pid

Don't forget the "&"
 

joachim

Member
Joined
May 22, 2013
Messages
404
Thanks for the tip. I tried it and works so far. I also found killall and so can stop mplayer without the PID. What I want to do is a script with start and stop time e.g. record starttime stoptime. So far I get with KAlarm for starting a script record stoptime.
at hh::mm killall mplayer is not working so I use at hh:mm -f kill where kill is a file with the line
just killall mplayer that works. Is it possible to start a script with at ? I can't get it to work.
I can try a script with uses record sleepseconds stoptime .

so this is it for now

#!/bin/bash
# for recording and stopping after set time then convert to mp4
# start as aufnahme HH:MM where HH:MM is stop time

cd ~/Videos
echo $1
#call file with does killall mplayer at set time
at $1 -f ~/Videos/kill
#mplayer Hello.mp4
mplayer -dumpstream dvb://arte -dumpfile tati.mpg


nice ffmpeg -i infile -map 0:0 -map 0:1 -map 0:2 -c:a mp2 -b:a 96k -b:v 450k -c:v mpeg4 outfile
echo "fertig"
 

FBnil

There is 1 impostor among us.
Joined
Dec 14, 2012
Messages
3,447
Location
Yurp
@joachim: have you tried
Code:
echo "/bin/bash ~/CODE/myscript.sh" |at 01:01
note: need to use paths, output files also need to have a path, or you need to cd to your working directory first.

If you need to feed the pipe composite information, then use (), like so:

Code:
(echo "hello";V="world";echo "$V") |xargs echo
also:

you can do it in less scripts, for example, run mplayer with & and fetch the PID with $! as @lukey said, then schedule a kill with at, meanwhile use the command "wait", to wait for the command with an & to end (which ends by that killall), you can then run the ffmpeg line. Should work from a single script...
 
Last edited:

joachim

Member
Joined
May 22, 2013
Messages
404
@FBnil : thanks for the tip. The echo version seems not to work, but I found something for the stop
time that works: (when calling the script with hh:mm I have the stoptime for at)
...
mplayer ~/Videos/Hello.mp4 &
pid=$!
at $1 <<< "kill $pid"
Now I can use KAlarm to start the script; it seems at cant start scripts. Or is it possible ?

edit :

I found in internet the echo versions works,but if you want to see the output you have to

echo "/bin/bash progname > $(tty)" | at hh:mm and all seems fine. But when I want to play video I have no
output.

trying goes on
 
Last edited:
Top