-
-
Notifications
You must be signed in to change notification settings - Fork 5.9k
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
How to download a subtitle file only from youtube without the timecode? #7496
Comments
huh, I used yt-dlp and ffmpeg as I succeed downloading the subtitle file and wasn't successfully in removing the timecode/timestamp from the subtitle file? As you can see the title, it is not about bug and is about "how" related to yt-dlp. Unless I am mistaken about something. then please enlighten me. |
You can't remove it just using yt-dlp. As far as I know you can't do it with ffmpeg either. When I saw your command at first, I assumed you ae piping something into Say the command to manually remove timestamps from the downloaded file manually is |
ah, it's more tricky than I thought. The reason why i can't find documentation on |
Ok. I was awaiting for the response to my question in my previous post and I have no idea how to use that EDITAlright, I'll be closing this question. Here's what I learned so far: First:I thought Second:I ended up had to modify the command using
this is the modified of sed's part: where:
LastI do not understand what is Have a good day! |
from the README
|
ah thank you. that helped me fully understand what it does and |
hi @Xelbayria , can you help me how to achieve transcript file of a video as i unable to comprehend this command. |
What do you want to see in the transcript file? You'll need to share command of what you tried to do. Someone or I can get a good idea of what you are trying to do. |
the transcription of the content in the video |
Ok. There are 2 commands,
it's not possible to download a file without a timecode. I recommended that you look at yt-dlp's documentation where they will explain what options & Usages are for. There is also Documentation for SED, too however, the fastest way to get Usage & Options is to run |
can you please share the final command too? |
alright, Here's the command and u will notice the format of subtitle is TTML, I have it converted it to SRT (blc it's the most clean one I can use to do with
first argument is Timecode (being removed), there is also an optional |
can the 2 commands be merged into single one such that output of 1st one acts as input for 2nd? |
I haven't solved that yet. |
Here we go |
@kharbandaraghu can it be further modified such that url input part can be moved to the last in the command? |
I'm not sure, but I would rather just use Mac shortcut and pass it as argument in the shortcut so I can run it directly from youtube page 🤷♂️ |
EDIT: |
|
This works as long as the URL is referencing a single video. I'd like to use a YouTube channel as the URL, which contains a list of videos. But the "output.txt" is getting overwritten each time, I think. How can this be modified to be used with a channel? Thanks. |
use the |
@nhershy |
@bashonly I tried that, and I got this error: [Exec] Executing command: sed -i -e '/^[0-9][0-9]:[0-9][0-9]:[0-9][0-9].[0-9][0-9][0-9] --> [0-9][0-9]:[0-9][0-9]:[0-9][0-9].[0-9][0-9][0-9]$/d' -e '/^[[:digit:]]{1,3}$/d' -e 's/<[^>]*>//g' 'Emotions are NEVER IRRATIONAL: feelings are not always justified [MSNBgLz3IJA].en.vtt' To be clear, I had to swap out "write-subs" with "write-auto-subs", since the videos only have the auto-generated subtitles. This is the full command I used: yt-dlp --skip-download --write-auto-subs --exec before_dl:"sed -i -e '/^[0-9][0-9]:[0-9][0-9]:[0-9][0-9].[0-9][0-9][0-9] --> [0-9][0-9]:[0-9][0-9]:[0-9][0-9].[0-9][0-9][0-9]$/d' -e '/^[[:digit:]]{1,3}$/d' -e 's/<[^>]*>//g' %(requested_subtitles.:.filepath)#q" https://www.youtube.com/@psychacks |
@nhershy show verbose output, add try changing |
@bashonly I tried without the #, and it gave same result. Here is the -v output:
|
A good tip: if you use both
With the command above, you can get a list of subtitles to select for displaying on your player. |
@nhershy ah you are using BSD sed instead of GNU sed, which parses arguments differently try this one
or install gsed with homebrew and use gsed instead |
I did try this new command and still get a similar error:
I guess I will try to download gsed as suggested and see how that works. I am on a M1 MacBook Pro if that makes a difference. |
@nhershy change |
When I added the The command I used:
As a reiteration, this command produces exactly what I want: no timestamps, and no duplicated sentences. But it only works on a single video:
|
Your question is a sed/shell question, not a yt-dlp question. You'll need to adapt the working external sed command line into the |
Thank you for your help. I got it to work by combining your command with pieces from the other command I mentioned:
|
DO NOT REMOVE OR SKIP THE ISSUE TEMPLATE
Checklist
Please make sure the question is worded well enough to be understood
You can pick any video that has subtitle which are either automatic caption or subtitle created by the creator/author.
I've tried varying commands included below that involved yt-dlp and ffmpeg. I have no success with the result. The timecode are not even removed at all.
yt-dlp --skip-download --write-auto-subs --write-subs --sub-lang en --convert-subs srt --sub-format txt --postprocessor-args "-ss 00:00:00 -to 99:59:59 -f srt - | sed '/^[0-9]*:[0-9]*:[0-9]*,[0-9]* --> [0-9]*:[0-9]*:[0-9]*,[0-9]*$/d' | tr -s '\n' ' ' > transcription.txt" https://youtu.be/jPrdCuYD-t0
The command above was able to successfully download the subtitle file from URL and was able to convert it to a plain text file, but failed to remove the timecode or timestamp.
into
Above is a perfect example of what I am trying to do. I am not sure if the verbose output is necessary because this is about using the correct command to get correct result I wanted. Let me know if i need to include it or not.
Provide verbose output that clearly demonstrates the problem
yt-dlp -vU <your command line>
)'verbose': True
toYoutubeDL
params instead[debug] Command-line config
) and insert it belowComplete Verbose Output
No response
The text was updated successfully, but these errors were encountered: