Skip to content

Commit

Permalink
Modify comskip_wrapper.sh. Add CM cut and concat function by ffmpeg.
Browse files Browse the repository at this point in the history
  • Loading branch information
hiroyuki nagata committed Nov 17, 2013
1 parent 6fd19af commit c675b07
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions misc/comskip_wrapper.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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}`
Expand Down Expand Up @@ -74,7 +74,7 @@ do
done

i=0
CUT_FILE_LIET=()
CUT_FILE_LIST=()

for _END__TIME in ${_END__TIME_ARRAY[@]}; do

Expand All @@ -83,16 +83,24 @@ 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 <input_data> -ss <start_sec> -t <play_time> <output_data>
${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

#
# concat CM cut files
#
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
Expand All @@ -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}

0 comments on commit c675b07

Please sign in to comment.