[FFmpeg-user] how to programitically close a ffplay event

Jim Shupert, Jr. jshupert at theppsgroup.com
Wed Dec 30 17:52:03 CET 2015


I am suspect that My question here will be judged as to broad or having to
do with a shell script and therefore be dismissed.
But , I am curious for a solution so I will ask anyway.

Any wisdom is welcomed. Thanks in advance.
Yes I realize this is a "hard one" , well-- it has been hard for me. ;)

I wish to loop through a directory of videos and play them in a specific way

( 1-for 5 seconds from the start , 2 then go 1 min deep and play for 5 sec )
my problem is I need to kill ffplay

I am very much able to PLAY in the manner i wish but seem UNABLE  to end a
ffplay event so that it can move forward to the next event.

It seems that ffplay stops at then end of 5 sec and then sits and waits.
If I do a control C in the shell or close the ffplay player only then does
the shell script move on.

You will see where I have tried vatious methods to kill ffplay.

My thought was
play file1 way 1
kill ffplay
play file 1 way 2
kill ffplay
and loop to next file
one thing I wish to populate a var $Myp
with the ffplay process id
I do not seem to be doing that right
Myp=$(ps aux | grep ffplay | grep -v grep | awk '{print $2}')



here is my script

#!/bin/bash
# ~~~~~~~~~~batch
# ~~~~~~~~-
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#-----------------------------------
#################################################################################
#
#
####---FROM < where the avis are . eg /media/data/cap
#Src=/media/data/cap
Src=/home/jshupert/Videos/t
job=playtest

etn=mp4
###--- the dir where the source avi are
cd $Src
echo            $(date)	  
__________________________________________________START_of_SESSIONj >>
~//01_logs/$job.txt
for f in *.$etn ; do

###################################---------  play 1  for 5 sec from top
#./kll.sh
#~/00_script/tst/kll.sh
ffplay -t 00:00:05.000 $Src/$f

#Myp < ps aux | grep ffplay | grep -v grep | awk '{print $2}'

Myp=$(ps aux | grep ffplay | grep -v grep | awk '{print $2}')


### here are my many failed attempts to close so it can go to Next
###sleep 5s
##pkill ffplay
# kill -SIGKILL
#kill -SIGKILL $Myp
#kill -SIGKILL -sigspec $Myp
killall ffplay
echo aaaaaaaaaaaaaaaaaa
echo $Myp

############---test for FF process
FFPLAYStillRunning="true"
    while [ "$FFPLAYStillRunning" = "true" ]; do
        Process=$(ps -C ffplay | grep -o -e "ffplay" )
        if [ -n "$Process" ]; then
            FFPLAYStillRunning="true"
        else
            FFPLAYStillRunning="false"
        fi
        sleep 2s
	done
###################################---------  play 2  for 5 sec from 1 min
deep

##  ./kll.sh &
ffplay -ss 00:01:00.000 -t 00:00:05.000 $Src/$f

sleep 5s
#kill -e -q ffplay
#kill -q ffplay
pkill ffplay
echo bbbbbbbbbbbbbbbbbbbbbbb

##-- rpt size
#vidSize=$(du -h $Src/${f%.*}.$etn)
###vidSize=$(du -h $Src/$f)
echo ${f%.*}	$vidSize ## >> ~//01_logs/$job.txt

echo            $(date)	   ________________________ >> ~//01_logs/$job.txt
echo -- >> ~//01_logs/$job.txt
  echo " -----------------------------------------------------------"
  echo " finished  ----- $f  -----"


##-- make the checksum
###  md5sum -b /home/jshupert/Videos/t/Bug_Love_sjp.mp4 >
/home/jshupert/Videos/t/Bug_Love_sjp.mp4.md5

echo "doing CHKSUM for  $f"
#md5sum -b $Src/${f%.*} > $Src/${f%.*}_.md5
#md5sum -b $Src/${f%.*} > $Src/$f_.md5
#md5sum -b $Src/${f%.mp4} > $Src/$f.md5
md5sum -b $Src/$f > $Src/$f.md5


echo $f		ok checksum  >> ~//01_logs/job_log.txt
echo            $(date)	  >> ~//01_logs/$job.txt





echo $f		$(date)		fin run ALL >> ~//01_logs/$job.txt
echo ------- >> ~//01_logs/$job.txt
echo ------- >> ~//01_logs/$job.txt
echo " -----------------------------------------------------------"
echo " finished $f --------- nnn --------"


#### - end
done



again, thanks for any wisdom

best regards

jim S



More information about the ffmpeg-user mailing list