PDA

View Full Version : bash script with tydemux



jrogers
02-10-2003, 11:43 AM
I'm trying to use tydemux, which works excellent under OSX, mplex, and a bash script to automate the conversion from .ty to .mpg. Has anybody done this already?

What I want to do is figure out how to pass the offset from tydemux to mplex. Is there a way to output the offset to a file and have my bash script read that offset and put it in the command for mplex? If anybody can help me figure this one out, or has already done this, let me know.

THanks,
Jrogers

artships
02-10-2003, 01:43 PM
I was under the impression that tydemux gave the audio offset as the return code. Hence...

audiooffset=`tydemux etc.`
result_from_mplex = `mplex -o $audiooffset etc.`

jrogers
02-10-2003, 03:10 PM
From Olaf:

"Under Windows tydemux will return the A/V sync offset in milli seconds, and -1000 on error and 1000 on usage error.

Under Unix (Linux, MacOSX) tydemux will return 0 on success, -1 on error and 1 on usage error."

So this means that on OSX it will not output the offset? Is there a way to do this, or am I just stuck doing everything by hand until this is added to tydemux?

Thanks,
Jrogers

jrogers
02-10-2003, 08:52 PM
Originally posted by artships
I was under the impression that tydemux gave the audio offset as the return code. Hence...

audiooffset=`tydemux etc.`
result_from_mplex = `mplex -o $audiooffset etc.`

If I do the audiooffset=`tydemux -s 2 ...` it simply stores all of the output, everything that is written to the screen, including status in the variable audiooffset. This doesn't do what I thought it would, which is store the variable that is returned from tydemux.

is there a way to edit this variable that is created to only have the audio offset portion with Bash? scan the variable, or log file, and then when it finds "A/V Sync Offset: -XXXms (i.e. audio plays XXXms late...)" and then have it delete everything up to XXX and delete everything after it?

I don't think this is the best way to go about this, maybe someone else has figured out an easy way to do this.

THanks,
Jrogers

Superdave
02-10-2003, 10:29 PM
I personally use a perl script to go from .ty to .mpg in linux. I will attempt to post it here. Its not the prettiest but it works.


David

jrogers
02-10-2003, 11:48 PM
Well,
after browsing this forum, and brushing up on Bash scripting, I have a script that does everything I want it to do. I'm not personally interested in burning vcds, but rather just want a fast way to get a synched copy of a show off one of my Tivos, and then postprocess it to my /Movies/Tivo/ folder. I use MFS_Stream with Tivoweb, and Tydemux (which is very fast and accurate on OSX), and then Mplex. This script passes the offset properly from Tydemux to Mplex and fixes the problem with having spaces in the filename, and then renames the file to it's original name, spaces included. Now I'm gonna setup an applescript as a helper app to autoconvert the .TY files on download from Safari.

Here is the script if anyone is interested. This does not do batch file processing. I'd also like to figure out a way to incorporate a way to print out how long the whole process took.

Superdave
02-11-2003, 12:46 AM
If your looking for times use the time command to execute your script.. time tydemux.sh for instance. Some systems the command is timex, but thats mostly AT&T based unixes I think. OSX probably has the time command, although I dont know for sure.

Gruph
02-11-2003, 03:05 AM
Originally posted by Superdave
If your looking for times use the time command to execute your script.. time tydemux.sh for instance. Some systems the command is timex, but thats mostly AT&T based unixes I think. OSX probably has the time command, although I dont know for sure.

Indeed "time" is a great utility for getting the amount of time that it takes to run a program... However, it doesn't apply at all to this. The time that he is after is the output from STDOUT from tydemux for the delay of audio to properly sync it with the video when remuxing. Thanks for the attempt of help though :)

I personally use a perl script with a regex to get the delay to put in as the mplex argument.

-Gruph

tungsten2k
02-11-2003, 06:55 AM
Originally posted by jrogers
If I do the audiooffset=`tydemux -s 2 ...` it simply stores all of the output, everything that is written to the screen

that is how most unix-like os's work. the return code is only given back if the command is executed in a shell or spawned process, as with a parenthetical execution syntax:

mplexOffset = (tydemux -s [1|2] -i tystream -a audiofile -v videofile)

btw - this may be usefull :

http://www.dealdatabase.com/forum/showthread.php?s=&postid=82867#post82867

jrogers
02-11-2003, 10:53 AM
Originally posted by Gruph
Indeed "time" is a great utility for getting the amount of time that it takes to run a program... However, it doesn't apply at all to this. The time that he is after is the output from STDOUT from tydemux for the delay of audio to properly sync it with the video when remuxing. Thanks for the attempt of help though :)

-Gruph

Actually, I have the output from STDOUT of TYDEMUX passing the properly audio delay to mplex. I was interested in knowing what time the entire process starts, then knowing what time it is when it ends, and then subtracting the two to get the total elapsed time of the conversion. I've tried the commands:

start=`time`;
...
end=`time`;
total=start-end;

but it doesn't seem to work exactly...

oh well, minor issue.

-Jrogers

Superdave
02-11-2003, 11:04 AM
Jroger,

Time will get you the total runtime for any program it prints it to stderr. You should mark your script executable.

chmod +x ty2mpg.sh

Then run your script with the following command to get the total runtime.

time ./ty2mpg.sh file.ty

Here is an example cut and pasted from my linux machine. The line that starts with real is the real time, user is the user cpu time, and sys is the amount of time in kernel.


[danderso@hercules danderso]$ time sleep 50

real 0m50.033s
user 0m0.000s
sys 0m0.000s
[danderso@hercules danderso]$

Enigma
02-11-2003, 02:42 PM
If you are looking to generate a Unix-style timestamp (number of seconds since 1-1-70, used quite a bit by the Tivo) in a shell script you can do something like this:


THISVAR=$(date +%s)

For example, at the time of this post it would output '1044990023'. If you get a start and end time for your script you can do a $end-$start to get the total script run time (although as many people have pointed out, the time utility does a good job of that).