Transform a path returned by dlgopen

Dlgopen return a full path to selected file. I need to transform it because for instance the subtitles argument will fail with normal syntax.

ffmpeg -i "E:\path\to\source file.mkv" -vf "subtitles=D:\path\to sub\source file.ass" "E:\path\to\source file_transcode.mkv"

Only this will work properly "subtitles='C\:\\Path\\To\\Subtitle\\file name with space.ass'"

It seems the only way would be writing a script because even if this command below would work, the format would still be wrong because I need to escape the colon C\:

@set sub={dlgopen|select sub|*.srt;*.ass;*.ssa} 


It would be great if a command like rename could handle any string source like {$sub} here, give the pattern to search and replacement.

off-topic question: You probably want to use this for other file types, or maybe you really want to burn in subtitles but MKV can already embed subtitles by simple remuxing, i.e. without transcoding. I prefer MKVToolnix but ffmpeg can remux, too. Remuxing would save you a lot of time.

It’s an edge case when I really want to burn in sub for short video. I guess it would be a feature of my needed ffmpeg script on my todo list.

1 Like

You could prompt for a filename to be typed on its own, but there's no way to make dlgopen return just a name.

If you prompt for a file using dlgopen, then returning just the name doesn't usually make sense as nothing stops the user from selecting a file in a completely different directory.

Using scripting is your best bet, and will probably make other things easier in the long run, once you get to the complexity of requesting multiple files, escaping some of the paths, and building them into a complex command line.

You could even have a script dialog that tells you if it found the subtitle file automatically (based on the chosen video file) while letting you click a button to change or define it when needed, as well as any other options you need.

1 Like