前作ったコマンドをChatGPTで直した
find . -type f -iname "*.MP4" ! -iname "*_FHD.mp4" -print0 |
while IFS= read -r -d '' f; do
out="${f%.*}_FHD.mp4"
echo "変換開始: $f"
if ffmpeg -nostdin -n -i "$f" \
-map 0:v:0 -map '0:a:0?' \
-map_metadata 0 \
-vf "scale=1920:1080:force_original_aspect_ratio=decrease:force_divisible_by=2:flags=fast_bilinear,setsar=1" \
-c:v libx264 -preset veryfast -crf 20 \
-pix_fmt yuv420p -profile:v high -level:v 4.1 \
-r 30000/1001 -fps_mode cfr \
-c:a aac -b:a 192k \
-tag:v avc1 -movflags +faststart \
"$out"; then
touch -r "$f" "$out"
echo "変換完了: $out"
else
echo "変換失敗: $f"
fi
done