commit 8243427cf64937a94cb81ad8b3b7c6b548ff93b1
parent 2a4265931b861ce6ffbee7781c3b7f9a99acc3b4
Author: minerva-jupiter <ryouturn@gmail.com>
Date: Wed, 26 Nov 2025 16:22:10 +0900
add mov2mp4(hevc)
Diffstat:
| A | mov2mp4.py | | | 88 | +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
1 file changed, 88 insertions(+), 0 deletions(-)
diff --git a/mov2mp4.py b/mov2mp4.py
@@ -0,0 +1,88 @@
+import glob
+import os
+import subprocess
+
+
+def convert_mov_to_mp4_h265_nvenc(input_dir, output_dir=None):
+ # 入力フォルダーの存在を確認
+ if not os.path.isdir(input_dir):
+ print(f"エラー: 入力フォルダー '{input_dir}' が見つかりません。")
+ return
+
+ # 出力フォルダーを設定。指定がなければ入力フォルダーと同じ
+ if output_dir is None:
+ output_dir = input_dir
+
+ # 出力フォルダーが存在しない場合は作成
+ if not os.path.exists(output_dir):
+ os.makedirs(output_dir)
+ print(f"出力フォルダー '{output_dir}' を作成しました。")
+
+ # .movファイルを検索
+ search_path = os.path.join(input_dir, "*.mov")
+ mov_files = glob.glob(search_path)
+
+ if not mov_files:
+ print(f"'{input_dir}' 内に .mov ファイルが見つかりませんでした。")
+ return
+
+ print(f"--- 変換処理を開始します (合計 {len(mov_files)} ファイル) ---")
+
+ converted_count = 0
+
+ for input_file_path in mov_files:
+ file_name_without_ext = os.path.splitext(os.path.basename(input_file_path))[0]
+ output_file_name = file_name_without_ext + ".mp4"
+ output_file_path = os.path.join(output_dir, output_file_name)
+
+ ffmpeg_command = [
+ "ffmpeg",
+ "-i",
+ input_file_path,
+ "-c:v",
+ "hevc_nvenc",
+ "-y",
+ output_file_path,
+ ]
+
+ print(
+ f"\n✅ 変換中: '{os.path.basename(input_file_path)}' -> '{os.path.basename(output_file_path)}'"
+ )
+
+ try:
+ subprocess.run(
+ ffmpeg_command,
+ check=True,
+ stdout=subprocess.PIPE,
+ stderr=subprocess.PIPE,
+ encoding="utf-8",
+ )
+ print(" ✨ 変換成功。")
+ converted_count += 1
+ except subprocess.CalledProcessError as e:
+ print(f" ❌ エラーが発生しました: '{os.path.basename(input_file_path)}'")
+ print(
+ f" FFmpeg出力:\n{e.stderr}..."
+ ) # エラーメッセージの最初500文字を表示
+ except FileNotFoundError:
+ print(
+ " ❌ エラー: FFmpegがインストールされていないか、PATHが通っていません。"
+ )
+ return # FFmpegが見つからない場合は処理を中断
+
+ print(f"\n--- 処理完了: {converted_count} 個のファイルが正常に変換されました ---")
+
+
+# --- 以下を convert.py の一番下に追加してください ---
+
+# 変換対象のフォルダーパス
+INPUT_FOLDER = r"E:\Pictures\他人作品\ホロ\2025112602"
+
+# 変換後のファイルを保存するフォルダーパス (NoneにするとINPUT_FOLDERと同じになります)
+# OUTPUT_FOLDER = None
+OUTPUT_FOLDER = r"E:\Pictures\他人作品\ホロ\2025112602"
+
+if __name__ == "__main__":
+ # Windowsの場合、パスは r"C:\Users\User\Videos" のように記述すると安全です
+ # Mac/Linuxの場合、パスは "/Users/user/Movies/Source" のように記述します
+ convert_mov_to_mp4_h265_nvenc(INPUT_FOLDER, OUTPUT_FOLDER)