この動画では、自動生成された字幕の作成プロセスが紹介されています。まず、MP4ビデオクリップからフレームが抽出され、GPT-4 Vision APIを使用してそれらのフレームを要約し、説明を生成します。次に、OpenAI TTS APIを使ってこれらの説明を音声に変換し、MP3ファイルに保存され、最終的にMP4ファイルと結合されて新しい音声オーバーが作成されます。また、AI搭載のビデオエディタであるCapCutの使用法も解説されており、これを使って簡単に高品質なビデオを作成できます。動画では、Pythonスクリプトを使った字幕生成の詳細も説明され、実際にいくつかのビデオクリップでこのスクリプトを実行し、その効果を検証しています。
公開日:2023年11月17日
※動画を再生してから読むのがオススメです。
さあ、行くぞ。
忍び寄るグリム。
緊張が走る。
一人発見、バム、ヘッドショット。
もう一人発見。
容赦ない。
やばい、倒れた。
ファゼクランがクリンチ。
恍惚の表情。
勝利の歓声。
観客は熱狂。
なんともエキサイティングな瞬間だ。
さっきのカウンターストライクの解説は、ビデオファイルを入力するだけで自律的に生成されたんだ。
その方法をお見せしよう。
まず、システムのフローチャートを見てみよう。
左上にあるように、MP4ビデオクリップを入力します。
そのビデオクリップから、設定したフレーム数を抽出します。
これは30でも60でも構いません。
これらのフレームはベース64エンコーディングに変換されます。
このエンコーディングによって、各フレームを取り出し、すべてのフレームの要約のようなものを作成することができます。
このサマリーはgp4 vision APIを使って、収集したすべてのフレームの完全な説明を作成することができる。
この説明はOpenAI TTS APIに渡されます。
私たちはこの説明を、いくつかのプロンプトエンジニアリングでナレーションになるように調整します。
TTS APIからのこの説明はMP3ファイルとして保存されます。
そうでしょう?
そしてMP4ファイルとMP3ファイルをマージします。
そして最終的に、gp4 vision APIで作成された新しい種類のナレーションが入ったビデオが完成します。
しかし、この仕組みをお見せする前に、今日のスポンサーであるcapcut onlineをちょっと見てみましょう。
コンテンツクリエイターとして、私はワークフローをよりスムーズで効率的にしてくれるツールを常に探しています。
だからこそ、capcut onlineのビデオエディターを紹介できることをとても嬉しく思っています。
革新的な機能
capcut onlineのAI搭載マジックツールについてお話ししましょう。
このスイート機能は、手間をかけずにハイクオリティなビデオを作成したい人にとって、画期的なものです。
ベテランのクリエイターでも、これから始めるクリエイターでも、これらのツールは編集プロセスを簡素化するので、クリエイティビティにより集中することができます。
標準機能として、capcut online script to videoがあります。
プロンプトを入力するだけで、capcut onlineがすぐに使えるスクリプトを作成し、著作権に準拠したビデオを生成します。
また、capcut onlineの長尺動画から短尺動画への変換機能を使えば、長尺コンテンツをTikTokのようなプラットフォームに最適な魅力的な短尺動画に簡単に変換することができます。
この機能は、コンテンツを再利用し、異なるソーシャルメディアチャンネルでより多くの視聴者にリーチするのに理想的です。
これらの素晴らしい機能はすべて、ワンクリックでご利用いただけます。
以下の説明のリンクをクリックし、今日からオンラインでcapcutを使い始め、AIを搭載したツールの数々を探求してみてください。
YouTube、TikTok、またはその他のプラットフォーム用にプロ並みのビデオを作成するのが、かつてないほど簡単になりました。
さて、動画に戻りましょう。
最初に紹介するのは、フレームを抽出する機能です。
ここでフレーム間隔を設定します。
私は60に設定しています。
つまり、1秒ごとに1フレームを取り出します。
つまり、10秒のビデオなら10フレームになります。
そしてここに、動画の継続時間を取得する関数があります。
これは動画の長さを知りたいので、プロンプトで調整するためです。
これからそれをお見せします。
ここで画像を64進エンコードする。
これはとても簡単だ。
そして、フレームの説明を取得します。
ここでgpt-4 Vision APIを紹介します。
トークンの最大値を2,000に設定し、温度を追加しました。
今はゼロにしていますが、これを1に設定すれば、よりクリエイティブで異なる出力を得ることができます。
サーバーエラーの試行もここに入れて、リトライ機能のようなものです。
これがナレーション作成機能です。
OpenAIのTTSモデルを使い、Echoという声を選びました。
そうですね、選べる声はいくつかありますが、多くはありません。
ここではMoviePを使って音声とビデオを統合します。
MP3とMP4ですね。
そしてここで、ビデオパスを設定します。
これがMP4ファイルです。
UIを作るのが面倒くさかったんだ。
でも、今はこうしておこう。
そして実行しよう。
というのも、プロンプト・エンジニアリングとでも呼べるようなことをやったからだ。
単語数が表示されています。
これは、ビデオ全体の中で何語言って欲しいかということです。
例えば、1秒間に2ワード、あるいは2.5ワードとします。
つまり、動画の長さを2倍します。
ビデオが10秒だとします。
文字数は25文字です。
単語数を表示します。
この動画は秒数しかありません。
つまり、10秒、10秒の長さです。
ですから、ナレーションは単語数以下でなければなりません。
つまり、25ワードとします。これが最初のプロンプトのようなものです。
そして、各ビデオにパーソナライズされたプロンプトを用意します。
会話形式で、OpenAIのチュートリアルガイドのように振る舞います。
ナレーションに適したフレームで、何が起きているのかを段階的に説明します。
そして、最後にこのような指示プロンプトを追加します。
これが最終的なプロンプトです。
これをVISのAPIモデルに入力します。
そしてMP3ファイルを取り出し、ビデオを取り出し、それらをマージします。
元のクリップにMP3ファイルを追加することもできます。
Pythonスクリプトの詳細が少し出てきましたが、では、いろいろなビデオクリップで動かしてみて、どんなクールなものができるか見てみましょう。
まずはesportsの映像から。
これはリーグ・オブ・レジェンドのようなものです。
音はなく、映像だけです。
このゲームでペンタをキルしたプレイヤーの映像です。
だから、ここで何が起こっているのか、すべてわかると思う。
それで、このファイルを使おうと思ったんだ。
これはlol.MP4というファイルなので、lolにします。
出力ファイルは、例えばLeague of Legends 2.MP4とします。
そして、プロンプトを変更しましょう。
リーグ・オブ・レジェンドの魅力的なコメンテーターとして、短い会話形式で演じてください。
ナレーションに適したフレームで何が起こっているかを説明してください。
オーケー、これだけです。
では、これを実行して、どのような結果が得られるか見てみましょう。
この右側を見てください、今は抽出されたフレームがありません。
しかし、これを実行すると、必要なフレームがすべて抽出されるのがわかりますね?
ワード数は35。
40、14秒です。
15フレームを抽出しました。
では、どんなナレーションができるか見てみましょう。
説明文をご覧ください。
これで合うかな?
どうかな。
やってみましょう。
では、ここを見てみましょう。
ああ、ベースはカオスだ。
ダブルキル、容赦なく追い詰める。
トリプル・キル。
クアドラキル、栄光のためにもう1つ。
ペンタキル、信じられない。
まあ、悪くはなかったが、ちょっとタイミングを逃したのがわかるだろう。
実際に起こる3秒前にペンタキルと表示されたんだ。
だから、そういうこともあるんだ。
フレームキャプチャーのレベルを上げてみたら、少しはマシになった。
でも、動画の長さや単語数を調整することもできるんだ。
だから、多少の調整は必要だけど、かなりうまくいったよ。
次のクリップに進みましょう。
次のクリップは、OpenAIのプレイグラウンドに行ったところです。
クリックしまくって、アシスタントを作ろうとしたんだ。
名前をつけて、指示を出して、モデルを選んで。
そして、このプレイグラウンド・ウィンドウの中でモデルを動かしてみました。
では、これにボイスオーバーを加えてみましょう。
OpenAIのチュートリアルガイドとして、会話のようなスタイルで、フレームの中で何が起こっているのかをステップごとに説明します。
動画の長さを決めます。
2.5秒にしましょう。
なかなか良かったと思います。
このまま60フレームでいこう。
そして、28秒、70ワード、29フレームを見ることができるように実行しましょう。
オーケー、オーケー、ではチェックしてみましょう。
OpenAIのプレイグラウンドへようこそ。
ここでは新しいアシスタントを作成します。
まず、プロジェクトに名前を付け、わかりやすくするためにtutorialと入力します。
次に、チュートリアルに役立つアシスタントのタスクを説明する指示を与えます。
次にモデルを選択し、高度な機能で知られる最新のGPT-4を選択します。
モデルがセットされたので、対話の準備ができた。
アシスタントをテストするための簡単なプロンプト、say hiを入力します。
そうです。
そう、"say hi "だ。
と言うのです。
アシスタントはハイと返事をします。
いや、"こんにちは "と答える。
しかし、完璧なタイミングだ。
OpenAIの基本的なアシスタントをプレイグラウンドにセットアップすることに成功しました。
今やインタラクションの可能性は無限大だ。
このAIができることを探求してみよう。
わあ、すごい。
詳細が間違ってた。
GPT-4の最新モデルって書いてあったんだけど。
でも、名前とか、入力とか、反応とか、そういう細かいところは間違ってた。
でも大丈夫。
とても良かったと思う。
クールでしょ?
では、別のクリップに移って、最終的なプロンプトを少し変えてみましょう。
Netflixシリーズからこんなクリップを見つけました。
これは自然の映像です。
シベリアトラが雪の上を歩いています。
そして最後にはカラスが登場します。
そこで私が選んだプロンプトは、デヴィッド・アッテンボローのような自然ドキュメンタリーのコメンテーターとして、会話形式で演じるというものでした。
ボイスオーバーの前に、フレームの中で起こっていることを説明してください。
オーケー、これはまだテストしたことがないんだ。
どうなるか見てみましょう。
では、実行してみましょう。
17秒です。
完璧です。
フレームが出てきました。
はい、177フレームが抽出されました。
単語数は43前後です。
だから、43語以上はいらない。
それでいい。
では、説明文をご覧ください。
正直なところ、かなり正確だと思います。
デービッド・アッテンボロー風だ。
では、聴いてみましょう。
よし、これだ。
タイガー2
夜明けの静寂の中、雄大なトラが雪に覆われた森の中をそっと歩く。
その縞模様は静謐な白とは対照的だ。
野生の耐久力の象徴であるトラは、目的と力を持って動いている。
広大な荒野の中の孤独な姿。
ああ、よかっただろ?
カラスのことは書いてなかったけど、なかなか良かったと思うよ。
デヴィッド・アッテンボローのドキュメンタリーを思い出したよ。
だからすごく好きなんだ。
この上に音楽とかを追加して、どれだけ良くなるか見てみよう。
では、BGMを追加してみました。
それでは聴いてみましょう。
こっちの方がずっといいと思う。
夜明けの静まり返った光の中、雪に覆われた森の中を雄大な虎がそっと駆けていく。
その縞模様は緑の白とは対照的だ。
野生の耐久力の象徴であるトラは、目的と力を持って動いている。
広大な荒野の中の孤独な姿。
ああ、かなり満足だ。
カッコイイだろ?
さて、私に言わせれば、なかなかクールなプロジェクトだった。
もしコードに興味があるなら、説明文の下の方に僕のYouTube会員へのリンクがある。
会員になればGitHubにアクセスできる。
だから、これをGitHubにアップロードするよ。
それから、CapCutのオンライン・チェックもお忘れなく。
ご視聴ありがとうございました。
それではまた次回。