Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Subtitles when using downloading -d flag #136

Open
sisyphus-kh opened this issue Jul 2, 2023 · 4 comments
Open

Subtitles when using downloading -d flag #136

sisyphus-kh opened this issue Jul 2, 2023 · 4 comments

Comments

@sisyphus-kh
Copy link

sisyphus-kh commented Jul 2, 2023

When using the -d with -l for the subtitles it should download the subtitles along with the movie/tv show

I've tried to add that feature but sometime it works and sometimes it doesn't, the problem appear to have something to do with having multiple subtitle links for one episode or movie

image

I think when adding the -l flag & -d the script should download the a subtitle file as the mp4 file

@justchokingaround
Copy link
Owner

this can be implemented, it would result in an ffmpeg that looks something like this:

ffmpeg -i input.mp4 -i english.vtt -i german.vtt \
-map 0:v -map 0:a -map 1 -map 2 \
-c:v copy -c:a copy -c:s srt \
-metadata:s:s:0 language=eng -metadata:s:s:1 language=ger \
output.mkv

the only issue at hand is parsing the subs etc to extract all of this information, as well as downloading each sub. i will look into implementing this. the resulting file would have in the .mkv format, since i don't think other formats can be used with embeded subtitles. it is up to the user to then convert the .mkv into a .mp4, there's a section for it in the wiki

@sisyphus-kh
Copy link
Author

I was thinking something along the lines of downloading the subtitles along with the movie/tv show, I have solved the issue with my simple solution and it looks like this (ps: I'm new to scripting sorry for any mistakes)

download_video() {
  yt-dlp "$1" --fragment-retries infinite -N 16 -o "$3/$2".mp4
  sub_link=$(echo "$subs_links" | tr -d '\\' | sed -n 's/\(http[s]\?:\/\/[^:]\+\).*/\1/p')
  [ -n "$sub_link" ] && curl "$sub_link" -o "$3/$2.vtt"
}

@justchokingaround
Copy link
Owner

what should the behavior then be, if there are many subtitle tracks? you would download all of them to the current directory? if i implement everything programmatically, you end up with one .mkv file that contains subs inside of it, which can toggled on/off

@sisyphus-kh
Copy link
Author

I guess I haven't thought that there would be many subtitle tracks, embedding makes more sense now. the above code just download the first subtitle track if there two English ones for example

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants