VideoHelp Forum
+ Reply to Thread
Results 1 to 7 of 7
Thread
  1. Member
    Join Date
    Feb 2021
    Location
    Sweden
    Search Comp PM
    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:
    Code:
    yt-dlp -F $VIDEOURL
    2) Run the download itself to get the video at the wanted resolution with embedded audio
    It uses the syntax:
    Code:
    getvideo <output filename> <video URL> <video quality>
    Snippet from the script:
    Code:
    COMMAND="yt-dlp -f $QUALITY -o $TARGETFILE $VIDEOURL"
    ...
    eval "$COMMAND"
    Note that the $QUALITY variable holds 2 different parts for video and audio quality separated by + like this:

    Code:
    hls-1557+hls-AAC-190-2ch-Svenska
    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...

    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?
    Last edited by BosseB; 18th May 2024 at 04:12. Reason: Adding forgotten comment
    Quote Quote  
  2. Member
    Join Date
    Apr 2007
    Location
    Australia
    Search Comp PM
    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
    This is a copied, modified & pasted command line to add the subs. It's wrapped up in a batch file. I end up with an mkv.
    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.
    Quote Quote  
  3. Member
    Join Date
    Feb 2021
    Location
    Sweden
    Search Comp PM
    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...
    Quote Quote  
  4. Hello:
    1. 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
    2. 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).
    3. 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
    4. 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"
    Quote Quote  
  5. Member
    Join Date
    Feb 2021
    Location
    Sweden
    Search Comp PM
    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.
    Quote Quote  
  6. Member
    Join Date
    Jul 2009
    Location
    United States
    Search Comp PM
    Did you try the --embed-subs option?
    Quote Quote  
  7. Member
    Join Date
    Feb 2021
    Location
    Sweden
    Search Comp PM
    Originally Posted by zing269 View Post
    Did you try the --embed-subs option?
    Yes, but that did not work..
    No subtitles appeared.

    But when I used this I got some subtitles included:
    Code:
    --write-subs
    Quote Quote  



Similar Threads

Visit our sponsor! Try DVDFab and backup Blu-rays!