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.
Admin - Is it worth having a seperate forum dedicated to Bash?
I have been experimenting with the import command, importing xwindows.
One of the side affects is the numbering sequence as cycling them with imagemagick does not play in order as images start off with 1.miff, 2.miff all the way to infinity.miff and not specifying the number format say 0001.miff, 0002.miff means they animate in random sequence. I can rename them afterwards, but would be nice to do it all on the fly.
I thought about trying to force a number sequence OR include the system timestamp into the filename, so 0156489458.miff 0156489462.miff 0156489466.miff and so on, whatever the system reported. This way I can interpolate the image times for accuracy.
I have hunted Linux Commands and ss64 but cannot find any reference or dedicated command for timestamp. I may be outreaching what I need to do, when really specifying the name type, say a million 0000000.miff then 0000001.miff etc, but not sure how to do this.
Any tips would be very welcome. One thing I do know about linux is the more familiar you get with bash, the less heavy GUI apps you need. Bash is awesome!
demian@dirac:~$ date
Thu Mar 23 19:54:17 CET 2006
demian@dirac:~$ date "+%y%m%d"
060323
demian@direac:~$ date "+%y%m%d-%H%M%S%N"
060323-195435665289000
demian@dirac:~$
edit: oh, and to include that in a filename just do something like
while [ "$x" -le "$2" ]
do
import -window $1 "image$x.miff"
so to add timestamp into the filename,
let x=1
while [ "$x" -le "$2" ]
do
import -window $1 | date "+%y%m%d-%H%M%S%N" | $.miff" or >> or something?
Not sure if that is right? One other query, in specifying the capture, is there a way of knowing at what rate a capture is taken without working out the timestamps? I mean my system will capture at 400 FPS or 5 FPS?
while [ "$x" -le "$2" ] is missing some functionality I think!
Last edited by smudge|lala; 03-23-2006 at 02:21 PM.
import -window $1 | date "+%y%m%d-%H%M%S%N" | $.miff"[/b] or >> or something?
Not sure if that is right? One other query, in specifying the capture, is there a way of knowing at what rate a capture is taken without working out the timestamps? I mean my system will capture at 400 FPS or 5 FPS?
import -window $1 `date "+%H%M%S%N"`-$x.miff
can't you just divide the mumber of output file by the time the script runs?
It could be used that way I guess. I think the most accurate way is to sort the import images with another script as they have such accurate timestamps. This will take some working out!
I'm pretty new with bash scripting, but have to learn as there are so many things the command line can offer.
Looking at my earlier script, I have to input two variables. The first to specify the active window, 0x320003b or something, and the amount of captures I want to make, 50, 100, whatever. I'd like to add into the script extra functionality with echo for the variables.
The first is after I run the script $ ./import.sh to run xwininfo automatically so I can select the window, then for it to automatically use the 0x320003b or whatever window ID found in xwininfo, and ask 'how many captures?' I can type the quantity AND an output directory, hit return and start importing!
Bit of a job, but I think it's all bash, nothing external. Not sure how to crop the window ID 0x320003b
#!/bin/sh
echo "Click the window you want to capture..."
winid=`xwininfo |awk '{if(NR==6)print $4}'`
echo -n "Enter the number of captures: "
read numcap
echo "capturing $numcap frames of window $winid"
start=`date "+%s.%N"`
for i in `seq $numcap`
do
import -window $winid `date "+%H%M%S%N"`-$i.miff
done
stop=`date "+%s.%N"`
echo "Capture took `echo "scale=5;($stop-$start)/$numcap"|bc` seconds per frame"
edit: I just read the import man page and found out about the -snaps option. So you can forget the entire for loop and replace that with
it will create files named filename-0.miff through filename-$numcap.miff automatically. You can, of course, still prefix it with the date string if you whish.
Works a treat! Handy to swap between the two as the snap makes a single large file, but easily converted into a mng. Creates a file called filename.miff. Any way to echo 'output filename'?
Last edited by smudge|lala; 03-23-2006 at 11:01 PM.
Works a treat! Handy to swap between the two as the snap makes a single large file, but easily converted into a mng. Creates a file called filename.miff.
ok, i only tried it with png files since miff are so large. they are stored in a single file per capture.
Quote:
Anyway to echo 'output filename'?
You mean have the script ask for the filename? Sure, that's possible, however, I think I've done enough of your work. With the above you've got more than enough info to take it from here. http://www.tldp.org/LDP/abs/html/
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.