Skip to content

Instantly share code, notes, and snippets.

@syuhendar729
Created February 9, 2024 16:34
Show Gist options
  • Save syuhendar729/dff004e5f4ac71aa406bcaa2a2d21529 to your computer and use it in GitHub Desktop.
Save syuhendar729/dff004e5f4ac71aa406bcaa2a2d21529 to your computer and use it in GitHub Desktop.
File Script Compress Video MP4 FFMPG
#!/bin/bash
# folder tempat file berada
folder_path="."
# loop melalui setiap file dalam folder
for input_file in "$folder_path"/*.MP4
do
# cek apakah file merupakan file video dengan ekstensi .MP4
if [[ -f "$input_file" ]] && [[ "${input_file##*.}" == "MP4" ]]; then
output_file="${input_file%.*}_compr.MP4"
# cek apakah folder sudah ada file tersebut
if [[ -f "compr/$output_file" ]]; then
echo "File sudah ada di dalam folder."
else
# menjalankan perintah ffmpeg untuk mengonversi file
./ffmpeg.exe -i "$input_file" -vcodec libx265 -crf 28 "compr/$output_file"
fi
fi
done
@echo off
setlocal enabledelayedexpansion
REM folder tempat file berada
set "folder_path=."
REM buat folder kompres jika belum ada
if not exist "compr" mkdir "compr"
REM loop melalui setiap file dalam folder
for %%I in ("%folder_path%\*.MP4") do (
REM cek apakah file merupakan file video dengan ekstensi .MP4
if exist "%%I" (
set "ext=%%~xI"
set "ext=!ext:~1!"
if /I "!ext!" == "MP4" (
set "output_file=%%~nI_compr.MP4"
REM cek apakah file sudah ada di dalam folder
if exist "compr\!output_file!" (
echo File sudah ada di dalam folder.
) else (
REM menjalankan perintah ffmpeg untuk mengonversi file
ffmpeg.exe -i "%%I" -vcodec libx265 -crf 28 "compr\!output_file!"
)
)
)
)
echo Selesai! Semua video dalam folder telah dikompres.
pause
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment