• AnyStream is having some DRM issues currently, Netflix is not available in HD for the time being.
    Situations like this will always happen with AnyStream: streaming providers are continuously improving their countermeasures while we try to catch up, it's an ongoing cat-and-mouse game. Please be patient and don't flood our support or forum with requests, we are working on it 24/7 to get it resolved. Thank you.

Subtitles

Hmmm, I found an issue with my settings and removed it.
But with the new setting I'm not sure which subtitle is played when multipe forced are in the stream. Probably the first one available :confused:
Need to find a way to mark the correct forced language as default ...
 
Hmmm, I found an issue with my settings and removed it.
But with the new setting I'm not sure which subtitle is played when multipe forced are in the stream. Probably the first one available :confused:
Need to find a way to mark the correct forced language as default ...

This is why all media files on my NAS have any forced subtitles burnt in (the pristine ones are backed up). I got sick of dealing with different players having different behavior.
 
Hmmm, I found an issue with my settings and removed it.
But with the new setting I'm not sure which subtitle is played when multipe forced are in the stream. Probably the first one available :confused:
Need to find a way to mark the correct forced language as default ...

It depends of your player. I use kodi and in the settings I select the forced sub and for the audio my language. if there are 3 forced subtitles (normally one per language) It selects automatically the good forced subtitles corresponding to my language preference.
 
It depends of your player. I use kodi and in the settings I select the forced sub and for the audio my language. if there are 3 forced subtitles (normally one per language) It selects automatically the good forced subtitles corresponding to my language preference.
Wow, thanks, I didn't even think of that ... I always marked my native forced subtitles default, but now I realise I didn't have to :banghead::thankyou:

Well, that makes all way easier, and you likely only need to feed Staxrip the mp4-file with embedded subtitles.
... which has another advantage ... all the subtitles still have the correct name tag:
2022-03-20%2017_51_58.png

At least for Netflix that works really good ... need to test other providers

So basically you feed your whole downloads folder(s) into Staxrip and you end up with perfectly remuxed and force-flagged MKV files in the (thats the flaw: only a single one) output folder
 
So, if I understand you correctly, when it assigns the track name, you want it to strip-off the language code and the period after it?

Just wanted to check to see if this was possible. If not, I'm good that way it is. I really appreciate you helping me out with everything. You did a bang up job.
 
Just wanted to check to see if this was possible. If not, I'm good that way it is. I really appreciate you helping me out with everything. You did a bang up job.

I have some ideas, but it's going to have to wait for the weekend.

I'm thinking of adding delimiters to the patterns to indicate what part should be used for the track name. For example, your first pattern would become "{LNG}.<forced>" to tell the script you only want "forced" in the name.
 
Last edited:
I have some ideas, but it's going to have to wait for the weekend.

I'm thinking of adding delimiters to the patterns to indicate what part should be used for the track name. For example, your first pattern would become "{LNG}.<forced>" to tell the script you only want "forced" in the name.

No worries. Take your time. Appreciate the effort. :)
 
No worries. Take your time. Appreciate the effort. :)

OK, give this version a try. I added logic so you can specific what part of the pattern to use for the subtitles track name. For example, the pattern for your forced tracks is now, "{LNG}.<forced>". So, it will look for a file called "NAME.en.forced.srt" and set it's track name to "forced". I did the same for "cc".

The track language is now set based on the language being processed.


Code:
@:: batch file to convert mp4 files to mkv
@echo off
setlocal EnableExtensions EnableDelayedExpansion

:: languages
set "langs=en eng"

:: subtitles file patterns
:: use "{LNG}" for the language code
:: use '<' and '>' to bracket the section to use for the track name
set "subpats={LNG}.<forced> {LNG} {LNG}-us {LNG}.<cc> {LNG}-us.<cc>"

