• <legend id='zZ3JT'><style id='zZ3JT'><dir id='zZ3JT'><q id='zZ3JT'></q></dir></style></legend>

      1. <i id='zZ3JT'><tr id='zZ3JT'><dt id='zZ3JT'><q id='zZ3JT'><span id='zZ3JT'><b id='zZ3JT'><form id='zZ3JT'><ins id='zZ3JT'></ins><ul id='zZ3JT'></ul><sub id='zZ3JT'></sub></form><legend id='zZ3JT'></legend><bdo id='zZ3JT'><pre id='zZ3JT'><center id='zZ3JT'></center></pre></bdo></b><th id='zZ3JT'></th></span></q></dt></tr></i><div id='zZ3JT'><tfoot id='zZ3JT'></tfoot><dl id='zZ3JT'><fieldset id='zZ3JT'></fieldset></dl></div>
        <tfoot id='zZ3JT'></tfoot>
          <bdo id='zZ3JT'></bdo><ul id='zZ3JT'></ul>

        <small id='zZ3JT'></small><noframes id='zZ3JT'>

      2. 是否可以使用 discord.py(从视频中的给定时间戳播

        时间:2023-10-11
      3. <small id='y0pZ4'></small><noframes id='y0pZ4'>

          • <bdo id='y0pZ4'></bdo><ul id='y0pZ4'></ul>
            <i id='y0pZ4'><tr id='y0pZ4'><dt id='y0pZ4'><q id='y0pZ4'><span id='y0pZ4'><b id='y0pZ4'><form id='y0pZ4'><ins id='y0pZ4'></ins><ul id='y0pZ4'></ul><sub id='y0pZ4'></sub></form><legend id='y0pZ4'></legend><bdo id='y0pZ4'><pre id='y0pZ4'><center id='y0pZ4'></center></pre></bdo></b><th id='y0pZ4'></th></span></q></dt></tr></i><div id='y0pZ4'><tfoot id='y0pZ4'></tfoot><dl id='y0pZ4'><fieldset id='y0pZ4'></fieldset></dl></div>

              <tbody id='y0pZ4'></tbody>

                • <legend id='y0pZ4'><style id='y0pZ4'><dir id='y0pZ4'><q id='y0pZ4'></q></dir></style></legend>
                • <tfoot id='y0pZ4'></tfoot>
                • 本文介绍了是否可以使用 discord.py(从视频中的给定时间戳播放)搜索流式 youtube 音频?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  不幸的是,传入带有 &t= 标记的 URL 不会导致 discord.pyVoiceClient 在该时间戳开始播放.我正在使用 youtube_dl.

                  Unfortunately passing in a URL with a &t= tag does not cause discord.py's VoiceClient to start playing at that timestamp. I'm using youtube_dl.

                  是否可以在 discord.py 中搜索音频,以便从开头以外的某个地方开始流式传输 YouTube 视频?

                  Is is possible to seek through audio within discord.py in order to start streaming a YouTube video from somewhere besides the start?

                  我知道像 Groovy 之类的一些专业机器人具有用于流式 YouTube 视频的搜索命令,因此 Discord API 本身能够这个.

                  I know some professional bots like Groovy have seek commands for streamed YouTube videos, so the Discord API itself is capable of this.

                  我使用的代码来自 这里.

                  推荐答案

                  ffmpeg_options 中,您可以使用 -ss 查找特定的时间戳标志.

                  In the ffmpeg_options, you're able to seek to a specific timestamp with the use of the -ss flag.

                  如果您希望从例如 40 秒开始,这就是选项的外观:

                  This is just how the options should look if you wish to start from, for example, 40 seconds:

                  ffmpeg_options = {
                      'options': '-vn -ss 40'
                  }
                  

                  当然你可以在 stream 命令中添加一个可选变量:

                  And of course you can add an optional variable to the stream command:

                  import typing # for the optional argument of the timestamp
                  
                      @classmethod
                      async def from_url(cls, url, *, loop=None, stream=False, timestamp=0):
                          # moved the options from outside the class to inside the method.
                          # this allows the use of variables in the options
                          ffmpeg_options = {
                              'options': f'-vn -ss {timestamp}'
                          }
                          # rest of the from_url code
                  
                      @commands.command()
                      async def stream(self, ctx, timestamp: typing.Optional[int]=0, *, url): # add the arg
                          """Streams from a url (same as yt, but doesn't predownload)"""
                  
                          async with ctx.typing():
                              player = await YTDLSource.from_url(url, loop=self.bot.loop, stream=True, timestamp=timestamp)
                              # other code
                  

                  我只添加了我从音乐机器人示例编辑的代码,所以我希望我编辑的内容很清楚.如果需要任何进一步的说明/某些东西是如何工作的,那么我很乐意进行编辑.

                  I only added in the code that I edited from the music bot example, so I hope it's clear what I edited. If any further clarification is needed/how something works, then I'll be happy to make edits.

                  参考资料:

                  • FFMPEG 文档 - -ss 的 Ctrl + F.
                  • discord 命令中的可选参数
                  • f-strings - Python 3.6.0+
                  • FFMPEG Docs - Ctrl + F for -ss.
                  • Optional arguments in discord commands
                  • f-strings - Python 3.6.0+

                  这篇关于是否可以使用 discord.py(从视频中的给定时间戳播放)搜索流式 youtube 音频?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                    <bdo id='9Xxu3'></bdo><ul id='9Xxu3'></ul>
                    <tfoot id='9Xxu3'></tfoot>

                      <small id='9Xxu3'></small><noframes id='9Xxu3'>

                          <tbody id='9Xxu3'></tbody>

                        <i id='9Xxu3'><tr id='9Xxu3'><dt id='9Xxu3'><q id='9Xxu3'><span id='9Xxu3'><b id='9Xxu3'><form id='9Xxu3'><ins id='9Xxu3'></ins><ul id='9Xxu3'></ul><sub id='9Xxu3'></sub></form><legend id='9Xxu3'></legend><bdo id='9Xxu3'><pre id='9Xxu3'><center id='9Xxu3'></center></pre></bdo></b><th id='9Xxu3'></th></span></q></dt></tr></i><div id='9Xxu3'><tfoot id='9Xxu3'></tfoot><dl id='9Xxu3'><fieldset id='9Xxu3'></fieldset></dl></div>

                      1. <legend id='9Xxu3'><style id='9Xxu3'><dir id='9Xxu3'><q id='9Xxu3'></q></dir></style></legend>