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 not embedded as expected #7909

Closed
forthrin opened this issue Dec 19, 2015 · 4 comments
Closed

Subtitles not embedded as expected #7909

forthrin opened this issue Dec 19, 2015 · 4 comments

Comments

@forthrin
Copy link

@forthrin forthrin commented Dec 19, 2015

youtube-dl -c -f hls-2364 --all-subs --embed-subs https://tv.nrk.no/serie/tara-og-vegard/MYNT16000115/sesong-1/episode-1

Subtitles are not embedded into the .mp4 file as expected. The following vague error message is given, though no obvious errors can be seen when examining the .ttml file.

ERROR: file:Bestegirlza-MYNT16000115.no.ttml: Invalid data found when processing input
@dstftw
Copy link
Collaborator

@dstftw dstftw commented Dec 19, 2015

Post the full output of youtube-dl when run with --verbose option.

@yan12125
Copy link
Collaborator

@yan12125 yan12125 commented Dec 19, 2015

ffmpeg does not support embedding TTML subtitles, so you need to convert them to srt or other ffmpeg-compatible formats first. However, TTML conversion in youtube-dl is broken for this case:

$ youtube-dl -v -f hls-2364 --write-sub --sub-format ttml --convert-subtitles srt --embed-subs https://tv.nrk.no/serie/tara-og-vegard/MYNT16000115/sesong-1/episode-1
[debug] System config: []
[debug] User config: []
[debug] Command-line args: ['-v', '-f', 'hls-2364', '--write-sub', '--sub-format', 'ttml', '--convert-subtitles', 'srt', '--embed-subs', 'https://tv.nrk.no/serie/tara-og-vegard/MYNT16000115/sesong-1/episode-1']
[debug] Encodings: locale UTF-8, fs utf-8, out UTF-8, pref UTF-8
[debug] youtube-dl version 2015.12.18
[debug] Git HEAD: 016dd82
[debug] Python version 3.5.1 - Linux-4.3.2-1-ARCH-x86_64-with-arch-Arch-Linux
[debug] exe versions: ffmpeg 2.8.3, ffprobe 2.8.3, rtmpdump 2.4
[debug] Proxy map: {}
[NRKTV] MYNT16000115: Downloading webpage
[NRKTV] MYNT16000115: Downloading f4m manifest
[NRKTV] MYNT16000115: Downloading m3u8 information
[info] Writing video subtitles to: Bestegirlza-MYNT16000115.no.ttml
[debug] Invoking downloader on 'http://nordond7b-f.akamaihd.net/i/wo/open/7d/7d4b00863c1c5230af1f364d92a9ed15db68b65a/dcbe7d41-010f-42c3-956e-94656a3141f2_,141,316,563,1266,2250,.mp4.csmil/index_4_av.m3u8?null='
[download] Bestegirlza-MYNT16000115.mp4 has already been downloaded
[download] 100% of 103.45MiB
[ffmpeg] Converting subtitles
WARNING: You have requested to convert dfxp (TTML) subtitles into another format, which results in style information loss
Traceback (most recent call last):
  File "<string>", line 27, in <module>
  File "/home/yen/Executables/Multimedia/youtube-dl/youtube_dl/__init__.py", line 410, in main
    _real_main(argv)
  File "/home/yen/Executables/Multimedia/youtube-dl/youtube_dl/__init__.py", line 400, in _real_main
    retcode = ydl.download(all_urls)
  File "/home/yen/Executables/Multimedia/youtube-dl/youtube_dl/YoutubeDL.py", line 1675, in download
    url, force_generic_extractor=self.params.get('force_generic_extractor', False))
  File "/home/yen/Executables/Multimedia/youtube-dl/youtube_dl/YoutubeDL.py", line 674, in extract_info
    return self.process_ie_result(ie_result, download, extra_info)
  File "/home/yen/Executables/Multimedia/youtube-dl/youtube_dl/YoutubeDL.py", line 720, in process_ie_result
    return self.process_video_result(ie_result, download=download)
  File "/home/yen/Executables/Multimedia/youtube-dl/youtube_dl/YoutubeDL.py", line 1345, in process_video_result
    self.process_info(new_info)
  File "/home/yen/Executables/Multimedia/youtube-dl/youtube_dl/YoutubeDL.py", line 1657, in process_info
    self.post_process(filename, info_dict)
  File "/home/yen/Executables/Multimedia/youtube-dl/youtube_dl/YoutubeDL.py", line 1721, in post_process
    files_to_delete, info = pp.run(info)
  File "/home/yen/Executables/Multimedia/youtube-dl/youtube_dl/postprocessor/ffmpeg.py", line 500, in run
    srt_data = dfxp2srt(f.read())
  File "/home/yen/Executables/Multimedia/youtube-dl/youtube_dl/utils.py", line 2026, in dfxp2srt
    end_time = begin_time + parse_dfxp_time_expr(para.attrib['dur'])
TypeError: unsupported operand type(s) for +: 'float' and 'NoneType'

There are two lines with invalid timestamps in the downloaded file:

      <p begin="00:00:46.080" dur="00:00:-46.-380" style="left">Dagene bestod av antidepressiva,<br />skolen, hat mot meg selv og andre.</p>
      <p begin="655:35:00.-296" dur="00:00:00.000" style="left">Jeg kranglet med foreldrene mine<br />og låste meg inne på rommet.</p>

youtube-dl should tolerate it.

@yan12125
Copy link
Collaborator

@yan12125 yan12125 commented Dec 19, 2015

Invalid timestamps in TTML are ignored now. In the next version you can embed subtitles with the following command:

$ youtube-dl -v -f hls-2364 --write-sub --sub-format ttml --convert-subtitles srt --embed-subs https://tv.nrk.no/serie/tara-og-vegard/MYNT16000115/sesong-1/episode-1
@PacoH
Copy link

@PacoH PacoH commented Jul 24, 2018

Thanks! I had the same problem. --convert-subtitles srt worked without --sub-format ttml. So did --convert-subs, which is from the man page.

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

Successfully merging a pull request may close this issue.

None yet
4 participants
You can’t perform that action at this time.