From c675b079d0e701b91f0e1dc4d136e0d96f64ed1e Mon Sep 17 00:00:00 2001 From: hiroyuki nagata Date: Sun, 17 Nov 2013 23:51:47 +0900 Subject: [PATCH] Modify comskip_wrapper.sh. Add CM cut and concat function by ffmpeg. --- misc/comskip_wrapper.sh | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/misc/comskip_wrapper.sh b/misc/comskip_wrapper.sh index 94c68e5..cc745af 100755 --- a/misc/comskip_wrapper.sh +++ b/misc/comskip_wrapper.sh @@ -29,7 +29,7 @@ INIFILE=$1 TS_FILE=$2 export LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:/usr/local/lib -#${COMSKIP} ${OPTIONS} --ini=${INIFILE} ${TS_FILE} +${COMSKIP} ${OPTIONS} --ini=${INIFILE} ${TS_FILE} FEXT="${TS_FILE##*.}" FILE_NAME=`basename ${TS_FILE} ${FEXT}` @@ -74,7 +74,7 @@ do done i=0 -CUT_FILE_LIET=() +CUT_FILE_LIST=() for _END__TIME in ${_END__TIME_ARRAY[@]}; do @@ -83,8 +83,16 @@ for _END__TIME in ${_END__TIME_ARRAY[@]}; do FILE_PARTS=${i} echo "${FFMPEG} -y -i ${TS_FILE} -c copy -ss ${_END__TIME} -t ${BEGIN_TIME} -sn `pwd`/${FILE_NAME}-${FILE_PARTS}.ts" CUT_FILE_LIST+=(`pwd`/${FILE_NAME}-${FILE_PARTS}.ts) + + # convert time from 1970-01-01 00:00:00(UNIX Time) + DATE_YMD=`date '+%Y/%m/%d'` + TIME_BEGIN=`date -d "${DATE_YMD} ${BEGIN_TIME}" "+%s"` + TIME__END_=`date -d "${DATE_YMD} ${_END__TIME}" "+%s"` + DIFF_SEC=`expr ${TIME__END_} - ${TIME_BEGIN}` + PLAY_TIME=`echo | awk -v D=${DIFF_SEC} '{printf "%02d:%02d:%02d",D/(60*60),D%(60*60)/60,D%60}'` # ffmpeg -i -ss -t - ${FFMPEG} -y -i ${TS_FILE} -c copy -ss ${_END__TIME} -t ${BEGIN_TIME} -sn `pwd`/${FILE_NAME}-${FILE_PARTS}.ts + echo "${FFMPEG} -y -i ${TS_FILE} -c copy -ss ${BEGIN_TIME} -t ${PLAY_TIME} -sn `pwd`/${FILE_NAME}-${FILE_PARTS}.ts" + ${FFMPEG} -y -i ${TS_FILE} -c copy -ss ${BEGIN_TIME} -t ${PLAY_TIME} -sn `pwd`/${FILE_NAME}-${FILE_PARTS}.ts done # @@ -92,7 +100,7 @@ done # FFMPEG_CONCAT_STR="concat:" i=0 -for FILE in ${CUT_FILE_LIET[@]}; do +for FILE in ${CUT_FILE_LIST[@]}; do if test ${i} != 0; then FFMPEG_CONCAT_STR=${FFMPEG_CONCAT_STR}"|" fi @@ -102,4 +110,4 @@ done OUTPUT_FILE="`pwd`/CUT-${FILE_NAME}ts" echo "${FFMPEG} -i \"${FFMPEG_CONCAT_STR}\" -c copy ${OUTPUT_FILE}" -${FFMPEG} -i \"${FFMPEG_CONCAT_STR}\" -c copy ${OUTPUT_FILE} +${FFMPEG} -i "${FFMPEG_CONCAT_STR}" -c copy ${OUTPUT_FILE} \ No newline at end of file