Hi all! I'm a beginner, and would like to create a shell script, which will get the length of an avi file, then halves it for cutting with mencoder... here is what i have now: #!/bin/bash for file in /home/mysite/mydomain/myfiles/*.avi do moviedata= mplayer -vo dummy -ao dummy -identify $file 2>/dev/null | perl -nle '/ID_LENGTH=([0-9\.]+)/ && ($t +=$1) && printf "%02d:%02d:%02d",$t/2/3600,$t/2/60%60,$t/2%60' | tail -n 1 mencoder -endpos "$moviedata" -oac copy -ovc copy "$file" -o "$file.splitted.avi" done Code (markup): It is really close to working... if you echo $moviedata, you get the half time in a formatted way, for example: 00:32:22. If i insert it into mencoder, it says "Error parsing option on the command line: -endpos" After that, i echoed the mencoder converter line, and i saw, that the $moviedata variable moved into the beginning of the line: Here is the echoed line: [B]00:51:19[/B]mencoder -endpos -oac copy -ovc copy /home/mysite/mydomain/myfiles/1.avi -o /home/mysite/mydomain/myfiles/1.avi.splitted.avi It should be like this: mencoder [B]-endpos 00:51:19[/B] -oac copy -ovc copy /home/mysite/mydomain/myfiles/1.avi -o /home/mysite/mydomain/myfiles/1.avi.splitted.avi Code (markup): I hope someone can help me to make this script working.
try backticks `mencoder -endpos "$moviedata" -oac copy -ovc copy "$file" -o "$file.splitted.avi"` `mencoder -endpos "${moviedata}" -oac copy -ovc copy "${file}" -o "${file.splitted.avi}"` If you want parse literal quote, I think you need to escape it. which ever works btw there is an easier way to get duration, using ffmpeg ffmpeg -i ${file} 2>&1 | grep "Duration" | cut -d ' ' -f 4 | sed s/,//
`mencoder -endpos "$moviedata" -oac copy -ovc copy "$file" -o "$file.splitted.avi"` `mencoder -endpos "${moviedata}" -oac copy -ovc copy "${file}" -o "${file.splitted.avi}"` Code (markup): Hi, i tried both ways, but itdoesn't work, somehow it still ignores the data. ( $file and $file.splitted avi is accepted, only the $moviedata isn't, kinda weird, i'm sure there is something wrong with serving the variable, not the mencoder command itself) ffmpeg -i ${file} 2>&1 | grep "Duration" | cut -d ' ' -f 4 | sed s/,// Code (markup): Well, the problem with this is that i'm just a beginner... i only want to cut movies to half, so i need to divide the whole lenght of the movie with 2, but i can't do this here because the lack of knowledge . If you can give me an example where i will get the half time of the movie in this format: 01:20:11 (h:m:s) i would be really glad. I really don't know why the first command which i found is not working, i think it is something with serving the moviedata variable, something is wrong with the way i get it, i think.