Mrrrr's Forum (VIEW ONLY)
Un forum care ofera solutii pentru unele probleme legate in general de PC. Pe langa solutii, aici puteti gasi si alte lucruri interesante // A forum that offers solutions to some PC related issues. Besides these, here you can find more interesting stuff.
Lista Forumurilor Pe Tematici
Mrrrr's Forum (VIEW ONLY) | Reguli | Inregistrare | Login

POZE MRRRR'S FORUM (VIEW ONLY)

Nu sunteti logat.
Nou pe simpatie:
ciocolata4u pe Simpatie.ro
Femeie
21 ani
Bucuresti
cauta Barbat
24 - 45 ani
Mrrrr's Forum (VIEW ONLY) / Tutoriale si Ghiduri Utile // Tutorials and useful guides / [VIDEO] Extract Subtitles from Video Files with FFMPEG & VBS Moderat de TRaP, TonyTzu
Autor
Mesaj Pagini: 1
Mrrrr
AdMiN

Inregistrat: acum 18 ani
Postari: 2241
The following VBScript will extract the subtitles from the video containers in the current folder, provided that you have the .vbs file and ffmpeg.exe in the folder and that you know the extensions of the video files (mkv, mp4 etc.) and the index of the subtitle you want to extract (2, 3 etc.).

The subtitles will be extracted to SRT.


' Create FileSystemObject
Dim fso
Set fso = CreateObject("Scripting.FileSystemObject")

' Check if ffmpeg.exe exists in the current folder
If Not fso.FileExists(fso.GetAbsolutePathName(".") & "\ffmpeg.exe") Then
    MsgBox "ffmpeg.exe not found in the current folder. Please ensure it is present and try again.", vbExclamation, "File Error"
    WScript.Quit
End If

' Create input dialogs to get user input
Dim extTo, indexTo, lang
extTo = InputBox("Enter the target file extension (e.g., mp4):", "Extension", "mkv")
indexTo = InputBox("Enter the new subtitle map index (e.g., 4):", "Map Index", "3")
lang = InputBox("Enter the language if you want to rename subtitles (e.g., eng):", "Language of Subtitle", "eng")

' if either of them is null or 0, end
If IsEmpty(extTo) Or IsEmpty(indexTo) Then
  MsgBox "You didn't enter a file extension or a map index," & vbCrLf & _
        "or you pressed cancel in either or both InputBox dialogs.", vbExclamation, "Input Error"
  WScript.Quit
End If

If lang <> "" Then
    lang = "_" & lang
End if

' Build batch script content
Dim batContent
batContent = "@echo off" & vbCrLf
batContent = batContent & "for %%f in (*." & extTo & ") do (" & vbCrLf
batContent = batContent & "    echo Processing ""%%f""..." & vbCrLf
batContent = batContent & "    ffmpeg -i ""%%f"" ^" & vbCrLf
batContent = batContent & "    -map 0:" & indexTo & " -c:s srt ""%%~nf""" & lang & ".srt""" & vbCrLf
batContent = batContent & ")" & vbCrLf
batContent = batContent & "pause" & vbCrLf

' Write batch script to a temporary file
'Dim fso
'Set fso = CreateObject("Scripting.FileSystemObject")
Dim batFile
Set batFile = fso.CreateTextFile("extract_subtitles.bat", True)
batFile.Write batContent
batFile.Close

' Execute the batch script
Dim shell
Set shell = CreateObject("WScript.Shell")
shell.Run "cmd /c extract_subtitles.bat", 1, True

' Clean up the batch script file
fso.DeleteFile "extract_subtitles.bat"


Source:
ChatGPT


_______________________________________


pus acum 1 luna
   
Mrrrr
AdMiN

Inregistrat: acum 18 ani
Postari: 2241
This can still be enhanced with more error checking, like what if mkv extension is not found in folder etc.

TBA


_______________________________________


pus acum 1 luna
   
Pagini: 1  

Mergi la