VLC is a completely free, open-source media player that can decode almost any video format, including the HEVC (H.265) files produced by this script. It provides excellent hardware decoding, reliable subtitle support, and works great on both Android and iOS.
VLCã¯å®å šã«ç¡æã®ãªãŒãã³ãœãŒã¹ã¡ãã£ã¢ãã¬ã€ã€ãŒã§ãããã®ã¹ã¯ãªããã§äœæãããHEVCïŒH.265ïŒãã¡ã€ã«ãå«ãã»ãŒãã¹ãŠã®åç»ãåçã§ããŸããããŒããŠã§ã¢ãã³ãŒããšåå¹è¡šç€ºã«åªããAndroidãšiOSã®äž¡æ¹ã§å¿«é©ã«åäœããŸãã
Both scripts require FFmpeg (which includes both ffmpeg and ffprobe) installed and available in your system PATH. Select your operating system below.
ã©ã¡ãã®ã¹ã¯ãªãããFFmpegïŒffmpegãšffprobeã®äž¡æ¹ãå«ãïŒãã·ã¹ãã ã®PATHã«å
¥ã£ãŠããå¿
èŠããããŸãã以äžããOSãéžæããŠãã ããã
The recommended build for Windows is the Gyan.dev full release, which includes all necessary libraries: libass (subtitle rendering), hevc_amf (AMD), hevc_nvenc (NVIDIA), hevc_qsv (Intel), and libx265 (software).
Windowsåãã«ãããããªã®ã¯Gyan.devã®fullãªãªãŒã¹ã§ãå¿ èŠãªã©ã€ãã©ãªïŒlibassãhevc_amfãhevc_nvencãhevc_qsvãlibx265ïŒãå šéšå ¥ã£ãŠããŸãã
Open Command Prompt or PowerShell and run:
ã³ãã³ãããã³ãããŸãã¯PowerShellãéããŠå®è¡ïŒ
winget install Gyan.FFmpeg
After installation, close and reopen your terminal to refresh the PATH, then verify with:
ã€ã³ã¹ããŒã«åŸãã¿ãŒããã«ãéããŠå床éããŠPATHãæŽæ°ãã確èªã³ãã³ããå®è¡ïŒ
ffmpeg -version
winget upgrade Gyan.FFmpeg
wingetã¯Windows 11ã«æåããå
¥ã£ãŠããŠãPATHã®èšå®ãèªåã§ãã£ãŠãããŸããæåã§ã®å±éãç°å¢å€æ°ã®ç·šéãäžèŠãã¢ããããŒããwinget upgrade Gyan.FFmpegã§ç°¡åã§ãã
C:\ffmpeg\.
C:\ffmpeg\ã®ãããªæä¹
çãªå Žæã«å±éã
C:\ffmpeg\bin to your system PATH via System Properties â Environment Variables â Path â Edit â New.
ã·ã¹ãã ã®ãããã㣠â ç°å¢å€æ° â Path â ç·šé â æ°èŠããC:\ffmpeg\binãPATHã«è¿œå ã
ffmpeg -version to confirm.
æ°ããã³ãã³ãããã³ãããéãffmpeg -versionã§ç¢ºèªã
On CachyOS (Arch-based), FFmpeg is available from the official repositories and includes all required encoders and filters â including libass, hevc_nvenc, libx265, and VA-API support.
CachyOSïŒArchããŒã¹ïŒã§ã¯ãFFmpegã¯å ¬åŒãªããžããªããå ¥æã§ããlibassãhevc_nvencãlibx265ãVA-APIãµããŒããªã©å¿ èŠãªãšã³ã³ãŒããŒãšãã£ã«ã¿ãŒããã¹ãŠå«ãŸããŠããŸãã
sudo pacman -S ffmpeg
Verify the install:
ã€ã³ã¹ããŒã«ã確èªïŒ
ffmpeg -version
yay. If you prefer to skip the extra setup, choose option 2 (AMD VA-API) instead â it works out of the box with no additional packages.
ã¹ã¯ãªããã®AMD AMFãšã³ã³ãŒããŒïŒéžæè¢1ïŒã䜿ãå ŽåãAMFã©ã³ã¿ã€ã ã©ã€ãã©ãªãå¿
èŠã§AURããã€ã³ã¹ããŒã«ããå¿
èŠããããŸããã¹ã¯ãªããã¯èªåçã«äžè¶³ãæ€åºããyayã§ã€ã³ã¹ããŒã«ããã確èªããŸãã远å èšå®ãçç¥ãããå Žåã¯éžæè¢2ïŒAMD VA-APIïŒãéžãã§ãã ããã远å ããã±ãŒãžãªãã§åäœããŸãã
/dev/dri/renderD128, which covers most single-GPU systems. If you have both an AMD and an Intel GPU, Intel is usually on renderD129. You can change the VAAPI_DEVICE variable at the top of the script if needed.
ã¹ã¯ãªããã¯ããã©ã«ãã§/dev/dri/renderD128ã䜿çšããŸãïŒã»ãšãã©ã®ã·ã³ã°ã«GPUã·ã¹ãã ã«å¯Ÿå¿ïŒãAMDãšIntelã®GPUãäž¡æ¹ããå ŽåãIntelã¯éåžžrenderD129ã«ãããŸããå¿
èŠã«å¿ããŠã¹ã¯ãªããåé ã®VAAPI_DEVICE倿°ã倿Žã§ããŸãã
Download the script for your operating system and place it directly inside the folder containing your .mkv files. The script will automatically process every single .mkv file in that same folder, so make sure the folder only contains the files you want to convert.
ã䜿ãã®OSã®ã¹ã¯ãªãããããŠã³ããŒãããŠã.mkvãã¡ã€ã«ãå
¥ã£ãŠãããã©ã«ãã«çŽæ¥çœ®ããŠãã ãããã¹ã¯ãªããã¯ãã®ãã©ã«ãå
ã®å
š.mkvãã¡ã€ã«ãèªåçã«åŠçããŸãã倿ããããã¡ã€ã«ã ããã®ãã©ã«ãã«å
¥ããŠãããŠãã ããã
Download encode_hevc.bat and place it in the same folder as your MKV files.
encode_hevc.batãããŠã³ããŒãããŠMKVãã¡ã€ã«ãšåããã©ã«ãã«çœ®ããŠãã ããã
cmd.exe window. Running from PowerShell will cause the loop variables to fail and nothing will encode.
å¿
ãWindowsãšã¯ã¹ãããŒã©ãŒã§ããã«ã¯ãªãã¯ããããcmd.exeãŠã£ã³ããŠããå®è¡ããŠãã ãããPowerShellããå®è¡ãããšã«ãŒã倿°ãæ£ããåããããšã³ã³ãŒãã倱æããŸãã
Download encode_hevc.sh, place it in the same folder as your MKV files, and make it executable:
encode_hevc.shãããŠã³ããŒãããŠMKVãã¡ã€ã«ãšåããã©ã«ãã«çœ®ããå®è¡æš©éãä»äžããŠãã ããïŒ
chmod +x encode_hevc.sh
cd into the folder containing your MKV files before running the script, or open a terminal directly in that folder. The script processes *.mkv in the current working directory.
ã¹ã¯ãªãããå®è¡ããåã«MKVãã¡ã€ã«ãå
¥ã£ãŠãããã©ã«ãã«cdãããããã®ãã©ã«ãã§çŽæ¥ã¿ãŒããã«ãéããŠãã ãããã¹ã¯ãªããã¯ã«ã¬ã³ããã£ã¬ã¯ããªã®*.mkvãåŠçããŸãã
These scripts convert all MKV files in the same folder into smartphone-optimised MP4 files using HEVC (H.265) encoding. They are designed for watching anime and Japanese media on smartphones using a player such as VLC. Both scripts produce identical output â only the platform and available encoders differ.
ãããã®ã¹ã¯ãªããã¯åããã©ã«ãå ã®å šMKVãã¡ã€ã«ãã¹ããŒããã©ã³æé©åMP4ã«äžæ¬å€æããŸããVLCãªã©ã®ãã¬ã€ã€ãŒã§ã¹ããŒããã©ã³äžã§ã¢ãã¡ãæ¥æ¬èªã¡ãã£ã¢ãèŠèŽããããšãç®çãšããŠèšèšãããŠããŸããäž¡ã¹ã¯ãªããã¯åäžã®åºåãçæããŸã â éãã¯ãã©ãããã©ãŒã ãšå©çšå¯èœãªãšã³ã³ãŒããŒã®ã¿ã§ãã
| Settingèšå® | Valueå€ | Notesåè |
|---|---|---|
| Video Codecæ åã³ãŒãã㯠| HEVC / H.265 | Hardware (GPU) or softwareããŒããŠã§ã¢ïŒGPUïŒãŸãã¯ãœãããŠã§ã¢ |
| Video Qualityæ åå質 | QP 31 | Good balance of quality and file sizeå質ãšãã¡ã€ã«ãµã€ãºã®è¯ããã©ã³ã¹ |
| Output Resolutionåºåè§£å床 | 1280Ã720 (16:9) 960Ã720 (4:3) | Auto-detected from sourceãœãŒã¹ããèªåæ€åº |
| Scale Filterã¹ã±ãŒã«ãã£ã«ã¿ãŒ | Lanczos | High-quality downscalingé«å質ããŠã³ã¹ã±ãŒã« |
| Sharpeningã·ã£ãŒããã³ã° | unsharp 3:3:0.3 | Subtle post-downscale crispnessããŠã³ã¹ã±ãŒã«åŸã®è»œåŸ®ãªé®®æå |
| Audio Codecé³å£°ã³ãŒãã㯠| AAC-LC stereo | Universal smartphone compatibilityã¹ããŒããã©ã³ã§åºãäºæ |
| Audio Bitrateé³å£°ãããã¬ãŒã | 128 kbps | Good quality for voice/music on mobileã¢ãã€ã«ã§ã®é³å£°ã»é³æ¥œã«ååãªå質 |
| Audio Tracké³å£°ãã©ã㯠| Japanese (jpn) onlyæ¥æ¬èªïŒjpnïŒã®ã¿ | Auto-selects first/default Japanese trackæå/ããã©ã«ãã®æ¥æ¬èªãã©ãã¯ãèªåéžæ |
| Subtitlesåå¹ | Burned inçŒã蟌㿠| English â default â first (auto fallback)è±èª â ããã©ã«ã â æåïŒèªåãã©ãŒã«ããã¯ïŒ |
| Chaptersãã£ãã¿ãŒ | Preservedä¿æ | Opening/ending markers carried overãªãŒããã³ã°/ãšã³ãã£ã³ã°ããŒã«ãŒãåŒãç¶ã |
| MP4 TagMP4ã¿ã° | hvc1 | Required for Apple device playbackAppleããã€ã¹åçã«å¿ èŠ |
| Faststartãã¡ã¹ãã¹ã¿ãŒã | Enabledæå¹ | Instant playback start, great for Wi-Fi streaming峿åçéå§ãWi-Fiã¹ããªãŒãã³ã°ã«æé© |
| Output Folderåºåãã©ã«ã | encoded_output/ | Created automatically in the script's folderã¹ã¯ãªãããšåããã©ã«ãã«èªåäœæ |
encode_hevc.bat inside the same folder as your MKV files. It will encode every .mkv it finds â the script does not recurse into subfolders.encode_hevc.batãMKVãã¡ã€ã«ãšåããã©ã«ãå
ã«çœ®ããã¹ã¯ãªããã¯ããã«ããå
š.mkvããšã³ã³ãŒãããŸãïŒãµããã©ã«ãã¯åŠçããŸããïŒãencode_hevc.bat in Windows Explorer. A Command Prompt window will open.Windowsãšã¯ã¹ãããŒã©ãŒã§encode_hevc.batãããã«ã¯ãªãã¯ãã³ãã³ãããã³ãããŠã£ã³ããŠãéããŸããencoded_output\ subfolder, ready to transfer to your smartphone.ãšã³ã³ãŒãããããã¡ã€ã«ã¯encoded_output\ãµããã©ã«ãã«ä¿åãããã¹ããŒããã©ã³ãžã®è»¢éæºåãæŽããŸããsudo pacman -S ffmpeg as described above.äžèšã®éãsudo pacman -S ffmpegã§FFmpegãã€ã³ã¹ããŒã«ãencode_hevc.sh inside the same folder as your MKV files and make it executable with chmod +x encode_hevc.sh.encode_hevc.shãMKVãã¡ã€ã«ãšåããã©ã«ãå
ã«çœ®ããchmod +x encode_hevc.shã§å®è¡æš©éãä»äžã./encode_hevc.sh.ãã®ãã©ã«ãã§ã¿ãŒããã«ãéã./encode_hevc.shãå®è¡ãencoded_output/ subfolder, ready to transfer to your smartphone.ãšã³ã³ãŒãããããã¡ã€ã«ã¯encoded_output/ãµããã©ã«ãã«ä¿åãããã¹ããŒããã©ã³ãžã®è»¢éæºåãæŽããŸããWhen you run the script you will see a GPU selection menu. The available options differ slightly between platforms.
ã¹ã¯ãªãããå®è¡ãããšGPUéžæã¡ãã¥ãŒã衚瀺ãããŸããå©çšå¯èœãªéžæè¢ã¯ãã©ãããã©ãŒã ã«ãã£ãŠè¥å¹²ç°ãªããŸãã
Select your GPU / encoder:
1. AMD (hevc_amf - VCE hardware)
2. NVIDIA (hevc_nvenc - NVENC hardware)
3. Intel (hevc_qsv - Quick Sync hardware)
4. Software (libx265 - slow but universal)
| # | Encoderãšã³ã³ãŒã㌠| GPU Requiredå¿ èŠãªGPU | Quality Modeå質ã¢ãŒã | Speedé床 |
|---|---|---|---|---|
| 1 | AMD hevc_amf | AMD RX 400 series or newerAMD RX 400ã·ãªãŒãºä»¥é | CQP 31 | Very fast â¡è¶ é«é â¡ |
| 2 | NVIDIA hevc_nvenc | GTX 950 or newerGTX 950以é | constqp 31 | Very fast â¡è¶ é«é â¡ |
| 3 | INTEL hevc_qsv | Intel 6th gen (Skylake) iGPU or newerIntel第6äžä»£ïŒSkylakeïŒå èµGPU以é | ICQ 31 | Fast â¡é«é â¡ |
| 4 | SOFTWARE libx265 | None â CPU onlyäžèŠ â CPUã®ã¿ | CRF 22 | Slow ð¢äœé ð¢ |
Select your GPU / encoder:
1. AMD (hevc_amf - AMF hardware, fastest)
2. AMD (hevc_vaapi - VA-API hardware, no extra install)
3. NVIDIA (hevc_nvenc - NVENC hardware)
4. Intel (hevc_vaapi - VA-API hardware, no extra install)
5. Software (libx265 - slow but universal)
| # | Encoderãšã³ã³ãŒã㌠| GPU Requiredå¿ èŠãªGPU | Quality Modeå質ã¢ãŒã | Speedé床 |
|---|---|---|---|---|
| 1 | AMD hevc_amf | AMD GPU + AUR packageAMD GPU + AURããã±ãŒãž | CQP 31 | Very fast â¡è¶ é«é â¡ |
| 2 | AMD hevc_vaapi | AMD GPU (no extra packages)AMD GPUïŒè¿œå ããã±ãŒãžäžèŠïŒ | CQP 31 | Very fast â¡è¶ é«é â¡ |
| 3 | NVIDIA hevc_nvenc | GTX 950 or newerGTX 950以é | constqp 31 | Very fast â¡è¶ é«é â¡ |
| 4 | INTEL hevc_vaapi | Intel iGPU (no extra packages)Intelå èµGPUïŒè¿œå ããã±ãŒãžäžèŠïŒ | CQP 31 | Fast â¡é«é â¡ |
| 5 | SOFTWARE libx265 | None â CPU onlyäžèŠ â CPUã®ã¿ | CRF 22 | Slow ð¢äœé ð¢ |
Before encoding, ffprobe reads the stored pixel dimensions and the Sample Aspect Ratio (SAR) to calculate the true display width. It then picks the correct output resolution:
ãšã³ã³ãŒãåã«ffprobeãä¿åããããã¯ã»ã«å¯žæ³ãšãµã³ãã«ã¢ã¹ãã¯ãæ¯ïŒSARïŒãèªã¿åããå®éã®è¡šç€ºå¹
ãèšç®ããŠæ£ããåºåè§£å床ãéžã³ãŸãïŒ
| Display Aspect衚瀺ã¢ã¹ãã¯ã | Outputåºå | Typical Sourceå žåçãªãœãŒã¹ |
|---|---|---|
| 16:9 | 1280Ã720 | BD/HD anime, modern TVBD/HDã¢ãã¡ãçŸä»£ã®TV |
| 4:3 | 960Ã720 | DVD anime, older TV releasesDVDã¢ãã¡ãå€ãTVäœå |
| Otherãã®ä» | auto width à 720èªåå¹ Ã 720 | Fallback for unusual sourcesç¹æ®ãªãœãŒã¹ãžã®ãã©ãŒã«ãã㯠|
language=eng metadata.language=engã¡ã¿ããŒã¿ãæã€åå¹ã¹ããªãŒã ãæ¢ããŸããdisposition:default=1 by the file author.ãã¡ã€ã«äœè
ãdisposition:default=1ãšããŠããŒã¯ããåå¹ãéžæãs:0) regardless of language.æåŸã®ææ®µïŒèšèªã«é¢ä¿ãªãæåã®åå¹ãã©ãã¯ïŒs:0ïŒã䜿çšãIf a file has no subtitle tracks at all, it is skipped with a warning in the console.
åå¹ãã©ãã¯ãå šããªããã¡ã€ã«ã¯èŠåä»ãã§ã¹ããããããŸãã
Only the Japanese (jpn) audio track is mapped to the output â commentary tracks, dubs, and other languages are automatically discarded. The script first looks for a default-flagged Japanese track, then falls back to the first Japanese track. If no Japanese track exists, the first audio track is used with a warning.
æ¥æ¬èªïŒjpnïŒé³å£°ãã©ãã¯ã®ã¿ãåºåã«ãããã³ã°ãããŸããã³ã¡ã³ã¿ãªãŒãã©ãã¯ãå¹ãæ¿ãããã®ä»ã®èšèªã¯èªåçã«é€å€ãããŸãããŸãããã©ã«ããã©ã°ä»ãã®æ¥æ¬èªãã©ãã¯ãæ¢ãããªããã°æåã®æ¥æ¬èªãã©ãã¯ã«ãã©ãŒã«ããã¯ãæ¥æ¬èªãã©ãã¯ãååšããªãå Žåã¯èŠåä»ãã§æåã®é³å£°ãã©ãã¯ã䜿çšãããŸãã
Lanczos scaling â high-quality downscale algorithm that preserves sharpness better than the default bilinear filter. Applied before subtitle burn-in.
ã©ã³ãã§ã¹ããŠã³ã¹ã±ãŒã« â ããã©ã«ãã®ãã€ãªãã¢ãã£ã«ã¿ãŒããé®®æããä¿æããé«å質ããŠã³ã¹ã±ãŒã«ã¢ã«ãŽãªãºã ãåå¹çŒã蟌ã¿åã«é©çšã
Unsharp mask (3:3:0.3) â subtle sharpening applied after scaling to recover crispness lost during downscaling. Conservative values to avoid artefacts.
ã¢ã³ã·ã£ãŒããã¹ã¯ïŒ3:3:0.3ïŒ â ããŠã³ã¹ã±ãŒã«åŸã«å€±ãããé®®æããå埩ããããã®æ§ãããªã·ã£ãŒããã³ã°ãã¢ãŒãã£ãã¡ã¯ããé¿ããããæ§ãããªå€ã«èšå®ã
Subtitle burn-in (hardsubbing) â subtitles are permanently rendered into the video frames using libass, the same renderer used by mpv and VLC. Embedded fonts from the MKV are used automatically.
åå¹çŒã蟌ã¿ïŒããŒããµãïŒ â mpvãVLCãšåãé«å質ã¬ã³ãã©ãŒlibassã䜿ã£ãŠåå¹ãæ åãã¬ãŒã ã«æ°žç¶çã«ã¬ã³ããªã³ã°ãMKVã«åã蟌ãŸãããã©ã³ããèªåçã«äœ¿çšã
Chapters, title metadata, hvc1 tag, and faststart â chapter markers are preserved from the source MKV; the title tag is set from the filename; the hvc1 codec tag ensures correct playback on Apple devices; faststart moves metadata to the front of the file for instant playback.
ãã£ãã¿ãŒãã¿ã€ãã«ã¡ã¿ããŒã¿ãhvc1ã¿ã°ããã¡ã¹ãã¹ã¿ãŒã â ãã£ãã¿ãŒããŒã«ãŒã¯ãœãŒã¹MKVããä¿æãã¿ã€ãã«ã¿ã°ã¯ãã¡ã€ã«åããèšå®ãhvc1ã³ãŒããã¯ã¿ã°ã¯Appleããã€ã¹ã§ã®æ£ããåçã確ä¿ããã¡ã¹ãã¹ã¿ãŒãã¯ã¡ã¿ããŒã¿ããã¡ã€ã«ã®å
é ã«ç§»åããŠå³æåçãå®çŸã
When using a VA-API encoder (options 2 or 4), all filters run on the CPU first. The pipeline converts Hi10P sources to 8-bit (format=yuv420p), then converts to NV12 and uploads frames to the GPU (format=nv12,hwupload) just before the hardware encoder receives them. This is handled automatically â you do not need to change anything.
VA-APIãšã³ã³ãŒããŒïŒéžæè¢2ãŸãã¯4ïŒã䜿çšããå Žåããã¹ãŠã®ãã£ã«ã¿ãŒã¯ãŸãCPUã§å®è¡ãããŸãããã€ãã©ã€ã³ã¯Hi10PãœãŒã¹ã8ãããïŒformat=yuv420pïŒã«å€æããæ¬¡ã«NV12ã«å€æããŠãã¬ãŒã ãGPUã«ã¢ããããŒãïŒformat=nv12,hwuploadïŒããŠããããŒããŠã§ã¢ãšã³ã³ãŒããŒã«æž¡ããŸããããã¯èªåçã«åŠçããããããèšå®å€æŽã¯äžèŠã§ãã
Both scripts are optimised for playback on smartphones using VLC for iOS / Android. Output settings were specifically tested on an iPhone 11 with VLC.
äž¡ã¹ã¯ãªããã¯VLC for iOS / Androidã§ã®ã¹ããŒããã©ã³åçã«æé©åãããŠããŸããåºåèšå®ã¯iPhone 11ã§VLCã䜿ã£ãŠå ·äœçã«ãã¹ããããŠããŸãã
| Device / Appããã€ã¹ / ã¢ã㪠| Compatibilityäºææ§ | Notesåè |
|---|---|---|
| iPhone 11 + VLC | â Excellentåªç§ | Hardware HEVC decode, directly testedããŒããŠã§ã¢HEVCãã³ãŒããçŽæ¥ãã¹ãæžã¿ |
| iPhone 11 + Native Playerãã€ãã£ããã¬ã€ã€ãŒ | â Goodè¯å¥œ | hvc1 tag required (included)hvc1ã¿ã°ãå¿ èŠïŒå«ãŸããŠããŸãïŒ |
| iPhone 12+ | â Excellentåªç§ | Hardware HEVC decodeããŒããŠã§ã¢HEVCãã³ãŒã |
| Android + VLC | â Excellentåªç§ | HEVC hardware decode on most modern Androidæè¿ã®Androidã§HEVCããŒããŠã§ã¢ãã³ãŒã |
| Android Native Galleryãã€ãã£ãã®ã£ã©ãªãŒ | â Variesæ©çš®ã«ãã | Samsung/Pixel generally fineSamsung/Pixelã¯æŠãåé¡ãªã |
yuv420p) ensures correct, vivid colours on all devices with no loss in perceived quality at 720p.
å€ãã®ãœãŒã¹ãã¡ã€ã«ïŒç¹ã«Hi10Pã¢ãã¡ïŒã¯10ãããã«ã©ãŒã§ãšã³ã³ãŒããããŠããŸããæè¡çã«ã¯ãµããŒããããŠããŸãããiPhone 11ãªã©ã®ããã€ã¹ã§VLCçµç±ã§åçãããšè²ãæŽãæµãããããã«è¡šç€ºãããããšããããŸãã8ãããïŒyuv420pïŒã«å€æããããšã§720pã§ã®ç¥èŠå質ãæãªãããšãªãå
šããã€ã¹ã§æ£ç¢ºã§é®®ãããªè²ãä¿èšŒãããŸãã
Copy and paste the code below into a new text file, then save it as encode_hevc.bat. In Notepad, set "Save as type" to "All Files (*.*)" to prevent it saving as .txt.
以äžã®ã³ãŒããã³ããŒããŠæ°ããããã¹ããã¡ã€ã«ã«è²Œãä»ããencode_hevc.batãšããŠä¿åããŠãã ãããã¡ã¢åž³ã§ã¯ããã¡ã€ã«ã®çš®é¡ããããã¹ãŠã®ãã¡ã€ã« (*.*)ãã«å€æŽããŠ.txtãšããŠä¿åãããªãããã«ããŠãã ããã
cmd.exe window. Running from PowerShell will cause the loop variables to fail and nothing will encode.
å¿
ãWindowsãšã¯ã¹ãããŒã©ãŒã§ããã«ã¯ãªãã¯ããããcmd.exeãŠã£ã³ããŠããå®è¡ããŠãã ãããPowerShellããå®è¡ãããšã«ãŒã倿°ãæ£ããåããããšã³ã³ãŒãã倱æããŸãã
@echo off
setlocal enabledelayedexpansion
:: ============================================================
:: Universal MKV â HEVC 8-bit MP4 Batch Encoder
:: Supports: AMD VCE, NVIDIA NVENC, Intel QSV, Software (x265)
:: Audio: First Japanese track only â AAC 128kbps stereo
:: Subtitles: Burned in with fallback priority:
:: 1. English-tagged (eng)
:: 2. Default-flagged subtitle in MKV
:: 3. First available subtitle track
:: 4. Skip file if no subtitles exist
:: Aspect: 4:3 source â 960x720 / 16:9 source â 1280x720
:: Chapters: Preserved
:: Metadata: Title set from filename
::
:: IMPORTANT: Run by double-clicking in Explorer or via cmd.exe
:: Do NOT run from PowerShell.
::
:: Requirements: ffmpeg + ffprobe must be in PATH
:: ============================================================
:: --- SETTINGS -----------------------------------------------
set QP=31
set AUDIO_BITRATE=128k
set OUTPUT_DIR=encoded_output
set SHARPEN=3:3:0.3
:: -------------------------------------------------------
:: ================================================================
:: GPU SELECTION MENU
:: Equivalent quality settings across encoders matching CQP 31:
:: AMD â hevc_amf, -rc cqp qp 31
:: NVIDIA â hevc_nvenc, -rc constqp qp 31
:: Intel â hevc_qsv, -q 31 (ICQ mode)
:: x265 â libx265, -crf 22 (CRF 22 â CQP 31 for HEVC)
:: ================================================================
echo ============================================================
echo Universal HEVC 8-bit Encoder
echo QP=31 Audio=128kbps 4:3=960x720 16:9=1280x720
echo ============================================================
echo.
echo Select your GPU / encoder:
echo.
echo 1. AMD ^(hevc_amf - VCE hardware^)
echo 2. NVIDIA ^(hevc_nvenc - NVENC hardware^)
echo 3. Intel ^(hevc_qsv - Quick Sync hardware^)
echo 4. Software ^(libx265 - slow but universal^)
echo.
set /p GPU_CHOICE=" Enter choice (1-4): "
if "%GPU_CHOICE%" == "1" (
set ENCODER=hevc_amf
set ENC_LABEL=AMD VCE
set ENC_PARAMS=-rc cqp -qp_i %QP% -qp_p %QP% -qp_b %QP% -quality quality -profile:v main -pix_fmt yuv420p
)
if "%GPU_CHOICE%" == "2" (
set ENCODER=hevc_nvenc
set ENC_LABEL=NVIDIA NVENC
set ENC_PARAMS=-rc constqp -qp %QP% -preset p4 -profile:v main -pix_fmt yuv420p
)
if "%GPU_CHOICE%" == "3" (
set ENCODER=hevc_qsv
set ENC_LABEL=Intel Quick Sync
set ENC_PARAMS=-q %QP% -preset slower -profile:v main -pix_fmt nv12
)
if "%GPU_CHOICE%" == "4" (
set ENCODER=libx265
set ENC_LABEL=Software x265
set ENC_PARAMS=-crf 22 -preset slow -profile:v main -pix_fmt yuv420p
)
if not defined ENCODER (
echo.
echo Invalid choice. Please enter 1, 2, 3 or 4.
pause
exit /b 1
)
echo.
echo Using encoder: %ENC_LABEL% ^(%ENCODER%^)
echo Output folder: %OUTPUT_DIR%
echo ============================================================
echo.
if not exist "%OUTPUT_DIR%" mkdir "%OUTPUT_DIR%"
set TMPFILE=%TEMP%\ffprobe_tmp.txt
set ENCODED=0
set FAILED=0
set SKIPPED=0
for %%F in (*.mkv) do (
echo -------------------------------------------------------
echo [%%F] Analysing streams...
:: ================================================================
:: SUBTITLE SELECTION â three-tier fallback
:: ================================================================
set SUB_INDEX=
set SUB_METHOD=
set SUB_REL_COUNTER=0
ffprobe -v error -select_streams s -show_entries stream=index,disposition=default:stream_tags=language -of csv=p=0 "%%F" > "%TMPFILE%" 2>&1
:: ---- Tier 1: English-tagged subtitle ----
for /f "usebackq delims=" %%S in ("%TMPFILE%") do (
if not defined SUB_INDEX (
set LINE=%%S
echo !LINE! | findstr /i ",eng" >nul 2>&1
if !errorlevel! == 0 (
set SUB_INDEX=!SUB_REL_COUNTER!
set SUB_METHOD=English-tagged
)
set /a SUB_REL_COUNTER+=1
) else (
set /a SUB_REL_COUNTER+=1
)
)
:: ---- Tier 2: Default-flagged subtitle ----
if not defined SUB_INDEX (
set SUB_REL_COUNTER=0
for /f "usebackq delims=" %%S in ("%TMPFILE%") do (
if not defined SUB_INDEX (
set LINE=%%S
echo !LINE! | findstr /r ",1," >nul 2>&1
if !errorlevel! == 0 (
set SUB_INDEX=!SUB_REL_COUNTER!
set SUB_METHOD=default-flagged
)
)
set /a SUB_REL_COUNTER+=1
)
)
:: ---- Tier 3: First available subtitle ----
if not defined SUB_INDEX (
for /f "usebackq delims=" %%S in ("%TMPFILE%") do (
if not defined SUB_INDEX (
set SUB_INDEX=0
set SUB_METHOD=first available
)
)
)
:: ================================================================
:: All remaining processing in if/else â no goto inside loop
:: ================================================================
if not defined SUB_INDEX (
echo [%%F] WARNING: No subtitle tracks found. Skipping file.
set /a SKIPPED+=1
) else (
echo [%%F] Subtitle selected: index !SUB_INDEX! ^(!SUB_METHOD!^)
:: ================================================================
:: RESOLUTION â 4:3 â 960x720, 16:9 â 1280x720
:: ================================================================
set STORED_W=
set STORED_H=
set SAR_N=1
set SAR_D=1
ffprobe -v error -select_streams v:0 -show_entries stream=width -of default=nw=1:nk=1 "%%F" > "%TMPFILE%" 2>&1
for /f "usebackq tokens=1" %%V in ("%TMPFILE%") do if not defined STORED_W set STORED_W=%%V
ffprobe -v error -select_streams v:0 -show_entries stream=height -of default=nw=1:nk=1 "%%F" > "%TMPFILE%" 2>&1
for /f "usebackq tokens=1" %%V in ("%TMPFILE%") do if not defined STORED_H set STORED_H=%%V
ffprobe -v error -select_streams v:0 -show_entries stream=sample_aspect_ratio -of default=nw=1:nk=1 "%%F" > "%TMPFILE%" 2>&1
for /f "usebackq tokens=1,2 delims=:" %%A in ("%TMPFILE%") do (
if not "%%A" == "N/A" if not "%%A" == "0" (
set SAR_N=%%A
set SAR_D=%%B
)
)
if "!SAR_D!" == "0" set SAR_D=1
if "!SAR_N!" == "0" set SAR_N=1
set /a DISP_W=!STORED_W! * !SAR_N! / !SAR_D!
set SCALE_FILTER=scale=1280:720:flags=lanczos
set RES_LABEL=1280x720 ^(16:9 default^)
if defined DISP_W if defined STORED_H (
set /a RATIO10=!DISP_W! * 10 / !STORED_H!
if !RATIO10! GEQ 14 (
set SCALE_FILTER=scale=1280:720:flags=lanczos
set RES_LABEL=1280x720 ^(16:9^)
) else (
set SCALE_FILTER=scale=960:720:flags=lanczos
set RES_LABEL=960x720 ^(4:3^)
)
)
echo [%%F] Display: !DISP_W!x!STORED_H! -^> !RES_LABEL!
:: ================================================================
:: JAPANESE AUDIO â find first/default jpn track, map by index
:: ================================================================
set JPN_ABS=
set JPN_REL=0
set JPN_FOUND=
ffprobe -v error -select_streams a -show_entries stream=index,disposition=default:stream_tags=language -of csv=p=0 "%%F" > "%TMPFILE%" 2>&1
:: First pass: default-flagged jpn audio
for /f "usebackq delims=" %%S in ("%TMPFILE%") do (
if not defined JPN_ABS (
set LINE=%%S
echo !LINE! | findstr /i "jpn" >nul 2>&1
if !errorlevel! == 0 (
echo !LINE! | findstr /r ",1" >nul 2>&1
if !errorlevel! == 0 (
for /f "tokens=1 delims=," %%I in ("!LINE!") do set JPN_ABS=%%I
)
)
)
)
:: Second pass: first jpn audio track
if not defined JPN_ABS (
for /f "usebackq delims=" %%S in ("%TMPFILE%") do (
if not defined JPN_ABS (
set LINE=%%S
echo !LINE! | findstr /i "jpn" >nul 2>&1
if !errorlevel! == 0 (
for /f "tokens=1 delims=," %%I in ("!LINE!") do set JPN_ABS=%%I
)
)
)
)
:: Convert absolute index to audio-relative index
if defined JPN_ABS (
set JPN_REL=0
ffprobe -v error -select_streams a -show_entries stream=index -of csv=p=0 "%%F" > "%TMPFILE%" 2>&1
for /f "usebackq delims=" %%S in ("%TMPFILE%") do (
if not defined JPN_FOUND (
for /f "tokens=1 delims=," %%I in ("%%S") do (
if %%I == !JPN_ABS! (
set JPN_FOUND=1
) else if not defined JPN_FOUND (
set /a JPN_REL+=1
)
)
)
)
echo [%%F] Japanese audio: stream !JPN_ABS! ^(audio index !JPN_REL!^)
set JPN_MAP=0:a:!JPN_REL!
) else (
echo [%%F] WARNING: No Japanese audio found, using first audio track.
set JPN_MAP=0:a:0
)
:: ================================================================
:: ENCODE
:: ================================================================
set TITLE=%%~nF
echo [%%F] Starting encode ^(%ENC_LABEL%^)...
ffmpeg -y ^
-i "%%F" ^
-vf "!SCALE_FILTER!,subtitles='%%F':si=!SUB_INDEX!,unsharp=%SHARPEN%" ^
-c:v %ENCODER% ^
%ENC_PARAMS% ^
-tag:v hvc1 ^
-movflags +faststart ^
-c:a aac ^
-b:a %AUDIO_BITRATE% ^
-ac 2 ^
-map 0:v:0 ^
-map !JPN_MAP! ^
-map_chapters 0 ^
-metadata title="!TITLE!" ^
"%OUTPUT_DIR%\%%~nF.mp4"
if !errorlevel! == 0 (
echo [%%F] Done ^> %OUTPUT_DIR%\%%~nF.mp4
set /a ENCODED+=1
) else (
echo [%%F] FAILED - check output above for errors
set /a FAILED+=1
)
)
set JPN_ABS=
set JPN_FOUND=
set STORED_W=
set STORED_H=
set SAR_N=1
set SAR_D=1
echo.
)
if exist "%TMPFILE%" del "%TMPFILE%"
echo ============================================================
echo Finished! Encoder: %ENC_LABEL%
echo Encoded: %ENCODED% Failed: %FAILED% Skipped: %SKIPPED%
echo ============================================================
pause
Copy and paste the code below into a new text file and save it as encode_hevc.sh. Then make it executable with chmod +x encode_hevc.sh.
以äžã®ã³ãŒããã³ããŒããŠæ°ããããã¹ããã¡ã€ã«ã«è²Œãä»ããencode_hevc.shãšããŠä¿åããŠãã ããããã®åŸchmod +x encode_hevc.shã§å®è¡æš©éãä»äžããŠãã ããã
#!/usr/bin/env bash
# ============================================================
# Universal MKV â HEVC 8-bit MP4 Batch Encoder
# Supports: AMD AMF, AMD VA-API, NVIDIA NVENC, Intel VA-API, Software (x265)
# Audio: First Japanese track only â AAC 128kbps stereo
# Subtitles: Burned in with fallback priority:
# 1. English-tagged (eng)
# 2. Default-flagged subtitle in MKV
# 3. First available subtitle track
# 4. Skip file if no subtitles exist
# Aspect: 4:3 source â 960x720 / 16:9 source â 1280x720
# Chapters: Preserved
# Metadata: Title set from filename
#
# Requirements: ffmpeg + ffprobe must be in PATH
# ============================================================
set -euo pipefail
# --- SETTINGS -----------------------------------------------
QP=31
AUDIO_BITRATE=128k
OUTPUT_DIR="encoded_output"
SHARPEN="3:3:0.3"
# ============================================================
echo "============================================================"
echo " Universal HEVC 8-bit Encoder"
echo " QP=31 Audio=128kbps 4:3=960x720 16:9=1280x720"
echo "============================================================"
echo
echo " Select your GPU / encoder:"
echo
echo " 1. AMD (hevc_amf - AMF hardware, fastest)"
echo " 2. AMD (hevc_vaapi - VA-API hardware, no extra install)"
echo " 3. NVIDIA (hevc_nvenc - NVENC hardware)"
echo " 4. Intel (hevc_vaapi - VA-API hardware, no extra install)"
echo " 5. Software (libx265 - slow but universal)"
echo
read -rp " Enter choice (1-5): " GPU_CHOICE
# VA-API render device â /dev/dri/renderD128 covers most single-GPU systems.
# If you have both AMD and Intel GPUs, Intel is usually renderD129.
VAAPI_DEVICE="/dev/dri/renderD128"
case "$GPU_CHOICE" in
1)
ENCODER="hevc_amf"
ENC_LABEL="AMD AMF"
ENC_PARAMS="-rc cqp -qp_i $QP -qp_p $QP -quality quality -profile:v main -pix_fmt yuv420p"
USE_VAAPI=0
# Check for AMF runtime and offer to install if missing
if ! ldconfig -p 2>/dev/null | grep -q "libamfrt64.so" && \
! find /usr/lib /usr/local/lib 2>/dev/null | grep -q "libamfrt64.so"; then
echo
echo " WARNING: AMF runtime (libamfrt64.so) not found."
echo " The package 'amf-amdgpu-pro' is required from the AUR."
echo
read -rp " Install it now via yay? (y/n): " INSTALL_AMF
if [[ "${INSTALL_AMF,,}" == "y" ]]; then
echo
echo " Installing amf-amdgpu-pro..."
if ! command -v yay &>/dev/null; then
echo " ERROR: yay not found. Please install amf-amdgpu-pro manually."
exit 1
fi
yay -S --noconfirm amf-amdgpu-pro
echo " AMF runtime installed."
else
echo
echo " Aborting. Re-run the script and choose option 2 (VA-API) instead,"
echo " which works without any additional packages."
exit 1
fi
fi
;;
2)
ENCODER="hevc_vaapi"
ENC_LABEL="AMD VA-API"
ENC_PARAMS="-rc_mode CQP -qp $QP -profile:v main"
USE_VAAPI=1
;;
3)
ENCODER="hevc_nvenc"
ENC_LABEL="NVIDIA NVENC"
ENC_PARAMS="-rc constqp -qp $QP -preset p4 -profile:v main -pix_fmt yuv420p"
USE_VAAPI=0
;;
4)
ENCODER="hevc_vaapi"
ENC_LABEL="Intel VA-API"
ENC_PARAMS="-rc_mode CQP -qp $QP -profile:v main"
USE_VAAPI=1
;;
5)
ENCODER="libx265"
ENC_LABEL="Software x265"
ENC_PARAMS="-crf 22 -preset slow -profile:v main -pix_fmt yuv420p"
USE_VAAPI=0
;;
*)
echo
echo " Invalid choice. Please enter 1, 2, 3, 4 or 5."
exit 1
;;
esac
echo
echo " Using encoder: $ENC_LABEL ($ENCODER)"
echo " Output folder: $OUTPUT_DIR"
echo "============================================================"
echo
mkdir -p "$OUTPUT_DIR"
TMPFILE="$(mktemp /tmp/ffprobe_tmp.XXXXXX)"
trap 'rm -f "$TMPFILE"' EXIT
ENCODED=0
FAILED=0
SKIPPED=0
shopt -s nullglob
MKV_FILES=(*.mkv)
if [[ ${#MKV_FILES[@]} -eq 0 ]]; then
echo " No .mkv files found in current directory."
exit 0
fi
for FILEPATH in "${MKV_FILES[@]}"; do
FILENAME="$FILEPATH"
BASENAME="${FILEPATH%.mkv}"
echo "-------------------------------------------------------"
echo "[$FILENAME] Analysing streams..."
# ================================================================
# SUBTITLE SELECTION â three-tier fallback
# ================================================================
SUB_INDEX=""
SUB_METHOD=""
ffprobe -v error -select_streams s \
-show_entries stream=index,disposition=default:stream_tags=language \
-of csv=p=0 "$FILENAME" > "$TMPFILE" 2>&1
# ---- Tier 1: English-tagged subtitle ----
SUB_REL_COUNTER=0
while IFS= read -r LINE; do
if [[ -z "$SUB_INDEX" ]]; then
if echo "$LINE" | grep -qi ",eng"; then
SUB_INDEX="$SUB_REL_COUNTER"
SUB_METHOD="English-tagged"
fi
fi
(( SUB_REL_COUNTER++ )) || true
done < "$TMPFILE"
# ---- Tier 2: Default-flagged subtitle ----
if [[ -z "$SUB_INDEX" ]]; then
SUB_REL_COUNTER=0
while IFS= read -r LINE; do
if [[ -z "$SUB_INDEX" ]]; then
if echo "$LINE" | grep -qP ",1,|,1$"; then
SUB_INDEX="$SUB_REL_COUNTER"
SUB_METHOD="default-flagged"
fi
fi
(( SUB_REL_COUNTER++ )) || true
done < "$TMPFILE"
fi
# ---- Tier 3: First available subtitle ----
if [[ -z "$SUB_INDEX" ]] && [[ -s "$TMPFILE" ]]; then
SUB_INDEX=0
SUB_METHOD="first available"
fi
# ================================================================
# Skip if no subtitles found
# ================================================================
if [[ -z "$SUB_INDEX" ]]; then
echo "[$FILENAME] WARNING: No subtitle tracks found. Skipping file."
(( SKIPPED++ )) || true
continue
fi
echo "[$FILENAME] Subtitle selected: index $SUB_INDEX ($SUB_METHOD)"
# ================================================================
# RESOLUTION â 4:3 â 960x720, 16:9 â 1280x720
# ================================================================
STORED_W=""
STORED_H=""
SAR_N=1
SAR_D=1
STORED_W=$(ffprobe -v error -select_streams v:0 \
-show_entries stream=width -of default=nw=1:nk=1 "$FILENAME" 2>/dev/null | head -1)
STORED_H=$(ffprobe -v error -select_streams v:0 \
-show_entries stream=height -of default=nw=1:nk=1 "$FILENAME" 2>/dev/null | head -1)
SAR_RAW=$(ffprobe -v error -select_streams v:0 \
-show_entries stream=sample_aspect_ratio -of default=nw=1:nk=1 "$FILENAME" 2>/dev/null | head -1)
if [[ "$SAR_RAW" != "N/A" && "$SAR_RAW" =~ ^([0-9]+):([0-9]+)$ ]]; then
SAR_N="${BASH_REMATCH[1]}"
SAR_D="${BASH_REMATCH[2]}"
[[ "$SAR_N" == "0" ]] && SAR_N=1
[[ "$SAR_D" == "0" ]] && SAR_D=1
fi
DISP_W=$(( STORED_W * SAR_N / SAR_D ))
SCALE_FILTER="scale=1280:720:flags=lanczos"
RES_LABEL="1280x720 (16:9 default)"
if [[ -n "$DISP_W" && -n "$STORED_H" && "$STORED_H" -gt 0 ]]; then
RATIO10=$(( DISP_W * 10 / STORED_H ))
if [[ "$RATIO10" -ge 14 ]]; then
SCALE_FILTER="scale=1280:720:flags=lanczos"
RES_LABEL="1280x720 (16:9)"
else
SCALE_FILTER="scale=960:720:flags=lanczos"
RES_LABEL="960x720 (4:3)"
fi
fi
echo "[$FILENAME] Display: ${DISP_W}x${STORED_H} -> $RES_LABEL"
# ================================================================
# JAPANESE AUDIO â find first/default jpn track, map by index
# ================================================================
JPN_ABS=""
JPN_REL=0
ffprobe -v error -select_streams a \
-show_entries stream=index,disposition=default:stream_tags=language \
-of csv=p=0 "$FILENAME" > "$TMPFILE" 2>&1
# First pass: default-flagged jpn audio
while IFS= read -r LINE; do
if [[ -z "$JPN_ABS" ]]; then
if echo "$LINE" | grep -qi "jpn"; then
if echo "$LINE" | grep -qP ",1,|,1$"; then
JPN_ABS=$(echo "$LINE" | cut -d',' -f1)
fi
fi
fi
done < "$TMPFILE"
# Second pass: first jpn audio track
if [[ -z "$JPN_ABS" ]]; then
while IFS= read -r LINE; do
if [[ -z "$JPN_ABS" ]]; then
if echo "$LINE" | grep -qi "jpn"; then
JPN_ABS=$(echo "$LINE" | cut -d',' -f1)
fi
fi
done < "$TMPFILE"
fi
# Convert absolute stream index to audio-relative index
if [[ -n "$JPN_ABS" ]]; then
JPN_REL=0
ffprobe -v error -select_streams a \
-show_entries stream=index -of csv=p=0 "$FILENAME" > "$TMPFILE" 2>&1
JPN_FOUND=""
while IFS= read -r LINE; do
IDX=$(echo "$LINE" | cut -d',' -f1)
if [[ "$IDX" == "$JPN_ABS" ]]; then
JPN_FOUND=1
break
fi
(( JPN_REL++ )) || true
done < "$TMPFILE"
echo "[$FILENAME] Japanese audio: stream $JPN_ABS (audio index $JPN_REL)"
JPN_MAP="0:a:$JPN_REL"
else
echo "[$FILENAME] WARNING: No Japanese audio found, using first audio track."
JPN_MAP="0:a:0"
fi
# ================================================================
# ENCODE
# ================================================================
TITLE="$BASENAME"
echo "[$FILENAME] Starting encode ($ENC_LABEL)..."
# Escape the filename for the subtitles filter (colons and special chars)
ESCAPED_PATH=$(printf '%s' "$FILENAME" | sed "s/'/'\\\\''/g; s/:/\\\\:/g")
set +e
if [[ "$USE_VAAPI" -eq 1 ]]; then
# VA-API: CPU-side filters run first. format=yuv420p converts Hi10P
# sources to 8-bit, then format=nv12,hwupload hands frames to the GPU.
# shellcheck disable=SC2086
ffmpeg -y \
-vaapi_device "$VAAPI_DEVICE" \
-i "$FILENAME" \
-vf "${SCALE_FILTER},subtitles='${ESCAPED_PATH}':si=${SUB_INDEX},unsharp=${SHARPEN},format=yuv420p,format=nv12,hwupload" \
-c:v "$ENCODER" \
$ENC_PARAMS \
-tag:v hvc1 \
-movflags +faststart \
-c:a aac \
-b:a "$AUDIO_BITRATE" \
-ac 2 \
-map 0:v:0 \
-map "$JPN_MAP" \
-map_chapters 0 \
-metadata title="$TITLE" \
"${OUTPUT_DIR}/${BASENAME}.mp4"
else
# AMF, NVENC, libx265: format=yuv420p in the filter chain handles
# Hi10P sources by converting to 8-bit before encoding.
# shellcheck disable=SC2086
ffmpeg -y \
-i "$FILENAME" \
-vf "${SCALE_FILTER},subtitles='${ESCAPED_PATH}':si=${SUB_INDEX},unsharp=${SHARPEN},format=yuv420p" \
-c:v "$ENCODER" \
$ENC_PARAMS \
-tag:v hvc1 \
-movflags +faststart \
-c:a aac \
-b:a "$AUDIO_BITRATE" \
-ac 2 \
-map 0:v:0 \
-map "$JPN_MAP" \
-map_chapters 0 \
-metadata title="$TITLE" \
"${OUTPUT_DIR}/${BASENAME}.mp4"
fi
EXIT_CODE=$?
set -e
if [[ $EXIT_CODE -eq 0 ]]; then
echo "[$FILENAME] Done > ${OUTPUT_DIR}/${BASENAME}.mp4"
(( ENCODED++ )) || true
else
echo "[$FILENAME] FAILED - check output above for errors"
(( FAILED++ )) || true
fi
echo
done
echo "============================================================"
echo " Finished! Encoder: $ENC_LABEL"
echo " Encoded: $ENCODED Failed: $FAILED Skipped: $SKIPPED"
echo "============================================================"