:: separator (characters between title and subtitles pattern
set "subsep=."

:: location of mvkmerge
set "mkvmerge=C:\Program Files\MKVToolNix\mkvmerge.exe"

:: output subdirectory
set "outdir=Anystream\mkv"

:: escapes brackets in subpats for proper processing
set "subpats=%subpats:<=^<%"
set "subpats=%subpats:>=^>%"

:: if there are no arguments, process the directory containing the script
if "%~1" == "" (
  call :DIR "%~dp0"
  goto :DONE
)

:: iterator through command line arguments
:CMDS
set "curr=%~1"

if "%curr%" == "" goto :DONE

:: ensure current arg exists
if not exist "%curr%" goto :EOF

:: determine if current arg is a dir or a file
pushd "%curr%" >NUL 2>&1
if ERRORLEVEL 1 (
  call :FILE "%curr%"
) else (
  call :DIR "%curr%"
)

shift
goto :CMDS

:DIR
echo recursing %1...
for /r %%i in ("*.mp4") do call :FILE "%%~i"
popd
goto :EOF

:FILE
:: ignore non-mp4 files
if /i "%~x1" NEQ ".mp4" goto :EOF

echo processing %1
pushd "%~dp1"
mkdir "%outdir%" >NUL 2>&1

:: process subtitles
set subs=
for %%L in (%langs%) do (
  for %%P in (%subpats%) do (
  set opts=

  :: substitute current language into pattern
  set pat=%%P
  set "pat=!pat:{LNG}=%%L!"
 
  :: remove brackets for file name
  set "file=!pat:<=!"
  set "file=!file:>=!"
  set "file=%~n1%subsep%!file!.srt"
 
  :: remove text around brackets (inclusive) for track name
  set "track="
   echo "!pat!" | find "<" > NUL 2>&1
   if not ERRORLEVEL 1 (
  set "track=!pat:*<=!"
  set "track2=!track:*>=!"
  call set "track=%%track:>!track2!=%%"
  )
 
  :: if file exist, process it
  if exist "!file!" (
  echo found subtitles file: "!file!"

  :: check for "forced" in subtitle file name
  echo !file! | find /i "forced" > NUL 2>&1
  if ERRORLEVEL 1 (
  set "opts=!opt! --language 0:%%L --default-track 0:0 --forced-track 0:0 --track-name ^"0:!track!^""
  ) else (
  set "opts=!opt! --language 0:%%L --default-track 0:1 --forced-track 0:1 --track-name ^"0:!track!^""
  )

  :: add new subtitles file to list 
  set "subs=!subs! !opts! ^"!file!^""
  )
  )
)

echo calling "%mkvmerge%" --default-language en -o "%outdir%\%~n1.mkv" "%~nx1" %subs%
"%mkvmerge%" --default-language en -o "%outdir%\%~n1.mkv" "%~nx1" %subs%
popd
goto :EOF

:DONE
echo Done.
pause
 
Last edited by a moderator:
OK, give this version a try. I added logic so you can specific what part of the pattern to use for the subtitles track name. For example, the pattern for your forced tracks is now, "{LNG}.<forced>". So, it will look for a file called "NAME.en.forced.srt" and set it's track name to "forced". I did the same for "cc".

The track language is now set based on the language being processed.


Code:
@:: batch file to convert mp4 files to mkv
@echo off
setlocal EnableExtensions EnableDelayedExpansion

:: languages
set "langs=en eng"

:: subtitles file patterns
:: use "{LNG}" for the language code
:: use '<' and '>' to bracket the section to use for the track name
set "subpats={LNG}.<forced> {LNG} {LNG}-us {LNG}.<cc> {LNG}-us.<cc>"

:: separator (characters between title and subtitles pattern
set "subsep=."

:: location of mvkmerge
set "mkvmerge=C:\Program Files\MKVToolNix\mkvmerge.exe"

:: output subdirectory
set "outdir=Anystream\mkv"

:: escapes brackets in subpats for proper processing
set "subpats=%subpats:<=^<%"
set "subpats=%subpats:>=^>%"

:: if there are no arguments, process the directory containing the script
if "%~1" == "" (
  call :DIR "%~dp0"
  goto :DONE
)

:: iterator through command line arguments
:CMDS
set "curr=%~1"

if "%curr%" == "" goto :DONE

:: ensure current arg exists
if not exist "%curr%" goto :EOF

:: determine if current arg is a dir or a file
pushd "%curr%" >NUL 2>&1
if ERRORLEVEL 1 (
  call :FILE "%curr%"
) else (
  call :DIR "%curr%"
)

shift
goto :CMDS

:DIR
echo recursing %1...
for /r %%i in ("*.mp4") do call :FILE "%%~i"
popd
goto :EOF

:FILE
:: ignore non-mp4 files
if /i "%~x1" NEQ ".mp4" goto :EOF

echo processing %1
pushd "%~dp1"
mkdir "%outdir%" >NUL 2>&1

:: process subtitles
set subs=
for %%L in (%langs%) do (
  for %%P in (%subpats%) do (
  set opts=

  :: substitute current language into pattern
  set pat=%%P
  set "pat=!pat:{LNG}=%%L!"

  :: remove brackets for file name
  set "file=!pat:<=!"
  set "file=!file:>=!"
  set "file=%~n1%subsep%!file!.srt"

  :: remove text around brackets (inclusive) for track name
  set "track="
   echo "!pat!" | find "<" > NUL 2>&1
   if not ERRORLEVEL 1 (
  set "track=!pat:*<=!"
  set "track2=!track:*>=!"
  call set "track=%%track:>!track2!=%%"
  )

  :: if file exist, process it
  if exist "!file!" (
  echo found subtitles file: "!file!"

  :: check for "forced" in subtitle file name
  echo !file! | find /i "forced" > NUL 2>&1
  if ERRORLEVEL 1 (
  set "opts=!opt! --language 0:%%L --default-track 0:0 --forced-track 0:0 --track-name ^"0:!track!^""
  ) else (
  set "opts=!opt! --language 0:%%L --default-track 0:1 --forced-track 0:1 --track-name ^"0:!track!^""
  )

  :: add new subtitles file to list
  set "subs=!subs! !opts! ^"!file!^""
  )
  )
)

echo calling "%mkvmerge%" --default-language en -o "%outdir%\%~n1.mkv" "%~nx1" %subs%
"%mkvmerge%" --default-language en -o "%outdir%\%~n1.mkv" "%~nx1" %subs%
popd
goto :EOF

:DONE
echo Done.
pause

Prelim testing works perfectly. If I come across any glitches or weirdness I'll let you know. But so far *chef's kiss*.
 
Last edited:
Disregard. So far everything is great.
 
Last edited:
Back
Top