I am using yt-dlp in order to download videos from SVT-Play for later viewing.
But when I do that I do not get the subtitles that appear when playing the video directly on a web browser from the site.
Specifically I have a script running on an Ubuntu 20.04.4 LTS server using yt-dlp and it uses two steps to download:
1) Check the available streams to select the wanted resolution
Here I use the following to list all of the contained streams:
2) Run the download itself to get the video at the wanted resolution with embedded audioCode:yt-dlp -F $VIDEOURL
It uses the syntax:
Snippet from the script:Code:getvideo <output filename> <video URL> <video quality>
Note that the $QUALITY variable holds 2 different parts for video and audio quality separated by + like this:Code:COMMAND="yt-dlp -f $QUALITY -o $TARGETFILE $VIDEOURL" ... eval "$COMMAND"
I just discovered that a video file downloaded like this does not display the subtitles the same way as the video does when played in the browser...Code:hls-1557+hls-AAC-190-2ch-Svenska
Specifically the browser played video switches on subtitles when a person on screen talks in a different language than Swedish, but this is not present in the videos downloaded using the command above.
Most videos I download have English as the foreign language and then I don't notice the lack of the subtitles, but now I encountered a video with French as the foreign language and then I cannot understand the video display...
So I would like to know if it is possible and then how to get the foreign language subtitles added to the output video?
EDIT:
I forgot to say that adding the argument --write-subs to the command only results in a text file with the subtitles being downloaded. When viewing the video with that file present (named as the video but with extension sv.svt) the subtitles appear if the video is locally played with the VLC player but NOT if opened using a browser!
So the video mp4 file itself is unaffected and therefore the text is not visible in a browser.
My question is how to ensure the subtitles are embedded in the mp4 video itself?
Try StreamFab Downloader and download from Netflix, Amazon, Youtube! Or Try DVDFab and copy Blu-rays!
+ Reply to Thread
Results 1 to 7 of 7
Thread
-
Last edited by BosseB; 18th May 2024 at 04:12. Reason: Adding forgotten comment
-
I'm using Windows 10, so your method will be slightly different.
yt-dlp.conf (This is stored in the same directory as yt-dlp.exe)
I also have copies of ffmpeg.exe & ffprobe.exe in the same directory.Code:# Start a line with a hash(#) to comment it out. # __________________________________________________________ # Suppress HTTPS certificate validation --no-check-certificate # Prefer ffmpeg over avconv for postprocessing --prefer-ffmpeg #Write subtitles - order of preference --write-sub --sub-format srt/vtt/best --sub-langs en # Convert the subtitles to another format - if needed. --convert-subs srt #Keep the original subs -k --merge-output-format mp4
Code:ffmpeg.exe" -i "thevideo.mp4" -sub_charenc ISO-8859-1 -i "thevideo.srt" -map 0:0 -map 0:1 -map 1:0 -c:v copy -c:a copy -c:s copy -disposition forced "thevideo.mkv"
Last edited by pcspeak; 19th May 2024 at 04:22.
-
I am not familiar with using the yt-dlp conf file and it seems like it would affect ALL downloads made using yt-dlp, right?
Cannot find it in my Ubuntu server installation, at least not if it is named yt-dlp.conf...
Do I understand this procedure correctly as follows:
1) Download the video using settings in the conf file (they are global, right?)
This will bring down both the video (as an mkv file) and the subtitles (as an srt file)
2) Run ffmpeg towards the downloaded video file to embed the subtitles into it by re-encoding the whole thing.
This ends up again with an mkv file whereas I need mp4 video files for further use.
I have already tried various ffmpeg commands to embed the subtitles but invariably that results in a very lengthy procedure taking like 30 minutes for a 60 minute video.
I was hoping for some way to do it during the download since the video when viewed on-line actually contains the subtitles when people on screen talk in a different language than Swedish (the main language of the video).
I could not understand why the subtitles were not present when I downloaded the video to disk for later viewing.
I assumed I had missed some argument to yt-dlp... -
Hello:
- To download your mp4 video file via yt-dlp please use instructions on https://github.com/mrblomblo/yt-dlp-usage-script?tab=readme-ov-file
- For the config file you can create a new text file in EXE folder, name it yt-dlp.conf and insert the code given by 12pcspeak. You might want to modify the language of the subtitles you need (--sub-langs en).
- To download the subtitles in srt format, use the following code in the command line of EXE folder: Code:
yt-dlp.exe --write-subs --skip-download -N 8 your video file html link
- You can merge your video and the subtitles into one mkv video file using the following code: Code:
ffmpeg.exe" -i "thevideo.mp4" -sub_charenc ISO-8859-1 -i "thevideo.srt" -map 0:0 -map 0:1 -map 1:0 -c:v copy -c:a copy -c:s copy -disposition forced "thevideo.mkv"
-
As I stated above my setup is a set of bash scripts running on an Ubuntu 20.04.4 LTS server...
So any instructions pertaining to Windows are not valid here.
The linked instructions on GitHub also referenced a Windows solution.
And I am looking for a system where the encoding is done during download so as not to waste extra time for a re-make of the entire file. -
Similar Threads
-
i'm downloading a video via m3u8 with yt-dlp
By nammin in forum Video Streaming DownloadingReplies: 1Last Post: 1st Jul 2023, 00:21 -
Downloading a movie from YouTube with yt-dlp
By CrymanChen in forum Video Streaming DownloadingReplies: 0Last Post: 17th Jun 2023, 04:14 -
problem downloading audio format with yt-dlp
By thedebutent59 in forum Video Streaming DownloadingReplies: 1Last Post: 6th Oct 2022, 11:36 -
downloading multiple audio track with yt-dlp
By chisdchisdq in forum Video Streaming DownloadingReplies: 2Last Post: 17th Apr 2022, 04:16 -
Recording and Downloading issues with yt-dlp
By Alan2154 in forum Video Streaming DownloadingReplies: 12Last Post: 9th Nov 2021, 07:38