Last active
January 14, 2023 10:00
-
-
Save TakamiChie/ee761c6dd8c7b427914073f1098ed1fc to your computer and use it in GitHub Desktop.
ffmpegを使用して動画を切り分ける(まとめ動画作成用)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## Cut and output video files. | |
## $range Specify the range to output. Specify as "Start:Length". | |
## $source The name of the file to read. This parameter is required. | |
## $outfile The name of the file to output. When not specified, it is output to the desktop folder with the file name "outfile.mp4". | |
## ex. movcut "30:10" [filename] | |
function movcut ( | |
[Parameter(mandatory=$true)][ValidatePattern('^[\d\.]+:[\d\.]+$')][String] $range, | |
[Parameter(mandatory=$true)] $source, | |
[Parameter(mandatory=$false)] $outfile="" | |
) { | |
if($outfile -eq ""){ $outfile = [Environment]::GetFolderPath("Desktop") + "\outfile.mp4" } | |
$n = $range -Split ":" | |
ffmpeg -ss $($n[0]) -i ""${source}"" -t $($n[1]) ""${outfile}"" | |
} | |
## Output multiple video files by specifying a partial part of a video file. | |
## $ranges Specify the range to output. Specify it as Start:Length in the array. | |
## $source The name of the file to read. This parameter is required. | |
## $outdir The name of the folder to output. If not specified, it will be output to the desktop folder. | |
## ex. movcuts 20:10,40:10,50:10 -source [filename] | |
function movcuts ( | |
[Parameter(mandatory=$true)][String[]] $ranges, | |
[Parameter(mandatory=$true)] $source, | |
[Parameter(mandatory=$false)] $outdir="" | |
) { | |
if($outdir -eq ""){ $outdir = [Environment]::GetFolderPath("Desktop") } | |
$i = 1 | |
foreach($range in $ranges){ | |
movcut -range $range -source $source -outfile "${outdir}\${i}.mp4" | |
$i++; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
ffmpegへ指定する秒数に小数点を指定できるように変更