VideoTrim
詳細とオプション
- VideoTrimを使うと,録画の関心部分を抽出したり関心がない部分を削除したりできる.
- VideoTrimは$WolframDocumentsDirectoryの"Video"ディレクトリに新たな動画を置く.
- 時間 t は以下のいずれでもよい.
-
t 秒で与えられる時間 Quantity[t,"unit"] 秒と互換の"unit"で与えられる時間 Quantity[t,"Frames"] フレーム数で与えられる時間 - デフォルトで,VideoTrimは新規動画を$WolframDocumentsDirectoryの"Video"ディレクトリに置く.
- 次は,指定可能なオプションである.
-
AudioEncoding Automatic 使用する音声符号化 CompressionLevel Automatic 使用する圧縮レベル GeneratedAssetFormat Automatic 結果のファイル形式 GeneratedAssetLocation $GeneratedAssetLocation 生成したデジタルアセットの場所 OverwriteTarget Automatic 既存のファイルに上書きするかどうか SubtitleEncoding Automatic 使用する字幕符号化 VideoEncoding Automatic 使用する動画符号化 VideoTransparency False 出力動画が透明度チャンネルを持つべきかどうか
例題
すべて開く すべて閉じる例 (1)
スコープ (7)
v = Video["ExampleData/Caminandes.mp4"];
Duration[v]VideoTrim[v, 10]Duration[%]VideoTrim[Video["ExampleData/Caminandes.mp4"], -10]VideoTrim[Video["ExampleData/Caminandes.mp4"], {10, 20}]有効なQuantityを使ってカットする:
VideoTrim[Video["ExampleData/Caminandes.mp4"], Quantity[0.8, "Minutes"]]Duration[%]VideoTrim[Video["ExampleData/Caminandes.mp4"], {{10, 20}, {40, 50}}]v = Video["ExampleData/Caminandes.mp4"];
QuantityMagnitude[Duration[v], "Seconds"]VideoTrim[Video["ExampleData/Caminandes.mp4"], {10, -10}]//Durationv = Video["http://exampledata.wolfram.com/agent327.mp4"]VideoTrim[v, 10]カットされた動画はローカル動画オブジェクトとして保存される点に注意のこと:
Information[%, "ResourcePath"]アプリケーション (3)
音声トラックをインポートし,AudioLocalMeasurementsを使って音声のコンテンツの周波数が最高になる時間を見付ける:
v = Video["ExampleData/Caminandes.mp4"];hfc = AudioLocalMeasurements[Audio[v], "HighFrequencyContent", PartitionGranularity -> Quantity[250, "Milliseconds"]];
ListLinePlot[hfc, PlotRange -> All]t = MaximalBy[Normal[hfc], Last][[1, 1]]VideoTrim[v, t + {-3, 3}]v = Video["ExampleData/Caminandes.mp4"]constantQ[img_] := Boole[Abs[Subtract@@MinMax[img]] < .1]VideoMapTimeSeriesを使ってこの関数を各フレームに適用し,結果をプロットする:
ts = VideoMapTimeSeries[constantQ[#Image]&, v];
ListLinePlot[ts]int = #[[{1, -1}, 1]] -> #[[1, 2]]& /@ SplitBy[Normal[ts], Last]roi = MaximalBy[Select[int, #[[2]] == 0&], Abs[Subtract@@#[[1]]]&][[1, 1]]VideoTrim[v, roi]VideoTrimを使って動画ファイルをより小さい部分に分割する:
v = Video["ExampleData/Caminandes.mp4"];
dur = QuantityMagnitude[Duration[v], "Seconds"]partitions = Partition[Range[0, dur, 20], 2, 1]vlist = VideoTrim[v, #]& /@ partitions分割された各部分について,フレームごとの平均強度を計算してプロットする:
ListLinePlot[VideoMapTimeSeries[ImageMeasurements[#Image, "MeanIntensity"]&, #]& /@ vlist, PlotLegends -> Range[Length[vlist]]]特定のセグメントについてフレームあたりの平均強度値を分析する:
seg = vlist[[3]];ts = VideoMapTimeSeries[ImageMeasurements[#Image, "Mean"]&, seg];ListLinePlot[ts, PlotStyle -> {Red, Green, Blue}]特定のセグメントの動画フレームにエッジ検出を適用して新しい動画を生成する:
VideoFrameMap[EdgeDetect, seg]特性と関係 (4)
要求された時間が動画の継続時間を超えている場合は,使用可能なデータだけが返される:
v = Video["ExampleData/Caminandes.mp4"];
dur = QuantityMagnitude[Duration[v], "Seconds"]VideoTrim[v, dur + 10]//DurationVideoTrim[v, -(dur + 10)]//Durationv = Video["ExampleData/Caminandes.mp4"];
Information[v, "VideoTracks"]trimmed = VideoTrim[v, 5];
Information[trimmed, "VideoTracks"]符号化変更の際にすべての特性を保持することは常に可能ではない:
v = Video["ExampleData/Caminandes.mp4"];
Information[v, "AudioTracks"]音声符号化の中には特定のサンプルレートをサポートするものがある:
trimmed = VideoTrim[v, 5, AudioEncoding -> "LIBOPUS"];
Information[trimmed, "AudioTracks"]カットした動画を作成するときは,RasterSizeのような動画オプションとトラック選択オプションが使われる.デフォルトのオプション設定がない動画オブジェクトを作る:
v = Video["ExampleData/bullfinch.mkv", SoundVolume -> .5, AudioTrackSelection -> 2, RasterSize -> 100, ImageSize -> 50];trimmed = VideoTrim[v, 2];Import[Information[#, "ResourcePath"], "RasterSize"]& /@ {v, trimmed}Import[Information[#, "ResourcePath"], "AudioTrackCount"]& /@ {v, trimmed}Options[trimmed, {SoundVolume, ImageSize}]関連するガイド
-
▪
- 動画編集 ▪
- 動画計算機能の更新履歴 ▪
- 動画処理
テキスト
Wolfram Research (2020), VideoTrim, Wolfram言語関数, https://reference.wolfram.com/language/ref/VideoTrim.html (2021年に更新).
CMS
Wolfram Language. 2020. "VideoTrim." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2021. https://reference.wolfram.com/language/ref/VideoTrim.html.
APA
Wolfram Language. (2020). VideoTrim. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/VideoTrim.html
BibTeX
@misc{reference.wolfram_2026_videotrim, author="Wolfram Research", title="{VideoTrim}", year="2021", howpublished="\url{https://reference.wolfram.com/language/ref/VideoTrim.html}", note=[Accessed: 12-July-2026]}
BibLaTeX
@online{reference.wolfram_2026_videotrim, organization={Wolfram Research}, title={VideoTrim}, year={2021}, url={https://reference.wolfram.com/language/ref/VideoTrim.html}, note=[Accessed: 12-July-2026]}