トップ 最新 追記

Masa's blog

検索キーワード:

2019年09月26日 How to capture Windows desktop with ffmpeg [長年日記]

_ ffmpeg.exeを使ってWindows10でデスクトップ操作をキャプチャする方法

ffmpeg.exe -y -f gdigrab -framerate 29.97 -i desktop -r 29.97 -c:v h264 -b:v 1000k -pix_fmt yuv420p capture.mp4

2019年09月27日 Script to blur specified rectangle of movie [長年日記]

_ blurmovie.sh - 動画の一部(矩形領域)にボカシを入れるシェルスクリプト

#! /bin/sh
#
if [ "X$1" = "X-h" -o "X$1" = "X--help" ]
then
	echo "Usage: $0 [-s starttime] [-e elapstime] [-r rectangle] [-vc vcodec] [-vb vbitrate] [-ac acodec] [-ab abitrate] [-i input] [-o output]"
	echo "Apply blur effect on specified rectangle of input."
        echo ""
	echo "-s starttime           hh:mm:ss(default 00:00:00)"
	echo "-e elapstime           hh:mm:ss(default 99:00:00)"
	echo "-r rectangle           x:y:width:height:blur"
	echo "-vc vcodec             h264(default), mpeg2video"
	echo "-vb vbitrate           video bitrate(default 1000k)"
	echo "-ac acodec             aac(default), any"
	echo "-ab abitrate           audio bitrate(default 192k)"
        exit 0
fi
#
START="00:00:00"
ELAPS="99:00:00"
X=""
Y=""
WIDTH=""
HEIGHT=""
BLUR=""
VCODEC="h264"
VBITRATE="1000k"
ACODEC="aac"
ABITRATE="192k"
INPUT=""
OUTPUT=""
#
while [ $# -ne 0 ]
do
	case $1 in
	-s)
		shift
		START="$1"
		;;
	-e)
		shift
		ELAPS="$1"
		;;
	-r)
		shift
		X=`echo $1|cut -d: -f1`
		Y=`echo $1|cut -d: -f2`
		WIDTH=`echo $1|cut -d: -f3`
		HEIGHT=`echo $1|cut -d: -f4`
		BLUR=`echo $1|cut -d: -f5`
		;;
	-vc)
		shift
		VCODEC="$1"
		;;
	-vb)
		shift
		VBITRATE="$1"
		;;
	-ac)
		shift
		ACODEC="$1"
		;;
	-ab)
		shift
		ABITRATE="$1"
		;;
	-i)
		shift
		INPUT="$1"
		;;
	-o)
		shift
		OUTPUT="$1"
		;;
	esac
	shift
done
#
if [ "${VCODEC}" = "h264" ]
then
	FFORMAT="mp4"
elif [ "${VCODEC}" = "mpeg2video" ]
then
	FFORMAT="mpegts"
else
	echo "vcodec should be h264 or mpeg2video, aborted."
	exit 1
fi
#
ffmpeg -y \
	-i ${INPUT} \
	-strict -2 \
	-ss ${START} \
	-t ${ELAPS} \
	-c:v ${VCODEC} \
	-b:v ${VBITRATE} \
	-c:a ${ACODEC} \
	-b:a ${ABITRATE} \
	-filter_complex "[0:v]crop=w=${WIDTH}:h=${HEIGHT}:x=${X}:y=${Y},boxblur=lp=${BLUR}[chat];[0:v][chat]overlay=${X}:${Y}" \
	-f ${FFORMAT} \
	${OUTPUT}