TopSideControl 11 Posted December 30, 2023 Posted December 30, 2023 I hope this is OK to post here but if not please delete it. I was having an issue with my Samsung tv and files with a large number of embedded subtitles. I know this isn't an Emby issue so I put together a script that runs through my mkv files and remuxes them removing all subs (I'm happy to let Emby grab the subs for me). You need the mkvmerge executable in a folder (sample path below) and it replaces the original files with the modified ones from the temp directory. Save the following as a .bat file and run it in the directory where the media is stored. It should skip any files without subtitles. @echo off set "mkvmerge_path=C:\mkv\mkvmerge.exe" powershell -Command "& { mkdir 'temp' -Force; Get-ChildItem -Filter *.mkv | ForEach-Object { $subtitles = & '%mkvmerge_path%' -i $_.FullName | Select-String 'subtitles'; if ($subtitles) { & '%mkvmerge_path%' -o ('temp\' + $_.Name) --no-subtitles $_.FullName }} }" move /y "temp\*" . rmdir /s /q "temp" 2 1
lolwut 16 Posted April 10 Posted April 10 (edited) Hi, I made a nodejs version of your script that goes also through subfolders. const fs = require('fs'); const path = require("path"); async function searchFile(dir, fileName) { const files = fs.readdirSync(dir); for (const file of files) { const filePath = dir + "/" + file; const fileStat = fs.statSync(filePath); const fpath = path.resolve(filePath); if (fileStat.isDirectory()) { await searchFile(filePath, fileName); } else if (file.endsWith(fileName)) { try{ var execSync = require('child_process').execSync; console.log("Processing " + filePath); let output1 = execSync("C:\\mkv\\mkvmerge.exe -i \"" + fpath + "\""); if (output1.includes("subtitles")) { console.log("Subtitles Found " + filePath); output2 = execSync("C:\\mkv\\mkvmerge.exe -o \"" + fpath + ".temp\" --no-subtitles \"" + fpath + "\""); if(output2.includes("Multiplexing") && fs.existsSync(fpath + ".temp")){ console.log("Subtitles Removed " + filePath); fs.unlinkSync(fpath); console.log("Original File Removed" + filePath); fs.renameSync(fpath + ".temp", fpath); console.log("Process Complete (Subtitles Removed)" + filePath); }else{ console.error('Error ' + filePath + " : " + output2); } } else { console.log('Process Complete (No Subtitles Found) ' + filePath); } }catch(e){ console.error('Error ' + filePath + " : " + e); } } } } searchFile('./', 'mkv'); Save it as javascript file for example mkv.js at base directory of a library Then call node mkv.js You have to have nodejs installed for this to work. Edited April 10 by lolwut fixed script error
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now