VideoHelp Forum




+ Reply to Thread
Results 1 to 3 of 3
  1. Member
    Join Date
    Sep 2004
    Location
    Australia
    Search Comp PM
    I want to automate this so I need a command line method to auto extract all subtitles from a video file like mkv. Not all video contain multiple subtitles so how can I do this?
    Quote Quote  
  2. Member
    Join Date
    Mar 2021
    Location
    Israel
    Search Comp PM
    Check out ffmpeg
    Quote Quote  
  3. Member
    Join Date
    Apr 2007
    Location
    Australia
    Search Comp PM
    I've modified an older batch file I wrote.
    All my mkv videos have .srt subs, so no testing .ass, etc.

    demux-all-subtitle-streams-v01.cmd
    Code:
    @echo off
     if not exist Subs\ md Subs
    for %%a in (*.mkv) do call :process1 "%%a"
    goto :end
    
    :process1
    rem Get a list of streams - pare down to subtitle streams.
    ffmpeg.exe -i "%~1" -y nul 2>&1 | find /i "stream" | find /i "subtitle" >"%~n1.txt"
    
    rem Using the temp file, "%~n1.txt", to set mapping and the output file name.
    for /f "usebackq tokens=1-7 delims=^(^)^:^#^ " %%a in ("%~n1.txt") do (
        setlocal enabledelayedexpansion
        set stream=%%b:%%c
        ffmpeg.exe -i "%~1" -map !stream! -y "Subs\%~n1-%%d.%%g"
    )
    goto :eof
    
    :end
    rem uncomment the next line to delete all temp txt files.
    rem del "*.txt"
    echo. &echo Output is in the Subs\ folder &pause
    Cheers.
    Quote Quote  



Similar Threads

Visit our sponsor! Try DVDFab and backup Blu-rays!