Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @echo off
- :: define suffix and language , for other languages, use 3-letter stream-representaion of language like eng for english,
- :: kor for korean , jpn for japanese and so on...
- set "srt_output_suffix=_synced"
- set "lang=eng"
- set "srt_output_suffix_eng=_%lang%%srt_output_suffix%"
- set "srt_extention=.srt"
- for /f "delims=" %%a in ("%~1") do set "Extension_1=%%~xa"
- for /f "delims=" %%a in ("%~1") do set "file_1_name=%%~na"
- for /f "delims=" %%a in ("%~2") do set "Extension_2=%%~xa"
- for /f "delims=" %%a in ("%~2") do set "file_2_name=%%~na"
- For %%A in ("%~1") do (
- Set file_1_p=%%~dpA
- Set file_1_p_full=%%~A
- )
- For %%A in ("%~2") do (
- Set file_2_p=%%~dpA
- Set file_2_p_full=%%~A
- )
- if %Extension_1%==%srt_extention% (
- ffprobe -show_entries stream=index,codec_type:stream_tags=language -of compact=p=0:nk=1 "%file_2_p_full%" -v 0 | grep %lang% | grep audio > output_audio_index.txt
- type output_audio_index.txt
- set /p audio_index= < output_audio_index.txt
- del output_audio_index.txt
- call :capture
- pause
- )
- if %Extension_2%==%srt_extention% (
- ffprobe -show_entries stream=index,codec_type:stream_tags=language -of compact=p=0:nk=1 "%file_1_p_full%" -v 0 | grep %lang% | grep audio > output_audio_index.txt
- type output_audio_index.txt
- set /p audio_index= < output_audio_index.txt
- del output_audio_index.txt
- call :capture
- pause
- )
- goto:no_srt_found
- :capture
- set /A stream_index=%audio_index:~0,1%
- set /A ffmpeg_index=%audio_index:~0,1% -1
- :: file no audio is found then perform the normal ffs command
- if %stream_index%==-1 (
- echo "No %lang% stream is found..."
- echo "Using default ffs command"
- if %Extension_1%==%srt_extention% (
- ffs "%file_2_p_full%" -i "%file_1_p_full%" -o "%file_1_p%%file_1_name%%srt_output_suffix%.srt"
- echo Done
- pause
- )
- if %Extension_2%==%srt_extention% (
- ffs "%file_1_p_full%" -i "%file_2_p_full%" -o "%file_2_p%%file_2_name%%srt_output_suffix%.srt"
- echo Done
- pause
- )
- ) else (
- echo %lang% stream is found...
- echo Using Stream #0:%stream_index%
- if %Extension_1%==%srt_extention% (
- ffs "%file_2_p_full%" -i "%file_1_p_full%" -o "%file_1_p%%file_1_name%%srt_output_suffix_eng%.srt" --reference-stream a:%ffmpeg_index%
- echo Done
- pause
- )
- if %Extension_2%==%srt_extention% (
- ffs "%file_1_p_full%" -i "%file_2_p_full%" -o "%file_2_p%%file_2_name%%srt_output_suffix_eng%.srt" --reference-stream a:%ffmpeg_index%
- echo Done
- pause
- )
- )
- :no_srt_found
- ::print warning message if no srt file is detected
- echo "no srt file detected"
- pause
Add Comment
Please, Sign In to add comment