Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am trying to make a clip out of video file by playing it only for certain interval.




mplayer -edlout $tmpedlfile "$mediafile" &> /dev/null

cat $tmpedlfile | while read f
    startpos=$(echo $f | awk '{print $1}')
    endpos=$(echo $f | awk '{print $2}')
    length=$(echo "$endpos-$startpos" | bc)

    tmpclip=$(mktemp --suffix='.mclip' --tmpdir=$PWD)
    echo -e "$mediafile_fullpath\t$startpos\t$length" > $tmpclip

    mplayer_clip.sh "$tmpclip" &>/dev/null

    echo -n "clip name : "
    read clipname < /dev/tty

    mv -nv "$tmpclip" "$clipname.mclip"

echo doing rm "$tmpedlfile"



mediafile=$(cat "$@" | awk -F'\t' '{print $1}')
startpos=$(cat "$@" | awk -F'\t' '{print $2}')
length=$(cat "$@" | awk -F'\t' '{print $3}')

mplayer -ss $startpos -endpos $length "$mediafile" &> /dev/null

But for some reason the while loop in make_mclip.sh is only run once even if $tempedlfile contains more than one line; the only exception is if the line

    mplayer_clip.sh "$tmpclip" &>/dev/null

is removed.

Whats wrong ?

ps. I would also like to know if there is already a program for this .

share|improve this question
up vote 1 down vote accepted

mplayer is "consuming" tmpedlfile remaining content. You need to add an option for it not to ignore its stdin:

mplayer -noconsolecontrols -ss $startpos -endpos $length "$mediafile" &> /dev/null
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.