question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[Site Request] Add subtitles conversion functionality for Bilibili's proprietary subtitle format

See original GitHub issue

Checklist

  • I’m reporting a site feature request
  • I’ve verified that I’m running yt-dlp version 2021.09.02 (I’m using the upstream version of yt-dlp, after the commit of Bilibili international)
  • I’ve searched the bug tracker for similar site feature requests including closed ones

Description

The subtitle of Bilibili is delivered in BCC format (Bilibili proprietary subtitle format, .json). Currently, embedding this format of subtitles cannot be achieved because neither yt-dlp nor ffmpeg has the ability to do so.

The following terminal output can be used as an example.

C:\Users\Tran Bich Dung>yt-dlp https://www.biliintl.com/en/play/37976/10344255 --write-subs --embed-subs --cookies "C:\Users\Tran Bich Dung\Downloads\fd798572-8600-4b99-b54a-ec690f6fc323.txt"
[BiliIntl] 10344255: Downloading JSON metadata
[BiliIntl] 10344255: Downloading JSON metadata
[BiliIntl] 10344255: Downloading JSON metadata
[info] 10344255: Downloading 1 format(s): 6+2
[info] Writing video subtitles to: I'm Luffy! The Man Who Will Become the Pirate King! [10344255].en.json
[download] Destination: I'm Luffy! The Man Who Will Become the Pirate King! [10344255].en.json
[download] 100% of 23.50KiB in 00:00
[info] Writing video subtitles to: I'm Luffy! The Man Who Will Become the Pirate King! [10344255].th.json
[download] Destination: I'm Luffy! The Man Who Will Become the Pirate King! [10344255].th.json
[download] 100% of 36.70KiB in 00:00
[info] Writing video subtitles to: I'm Luffy! The Man Who Will Become the Pirate King! [10344255].vi.json
[download] Destination: I'm Luffy! The Man Who Will Become the Pirate King! [10344255].vi.json
[download] 100% of 25.60KiB in 00:00
[info] Writing video subtitles to: I'm Luffy! The Man Who Will Become the Pirate King! [10344255].id.json
[download] Destination: I'm Luffy! The Man Who Will Become the Pirate King! [10344255].id.json
[download] 100% of 26.75KiB in 00:00
[SubtitlesConvertor] Converting subtitles
[SubtitlesConvertor] You have requested to convert json subtitles into another format, which is currently not possible
[SubtitlesConvertor] You have requested to convert json subtitles into another format, which is currently not possible
[SubtitlesConvertor] You have requested to convert json subtitles into another format, which is currently not possible
[SubtitlesConvertor] You have requested to convert json subtitles into another format, which is currently not possible
[download] Destination: I'm Luffy! The Man Who Will Become the Pirate King! [10344255].f6.mp4
[download] 100% of 131.17MiB in 03:00
[download] Destination: I'm Luffy! The Man Who Will Become the Pirate King! [10344255].f2.mp4
[download] 100% of 23.41MiB in 00:24
[Merger] Merging formats into "I'm Luffy! The Man Who Will Become the Pirate King! [10344255].mkv"
Deleting original file I'm Luffy! The Man Who Will Become the Pirate King! [10344255].f6.mp4 (pass -k to keep)
Deleting original file I'm Luffy! The Man Who Will Become the Pirate King! [10344255].f2.mp4 (pass -k to keep)
ERROR: 'duration'

To add the conversion functionality to yt-dlp, you can consult this python script. I want to thank @riyuejz for pointing this out.

Please note that the link in the output above is region-locked because that series is not available on Bilibili outside Asia. Thank you!

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
pukkandancommented, Sep 18, 2021

you can consult this python script

The license of that script is not compatible with yt-dlp. Unless @y2361547758 wants to release it under unlicence, any implementation of this has to be written from scratch

0reactions
pukkandancommented, Oct 1, 2021

oh, I did not expect that! We should be able to just copy the code over, _download_json the json subtitle (we are already fetching the url) and pass it though the function to generate ass. See linkedinLearning or crunchyroll for example of similar implementation

If there are multiple subtitles, it would be desirable to not download all the json even though we may need only one. But afaik we dont currently have any way to handle that. I’ll have to look into how it can be implemented (I have an idea, but not entirely sure of potential side-effects). Let me know if that is something that is needed

PS: I noticed that the original script is adding some custom styling. Our implementation should only add styling if it is either in the source, or is essential for the subs to display correctly

Read more comments on GitHub >

github_iconTop Results From Across the Web

Free Caption Format Converter | SRT, SCC, DFXP, SMI, STL
Free caption format converter tool for caption or subtitle formats from SRT (Facebook) or SBV (YouTube) to Flash, DFXP, SMI and more.
Read more >
Convert captions to another format - Apple Support
This conversion method retains a copy of the captions in the original format and is a good way to quickly add languages in...
Read more >
EZConvert - the world's unique subtitles conversion software
Fast and accurate subtitle conversion tool which supports a variety of subtitle and closed captions formats and DVD, Blu-ray and NLE authoring systems....
Read more >
Subtitle Converter - Closed Caption Converter API
Convert your closed captioning and subtitle files to more than 25 different formats including broadcast formats such as SCC, MCC, EBU-STL, and more....
Read more >
[Feature Request] Stop converting .srt subtitles in .ass ... - GitHub
Hanbrake is a very good encoding tool, but i don't understand why it's convert all my embedded .srt subtitles in .ass format !...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found