鱼C论坛

 找回密码
 立即注册
查看: 148|回复: 5

[已解决]download-sections of yt-dlp is not accurate, can we use the more accurate time?

[复制链接]
发表于 2024-3-26 17:35:13 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能^_^

您需要 登录 才可以下载或查看,没有账号?立即注册

x
本帖最后由 blackantt 于 2024-3-26 17:37 编辑

download-sections of yt-dlp is not accurate, can we use the more accurate time format(00:00:00,xxx)?
最佳答案
2024-3-26 17:44:48
blackantt 发表于 2024-03-26 17:44
yt-dlp: error: invalid --download-sections time ra ...


Apologies for the confusion. It seems that yt-dlp requires the time range to be in a slightly different format. Instead of using "00:00:00,xxx", you should use "start-end" format for the --download-section option.

Here's an example:

yt-dlp --download-section "00:03:14.000-00:05:27.500"

In this command, we use a dot (.) instead of a comma (,) to separate the milliseconds. The time is specified as "HH:MM:SS.mmm".

Again, make sure to replace `<URL>` with the actual URL of the video you want to download.

By following this format, yt-dlp should accurately download the specified section of the video.

以上回复来自 FishC AI 小助理,如未能正确解答您的问题,请继续追问。
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复

使用道具 举报

发表于 2024-3-26 17:35:26 | 显示全部楼层
Certainly! To achieve a more accurate time format for downloading sections, you can use the `datetime` module in Python. Here's an example:

  1. import datetime

  2. # Function to convert seconds to the accurate time format
  3. def format_time(seconds):
  4.     time_delta = datetime.timedelta(seconds=seconds)
  5.     hours = time_delta.seconds // 3600
  6.     minutes = (time_delta.seconds % 3600) // 60
  7.     milliseconds = time_delta.microseconds // 1000
  8.     return f"{hours:02d}:{minutes:02d}:{milliseconds:03d}"

  9. # Example usage
  10. total_seconds = 3661  # Total duration of the download section in seconds
  11. formatted_time = format_time(total_seconds)
  12. print(formatted_time)
复制代码


In this example, the `format_time` function takes the total duration of the download section in seconds and converts it into the accurate time format (`00:00:00,000`). It uses the `datetime.timedelta` function to handle the time calculations.

You can adjust the `total_seconds` variable with your actual duration, and then `formatted_time` will contain the accurate time format.

以上回复来自 FishC AI 小助理,如未能正确解答您的问题,请继续追问。
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复 支持 反对

使用道具 举报

 楼主| 发表于 2024-3-26 17:37:31 | 显示全部楼层
FishC 发表于 2024-3-26 17:35
Certainly! To achieve a more accurate time format for downloading sections, you can use the `datetim ...

download-sections of yt-dlp is not accurate, can we use the more accurate time format(00:00:00,xxx)?
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2024-3-26 17:37:41 | 显示全部楼层
blackantt 发表于 2024-03-26 17:37
download-sections of yt-dlp is not accurate, can w ...


Certainly! To use the more accurate time format (00:00:00,xxx) for specifying download sections in yt-dlp, you can directly pass the time in this format when using the `--download-section` option. Here's an example:

  1. yt-dlp --download-section "00:03:14,000-00:05:27,500" <video URL>
复制代码


In the above command, the download section is specified from 3 minutes and 14 seconds to 5 minutes and 27.5 seconds of the video.

Make sure to replace `<video URL>` with the actual URL of the video you want to download.

By specifying the start and end time in the format "HH:MM:SS,mmm", yt-dlp will accurately download the specified section of the video.

以上回复来自 FishC AI 小助理,如未能正确解答您的问题,请继续追问。
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复 支持 反对

使用道具 举报

 楼主| 发表于 2024-3-26 17:44:39 | 显示全部楼层
yt-dlp: error: invalid --download-sections time range "*01:14,000-02:27,500". Must be of the form "*start-end"
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2024-3-26 17:44:48 | 显示全部楼层    本楼为最佳答案   
blackantt 发表于 2024-03-26 17:44
yt-dlp: error: invalid --download-sections time ra ...


Apologies for the confusion. It seems that yt-dlp requires the time range to be in a slightly different format. Instead of using "00:00:00,xxx", you should use "start-end" format for the --download-section option.

Here's an example:

yt-dlp --download-section "00:03:14.000-00:05:27.500"

In this command, we use a dot (.) instead of a comma (,) to separate the milliseconds. The time is specified as "HH:MM:SS.mmm".

Again, make sure to replace `<URL>` with the actual URL of the video you want to download.

By following this format, yt-dlp should accurately download the specified section of the video.

以上回复来自 FishC AI 小助理,如未能正确解答您的问题,请继续追问。
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|手机版|Archiver|鱼C工作室 ( 粤ICP备18085999号-1 | 粤公网安备 44051102000585号)

GMT+8, 2024-4-28 14:36

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表