Sign up ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. It's 100% free, no registration required.

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 "$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 is only run once even if $tempedlfile contains more than one line; the only exception is if the line "$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

1 Answer 1

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.