Recherche avancée

Médias (1)

Mot : - Tags -/pirate bay

Autres articles (64)

  • Publier sur MédiaSpip

    13 juin 2013

    Puis-je poster des contenus à partir d’une tablette Ipad ?
    Oui, si votre Médiaspip installé est à la version 0.2 ou supérieure. Contacter au besoin l’administrateur de votre MédiaSpip pour le savoir

  • Contribute to documentation

    13 avril 2011

    Documentation is vital to the development of improved technical capabilities.
    MediaSPIP welcomes documentation by users as well as developers - including : critique of existing features and functions articles contributed by developers, administrators, content producers and editors screenshots to illustrate the above translations of existing documentation into other languages
    To contribute, register to the project users’ mailing (...)

  • Selection of projects using MediaSPIP

    2 mai 2011, par

    The examples below are representative elements of MediaSPIP specific uses for specific projects.
    MediaSPIP farm @ Infini
    The non profit organizationInfini develops hospitality activities, internet access point, training, realizing innovative projects in the field of information and communication technologies and Communication, and hosting of websites. It plays a unique and prominent role in the Brest (France) area, at the national level, among the half-dozen such association. Its members (...)

Sur d’autres sites (8352)

  • ERROR "Tag [3][0][0][0] incompatible with output codec id '86016' (mp4a)" while writing headers for output mp4 file from a UDP stream

    8 mai 2023, par lokit khemka

    I have a running UDP stream, that I simulating using FFMPEG command :

    


    ffmpeg -stream_loop -1 -re -i ./small_bunny_1080p_60fps.mp4 -v 0 -vcodec mpeg4 -f mpegts udp://127.0.0.1:23000


    


    The video file is obtained from the github link : https://github.com/leandromoreira/ffmpeg-libav-tutorial

    


    I keep getting error response, when I calling the function avformat_write_header. The output format is mp4, output video codec is av1 and output audio codec is same as input audio codec.

    


    I tried to create a "minimal reproducible code", however, I think it is still not completely minimal, but it reproduces the exact error.

    


    #include <libavcodec></libavcodec>avcodec.h>&#xA;#include <libavformat></libavformat>avformat.h>&#xA;#include <libavutil></libavutil>timestamp.h>&#xA;#include <libavutil></libavutil>opt.h>&#xA;#include <libswscale></libswscale>swscale.h>&#xA;#include &#xA;#include &#xA;#include &#xA;&#xA;#include &#xA;#include &#xA;&#xA;typedef struct StreamingContext{&#xA;    AVFormatContext* avfc;&#xA;    const AVCodec *video_avc;&#xA;    const AVCodec *audio_avc;&#xA;    AVStream *video_avs;&#xA;    AVStream *audio_avs;&#xA;    AVCodecContext *video_avcc;&#xA;    AVCodecContext *audio_avcc;&#xA;    int video_index;&#xA;    int audio_index;&#xA;    char* filename;&#xA;    struct SwsContext *sws_ctx;&#xA;}StreamingContext;&#xA;&#xA;&#xA;typedef struct StreamingParams{&#xA;    char copy_video;&#xA;    char copy_audio;&#xA;    char *output_extension;&#xA;    char *muxer_opt_key;&#xA;    char *muxer_opt_value;&#xA;    char *video_codec;&#xA;    char *audio_codec;&#xA;    char *codec_priv_key;&#xA;    char *codec_priv_value;&#xA;}StreamingParams;&#xA;&#xA;void logging(const char *fmt, ...)&#xA;{&#xA;    va_list args;&#xA;    fprintf(stderr, "LOG: ");&#xA;    va_start(args, fmt);&#xA;    vfprintf(stderr, fmt, args);&#xA;    va_end(args);&#xA;    fprintf(stderr, "\n");&#xA;}&#xA;&#xA;int fill_stream_info(AVStream *avs, const AVCodec **avc, AVCodecContext **avcc)&#xA;{&#xA;    *avc = avcodec_find_decoder(avs->codecpar->codec_id);&#xA;    *avcc = avcodec_alloc_context3(*avc);&#xA;    if (avcodec_parameters_to_context(*avcc, avs->codecpar) &lt; 0)&#xA;    {&#xA;        logging("Failed to fill Codec Context.");&#xA;        return -1;&#xA;    }&#xA;    avcodec_open2(*avcc, *avc, NULL);&#xA;    return 0;&#xA;}&#xA;&#xA;int open_media(const char *in_filename, AVFormatContext **avfc)&#xA;{&#xA;    *avfc = avformat_alloc_context();&#xA;    if (avformat_open_input(avfc, in_filename, NULL, NULL) != 0)&#xA;    {&#xA;        logging("Failed to open input file %s", in_filename);&#xA;        return -1;&#xA;    }&#xA;&#xA;    if (avformat_find_stream_info(*avfc, NULL) &lt; 0)&#xA;    {&#xA;        logging("Failed to get Stream Info.");&#xA;        return -1;&#xA;    }&#xA;}&#xA;&#xA;int prepare_decoder(StreamingContext *sc)&#xA;{&#xA;    for (int i = 0; i &lt; (int)sc->avfc->nb_streams; i&#x2B;&#x2B;)&#xA;    {&#xA;        if (sc->avfc->streams[i]->codecpar->codec_type == AVMEDIA_TYPE_VIDEO)&#xA;        {&#xA;            sc->video_avs = sc->avfc->streams[i];&#xA;            sc->video_index = i;&#xA;&#xA;            if (fill_stream_info(sc->video_avs, &amp;sc->video_avc, &amp;sc->video_avcc))&#xA;            {&#xA;                return -1;&#xA;            }&#xA;        }&#xA;        else if (sc->avfc->streams[i]->codecpar->codec_type == AVMEDIA_TYPE_AUDIO)&#xA;        {&#xA;            sc->audio_avs = sc->avfc->streams[i];&#xA;            sc->audio_index = i;&#xA;&#xA;            if (fill_stream_info(sc->audio_avs, &amp;sc->audio_avc, &amp;sc->audio_avcc))&#xA;            {&#xA;                return -1;&#xA;            }&#xA;        }&#xA;        else&#xA;        {&#xA;            logging("Skipping Streams other than Audio and Video.");&#xA;        }&#xA;    }&#xA;    return 0;&#xA;}&#xA;&#xA;int prepare_video_encoder(StreamingContext *encoder_sc, AVCodecContext *decoder_ctx, AVRational input_framerate,&#xA;                          StreamingParams sp, int scaled_frame_width, int scaled_frame_height)&#xA;{&#xA;    encoder_sc->video_avs = avformat_new_stream(encoder_sc->avfc, NULL);&#xA;    encoder_sc->video_avc = avcodec_find_encoder_by_name(sp.video_codec);&#xA;    if (!encoder_sc->video_avc)&#xA;    {&#xA;        logging("Cannot find the Codec.");&#xA;        return -1;&#xA;    }&#xA;&#xA;    encoder_sc->video_avcc = avcodec_alloc_context3(encoder_sc->video_avc);&#xA;    if (!encoder_sc->video_avcc)&#xA;    {&#xA;        logging("Could not allocate memory for Codec Context.");&#xA;        return -1;&#xA;    }&#xA;&#xA;    av_opt_set(encoder_sc->video_avcc->priv_data, "preset", "fast", 0);&#xA;    if (sp.codec_priv_key &amp;&amp; sp.codec_priv_value)&#xA;        av_opt_set(encoder_sc->video_avcc->priv_data, sp.codec_priv_key, sp.codec_priv_value, 0);&#xA;&#xA;    encoder_sc->video_avcc->height = scaled_frame_height;&#xA;    encoder_sc->video_avcc->width = scaled_frame_width;&#xA;    encoder_sc->video_avcc->sample_aspect_ratio = decoder_ctx->sample_aspect_ratio;&#xA;&#xA;    if (encoder_sc->video_avc->pix_fmts)&#xA;        encoder_sc->video_avcc->pix_fmt = encoder_sc->video_avc->pix_fmts[0];&#xA;    else&#xA;        encoder_sc->video_avcc->pix_fmt = decoder_ctx->pix_fmt;&#xA;&#xA;    encoder_sc->video_avcc->bit_rate = 2 * 1000 * 1000;&#xA;&#xA;    encoder_sc->video_avcc->time_base = av_inv_q(input_framerate);&#xA;    encoder_sc->video_avs->time_base = encoder_sc->video_avcc->time_base;&#xA;&#xA;    &#xA;&#xA;    if (avcodec_open2(encoder_sc->video_avcc, encoder_sc->video_avc, NULL) &lt; 0)&#xA;    {&#xA;        logging("Could not open the Codec.");&#xA;        return -1;&#xA;    }&#xA;    avcodec_parameters_from_context(encoder_sc->video_avs->codecpar, encoder_sc->video_avcc);&#xA;    return 0;&#xA;}&#xA;&#xA;&#xA;int prepare_copy(AVFormatContext *avfc, AVStream **avs, AVCodecParameters *decoder_par)&#xA;{&#xA;    *avs = avformat_new_stream(avfc, NULL);&#xA;    avcodec_parameters_copy((*avs)->codecpar, decoder_par);&#xA;    return 0;&#xA;}&#xA;&#xA;int encode_video(StreamingContext *decoder, StreamingContext *encoder, AVFrame *input_frame)&#xA;{&#xA;    if (input_frame)&#xA;        input_frame->pict_type = AV_PICTURE_TYPE_NONE;&#xA;&#xA;    AVPacket *output_packet = av_packet_alloc();&#xA;&#xA;&#xA;    int response = avcodec_send_frame(encoder->video_avcc, input_frame);&#xA;&#xA;    while (response >= 0)&#xA;    {&#xA;        response = avcodec_receive_packet(encoder->video_avcc, output_packet);&#xA;        if (response == AVERROR(EAGAIN) || response == AVERROR_EOF)&#xA;        {&#xA;            break;&#xA;        }&#xA;&#xA;        output_packet->stream_index = decoder->video_index;&#xA;        output_packet->duration = encoder->video_avs->time_base.den / encoder->video_avs->time_base.num / decoder->video_avs->avg_frame_rate.num * decoder->video_avs->avg_frame_rate.den;&#xA;&#xA;        av_packet_rescale_ts(output_packet, decoder->video_avs->time_base, encoder->video_avs->time_base);&#xA;        response = av_interleaved_write_frame(encoder->avfc, output_packet);&#xA;    }&#xA;&#xA;    av_packet_unref(output_packet);&#xA;    av_packet_free(&amp;output_packet);&#xA;&#xA;    return 0;&#xA;}&#xA;&#xA;int remux(AVPacket **pkt, AVFormatContext **avfc, AVRational decoder_tb, AVRational encoder_tb)&#xA;{&#xA;    av_packet_rescale_ts(*pkt, decoder_tb, encoder_tb);&#xA;    if (av_interleaved_write_frame(*avfc, *pkt) &lt; 0)&#xA;    {&#xA;        logging("Error while copying Stream Packet.");&#xA;        return -1;&#xA;    }&#xA;    return 0;&#xA;}&#xA;&#xA;int transcode_video(StreamingContext *decoder, StreamingContext *encoder, AVPacket *input_packet, AVFrame *input_frame)&#xA;{&#xA;    int response = avcodec_send_packet(decoder->video_avcc, input_packet);&#xA;    while (response >= 0)&#xA;    {&#xA;        response = avcodec_receive_frame(decoder->video_avcc, input_frame);&#xA;        &#xA;        if (response == AVERROR(EAGAIN) || response == AVERROR_EOF)&#xA;        {&#xA;            break;&#xA;        }&#xA;        if (response >= 0)&#xA;        {&#xA;            if (encode_video(decoder, encoder, input_frame))&#xA;                return -1;&#xA;        }&#xA;&#xA;        av_frame_unref(input_frame);&#xA;    }&#xA;    return 0;&#xA;}&#xA;&#xA;int main(int argc, char *argv[])&#xA;{&#xA;    const int scaled_frame_width = 854;&#xA;    const int scaled_frame_height = 480;&#xA;    StreamingParams sp = {0};&#xA;    sp.copy_audio = 1;&#xA;    sp.copy_video = 0;&#xA;    sp.video_codec = "libsvtav1";&#xA;    &#xA;    StreamingContext *decoder = (StreamingContext *)calloc(1, sizeof(StreamingContext));&#xA;    decoder->filename = "udp://127.0.0.1:23000";&#xA;&#xA;    StreamingContext *encoder = (StreamingContext *)calloc(1, sizeof(StreamingContext));&#xA;    encoder->filename = "small_bunny_9.mp4";&#xA;    &#xA;    if (sp.output_extension)&#xA;    {&#xA;        strcat(encoder->filename, sp.output_extension);&#xA;    }&#xA;&#xA;    open_media(decoder->filename, &amp;decoder->avfc);&#xA;    prepare_decoder(decoder);&#xA;&#xA;&#xA;    avformat_alloc_output_context2(&amp;encoder->avfc, NULL, "mp4", encoder->filename);&#xA;    AVRational input_framerate = av_guess_frame_rate(decoder->avfc, decoder->video_avs, NULL);&#xA;    prepare_video_encoder(encoder, decoder->video_avcc, input_framerate, sp, scaled_frame_width, scaled_frame_height);&#xA;&#xA;    prepare_copy(encoder->avfc, &amp;encoder->audio_avs, decoder->audio_avs->codecpar);&#xA;        &#xA;&#xA;    if (encoder->avfc->oformat->flags &amp; AVFMT_GLOBALHEADER)&#xA;        encoder->avfc->flags |= AV_CODEC_FLAG_GLOBAL_HEADER;&#xA;&#xA;    if (!(encoder->avfc->oformat->flags &amp; AVFMT_NOFILE))&#xA;    {&#xA;        if (avio_open(&amp;encoder->avfc->pb, encoder->filename, AVIO_FLAG_WRITE) &lt; 0)&#xA;        {&#xA;            logging("could not open the output file");&#xA;            return -1;&#xA;        }&#xA;    }&#xA;&#xA;    &#xA;    if (avformat_write_header(encoder->avfc, NULL) &lt; 0)&#xA;    {&#xA;        logging("an error occurred when opening output file");&#xA;        return -1;&#xA;    }&#xA;&#xA;    AVFrame *input_frame = av_frame_alloc();&#xA;    AVPacket *input_packet = av_packet_alloc();&#xA;&#xA;    while (1)&#xA;    {&#xA;        int ret = av_read_frame(decoder->avfc, input_packet);&#xA;        if(ret&lt;0)&#xA;            break;&#xA;        if (decoder->avfc->streams[input_packet->stream_index]->codecpar->codec_type == AVMEDIA_TYPE_VIDEO)&#xA;        {&#xA;            if (transcode_video(decoder, encoder, input_packet, input_frame))&#xA;                return -1;&#xA;            av_packet_unref(input_packet);&#xA;&#xA;        }&#xA;        else if (decoder->avfc->streams[input_packet->stream_index]->codecpar->codec_type == AVMEDIA_TYPE_AUDIO)&#xA;        {&#xA;            &#xA;                if (remux(&amp;input_packet, &amp;encoder->avfc, decoder->audio_avs->time_base, encoder->audio_avs->time_base))&#xA;                    return -1;&#xA;        }&#xA;        else&#xA;        {&#xA;            logging("Ignoring all nonvideo or audio packets.");&#xA;        }&#xA;    }&#xA;&#xA;    if (encode_video(decoder, encoder, NULL))&#xA;        return -1;&#xA;    &#xA;&#xA;    av_write_trailer(encoder->avfc);&#xA;&#xA;&#xA;    if (input_frame != NULL)&#xA;    {&#xA;        av_frame_free(&amp;input_frame);&#xA;        input_frame = NULL;&#xA;    }&#xA;&#xA;    if (input_packet != NULL)&#xA;    {&#xA;        av_packet_free(&amp;input_packet);&#xA;        input_packet = NULL;&#xA;    }&#xA;&#xA;    avformat_close_input(&amp;decoder->avfc);&#xA;&#xA;    avformat_free_context(decoder->avfc);&#xA;    decoder->avfc = NULL;&#xA;    avformat_free_context(encoder->avfc);&#xA;    encoder->avfc = NULL;&#xA;&#xA;    avcodec_free_context(&amp;decoder->video_avcc);&#xA;    decoder->video_avcc = NULL;&#xA;    avcodec_free_context(&amp;decoder->audio_avcc);&#xA;    decoder->audio_avcc = NULL;&#xA;&#xA;    free(decoder);&#xA;    decoder = NULL;&#xA;    free(encoder);&#xA;    encoder = NULL;&#xA;&#xA;    return 0;&#xA;}&#xA;

    &#xA;

  • FFMPEG : "DLL amfrt64.dll failed to open" on Windows [closed]

    22 juillet 2021, par barteck

    I experienced the following issue.

    &#xA;

    I'm using ffmpeg to batch resize/compress photos and videos on Windows 10. I used a version 3 and since upgraded to ver 4.4 of ffmpeg the quality of outputs dropped. I found out that I need to modify my script and explicitly define the output encoder, however when defining h264 I always got this error

    &#xA;

    DLL amfrt64.dll failed to open&#xA;

    &#xA;

    cheers&#xA;Bart

    &#xA;

  • How do i properly setup ffmpeg and fix this "Permission Denied" error im getting ?

    8 décembre 2020, par ExaNori

    Error im getting&#xA;C:/Users/Motzumoto/Desktop/AGB/ffmpeg/bin: Permission denied

    &#xA;

    I already have ffmpeg installed to path on my windows 10 machine, but that didnt fix it, so i just tried to put ffmpeg in my bots directory, that didnt do it either.&#xA;Heres my music code if anyone can help&#xA;It uses a mixture of youtube-dl and ffmpeg&#xA;If there are also any errors that would stop this from working at all it'd be nice if you could show me them, im quite tired of this as of now and im honestly just about to scrap this idea and forget about it

    &#xA;

    I've tried linking the path to the ffmpeg.exe, that still didnt work, i got the same error, i have no idea what to do

    &#xA;

    import asyncio&#xA;import logging&#xA;import math&#xA;from urllib import request&#xA;&#xA;import discord&#xA;from discord.ext import commands&#xA;import youtube_dl&#xA;from utils.guilds import Guilds&#xA;import ffmpeg&#xA;from asyncio import run_coroutine_threadsafe as coroutine&#xA;&#xA;DOWNLOAD_PATH = "audio" # download path of the file&#xA;STREAM_INDICATOR_PREFIX = "${STREAM}:"&#xA;&#xA;&#xA;&#xA;&#xA;# options&#xA;ytdl_options = {&#xA;    "quiet": True,&#xA;    "forceipv4": True,&#xA;    "noplaylist": True,&#xA;    "no_warnings": True,&#xA;    "ignoreerrors": True,&#xA;    "nooverwrites": True,&#xA;    "restrictfilenames": True,&#xA;    "nocheckcertificate": True,&#xA;    "default_search": "auto",&#xA;    "format": "bestaudio/best",&#xA;}&#xA;ffmpeg_options = {&#xA;    "options": "-vn" # indicates that we have disabled video recording in the output file&#xA;}&#xA;&#xA;ytdl = youtube_dl.YoutubeDL(ytdl_options) # youtube_dl object&#xA;&#xA;# checks functions&#xA;def is_connected(ctx):&#xA;    """Check if the bot is connected to a voice channel."""&#xA;    &#xA;    if ctx.voice_client:&#xA;        return True&#xA;    &#xA;    return False&#xA;def is_same_channel(ctx):&#xA;    """Check if the bot and the user is in the same channel."""&#xA;    &#xA;    # try to get their voice channel id if there&#x27;s any&#xA;    try:&#xA;        bot_channel_id = ctx.voice_client.channel.id&#xA;        user_channel_id = ctx.author.voice.channel.id&#xA;    # if one of them is not connected to a voice channel then they&#x27;re not together&#xA;    except AttributeError:&#xA;        return False&#xA;    &#xA;    # check if their voice channel id is the same&#xA;    if bot_channel_id == user_channel_id:&#xA;        return True&#xA;    &#xA;    return False&#xA;async def checks(ctx):&#xA;    """Do some checking."""&#xA;    &#xA;    # check if the user and the bot is in the same channel&#xA;    if not is_same_channel(ctx):&#xA;        await ctx.send("I am not with you. How dare you to command me like that.")&#xA;        return False&#xA;    &#xA;    return True&#xA;&#xA;# other function&#xA;async def create_source(ctx, query):&#xA;    """Creates youtube_dl audio source for discord.py voice client."""&#xA;    &#xA;    try:&#xA;        async with ctx.typing(): # shows that the bot is typing in chat while searching for an audio source&#xA;            source = await YTDLSource.from_url(query, ctx.bot.loop) # creates a youtube_dl source&#xA;    except IndexError: # if found nothing&#xA;        await ctx.send("I found nothing with the given query..")&#xA;        return None&#xA;    &#xA;    return source&#xA;&#xA;class Music(commands.Cog, name="music"):&#xA;    def __init__(self, bot):&#xA;        self.bot = bot&#xA;        self.guilds = Guilds() # collection of some guilds that this bot is currently in&#xA;    &#xA;    async def cog_command_error(self, ctx, error):&#xA;        """Catch all errors of this cog."""&#xA;        &#xA;        # a check on a command has failed&#xA;        if isinstance(error, commands.CheckFailure):&#xA;            await ctx.send("I&#x27;m not connected to any voice channel.")&#xA;        # ignore this error because it is already handled at the command itself&#xA;        elif isinstance(error, commands.errors.BadArgument):&#xA;            pass&#xA;        # otherwise, log all the other errors&#xA;        else:&#xA;            music_logger.exception(error)&#xA;            await ctx.send(error)&#xA;    &#xA;    @commands.command()&#xA;    async def join(self, ctx):&#xA;        """Invite me to your voice channel."""&#xA;        &#xA;        try:&#xA;            async with ctx.typing(): # shows that the bot is typing in chat while joining the voice channel&#xA;                await ctx.author.voice.channel.connect()&#xA;                await ctx.send("Alright, I joined your voice channel.")&#xA;        # user is not yet connected to a voice channel&#xA;        except AttributeError:&#xA;            await ctx.send(f"You must be connected to a voice channel first {ctx.author.name}.")&#xA;        # bot is already connected to a voice channel&#xA;        except discord.ClientException:&#xA;            if is_same_channel(ctx):&#xA;                await ctx.send("I&#x27;m already with you.")&#xA;            else:&#xA;                await ctx.send("I&#x27;m already with somebody else.")&#xA;    &#xA;    @commands.command()&#xA;    @commands.check(is_connected)&#xA;    async def leave(self, ctx):&#xA;        """Kick me out of your voice channel."""&#xA;        &#xA;        # do some checking before executing this command&#xA;        if not await checks(ctx):&#xA;            return&#xA;        &#xA;        # reset some bot&#x27;s states&#xA;        self.guilds(ctx).has_played_voice = False # reset &#x27;has_played_voice&#x27; state&#xA;        self.guilds(ctx).queue.clear() # reset the queue&#xA;        &#xA;        # finally, stop and disconnect the bot&#xA;        ctx.voice_client.stop() # stop the bot&#x27;s voice&#xA;        await ctx.voice_client.disconnect() # disconnect the bot from voice channel&#xA;        await ctx.send("Ah, alright, cya.")&#xA;    &#xA;    async def play_source(self, ctx, vc, source):&#xA;        """Play an audio to a voice channel."""&#xA;        &#xA;        def play_next(error):&#xA;            """Executes when the voice client is done playing."""&#xA;            &#xA;            # log the errors if there is any&#xA;            if error:&#xA;                music_logger.exception(error)&#xA;                coroutine(ctx.send(error), self.bot.loop)&#xA;            &#xA;            # ensure that there is a song in queue&#xA;            if self.guilds(ctx).queue.queue:&#xA;                coroutine(ctx.invoke(self.bot.get_command("next")), self.bot.loop) # go to the next song&#xA;        &#xA;        vc.play(source, after=play_next) # play the voice to the voice channel&#xA;        await ctx.send(f"Now playing &#x27;{source.title}&#x27;.")&#xA;    &#xA;    @commands.command(aliases=("p", "stream"))&#xA;    async def play(self, ctx, *, query=""):&#xA;        """Play a song for you."""&#xA;        &#xA;        # check if the query argument is empty&#xA;        if not query:&#xA;            # if yes, cancel this command&#xA;            await ctx.send("What should I play?")&#xA;            return&#xA;        &#xA;        # check if this command is invoked using &#x27;stream&#x27; alias&#xA;        if ctx.invoked_with == "stream":&#xA;            SIP = STREAM_INDICATOR_PREFIX # put prefix to the title of the source that indicates that it must be streamed&#xA;        else:&#xA;            SIP = ""&#xA;        &#xA;        # ensure that the bot is connected a voice channel&#xA;        try:&#xA;            # connect the bot to the user voice channel&#xA;            await ctx.author.voice.channel.connect()&#xA;        except AttributeError:&#xA;            # user is not yet connected to a voice channel&#xA;            await ctx.send(f"You must be connected to a voice channel first {ctx.author.name}.")&#xA;            return&#xA;        except discord.ClientException:&#xA;            pass # just ignore if bot is already connected to the voice channel&#xA;        &#xA;        # do some other checking before executing this command&#xA;        if not await checks(ctx):&#xA;            return&#xA;        &#xA;        # create the audio source&#xA;        source = await create_source(ctx, SIP &#x2B; query)&#xA;        &#xA;        # ensure that there is actually a source&#xA;        if source:&#xA;            # initialize bot&#x27;s states if the the queue is still empty&#xA;            if not self.guilds(ctx).queue.queue:&#xA;                self.guilds(ctx).has_played_voice = True # this means that the bot has played in the voice at least once&#xA;                self.guilds(ctx).queue.enqueue(SIP &#x2B; source.title)&#xA;            &#xA;            # play the audio&#xA;            try:&#xA;                await self.play_source(ctx, ctx.voice_client, source)&#xA;            # enqueue the source if audio is already playing&#xA;            except discord.ClientException:&#xA;                self.guilds(ctx).queue.enqueue(SIP &#x2B; source.title)&#xA;                await ctx.send(f"&#x27;{source.title}&#x27; is added to the queue.")&#xA;    &#xA;    @commands.command()&#xA;    @commands.check(is_connected)&#xA;    async def volume(self, ctx, *, vol=None):&#xA;        """Adjust my voice volume."""&#xA;        &#xA;        # do some checking before executing this command&#xA;        if not await checks(ctx):&#xA;            return&#xA;        &#xA;        vc = ctx.voice_client # get the voice client&#xA;        &#xA;        # ensure that the bot is playing voice in order to change the volume&#xA;        if not self.guilds(ctx).has_played_voice:&#xA;            await ctx.send("I haven&#x27;t even started yet.")&#xA;            return&#xA;        elif vc.source is None:&#xA;            await ctx.send("I am not playing anything.")&#xA;            return&#xA;        &#xA;        # check if user has passed an argument&#xA;        if vol is None:&#xA;            await ctx.send("I expect an argument from 0 to 100.")&#xA;            return&#xA;        &#xA;        # cast string argument &#x27;vol&#x27; into a float&#xA;        try:&#xA;            vol = float(vol)&#xA;        # except if the argument is not a number&#xA;        except ValueError:&#xA;            await ctx.send("The argument must only be a number.")&#xA;            return&#xA;        &#xA;        # set the volume&#xA;        if vol >= 0 and vol &lt;= 100: # bound the volume from 0 to 100&#xA;            vc.source.volume = vol / 100&#xA;        else:&#xA;            await ctx.send("I expect a value from 0 to 100.")&#xA;    &#xA;    @commands.command()&#xA;    @commands.check(is_connected)&#xA;    async def pause(self, ctx):&#xA;        """Pause the song."""&#xA;        &#xA;        # do some checking before executing this command&#xA;        if not await checks(ctx):&#xA;            return&#xA;        &#xA;        vc = ctx.voice_client # get the voice client&#xA;        &#xA;        # ensure that the bot&#x27;s voice is playing in order to pause&#xA;        if vc.is_playing():&#xA;            vc.pause()&#xA;            await ctx.send("Alright, paused.")&#xA;        # the bot haven&#x27;t played yet&#xA;        elif not self.guilds(ctx).has_played_voice:&#xA;            await ctx.send("I haven&#x27;t even started yet.")&#xA;        # there is no song in queue&#xA;        elif not self.guilds(ctx).queue.queue:&#xA;            await ctx.send("I am not playing anything.")&#xA;        else:&#xA;            await ctx.send("I already paused.")&#xA;    &#xA;    @commands.command()&#xA;    @commands.check(is_connected)&#xA;    async def resume(self, ctx):&#xA;        """Resume the song."""&#xA;        &#xA;        # do some checking before executing this command&#xA;        if not await checks(ctx):&#xA;            return&#xA;        &#xA;        vc = ctx.voice_client # get the voice client&#xA;        &#xA;        # ensure that the bot&#x27;s voice is paused in order to resume&#xA;        if vc.is_paused():&#xA;            vc.resume()&#xA;            await ctx.send("Alright, song resumed")&#xA;        # the bot haven&#x27;t played yet&#xA;        elif not self.guilds(ctx).has_played_voice:&#xA;            await ctx.send("I haven&#x27;t even started yet.")&#xA;        # there is no song in queue&#xA;        elif not self.guilds(ctx).queue.queue:&#xA;            await ctx.send("I am not playing anything.")&#xA;        else:&#xA;            await ctx.send("I am not paused.")&#xA;    &#xA;    async def update_song(self, ctx):&#xA;        """Change the currently playing song."""&#xA;        &#xA;        vc = ctx.voice_client # get the voice client&#xA;        current = self.guilds(ctx).queue.current # get the current song in queue if there&#x27;s any&#xA;        &#xA;        # ensure that the queue is not empty&#xA;        if current:&#xA;            source = await create_source(ctx, current) # create the audio source&#xA;        # the bot haven&#x27;t played yet&#xA;        elif not self.guilds(ctx).has_played_voice:&#xA;            await ctx.send("I haven&#x27;t even started yet.")&#xA;            return&#xA;        else:&#xA;            vc.stop() # stop the voice just to be sure&#xA;            await ctx.send("No more songs unfortunately.")&#xA;            return&#xA;        &#xA;        # if voice client is already playing, just change the source&#xA;        if vc.is_playing():&#xA;            vc.source = source&#xA;            await ctx.send(f"Now playing &#x27;{source.title}&#x27;.")&#xA;        # otherwise, play the source&#xA;        else:&#xA;            await self.play_source(ctx, vc, source)&#xA;    &#xA;    @commands.command()&#xA;    @commands.check(is_connected)&#xA;    async def next(self, ctx):&#xA;        """Skip the current song."""&#xA;        &#xA;        # do some checking before executing this command&#xA;        if not await checks(ctx):&#xA;            return&#xA;        &#xA;        self.guilds(ctx).queue.shift(1) # shift the queue to the left&#xA;        await self.update_song(ctx) # change the current song&#xA;    &#xA;    @commands.command()&#xA;    @commands.check(is_connected)&#xA;    async def prev(self, ctx):&#xA;        """Go back to the previous song."""&#xA;        &#xA;        # do some checking before executing this command&#xA;        if not await checks(ctx):&#xA;            return&#xA;        &#xA;        self.guilds(ctx).queue.shift(-1) # shift the queue to the right&#xA;        await self.update_song(ctx) # change the current song&#xA;    &#xA;    @commands.command()&#xA;    @commands.check(is_connected)&#xA;    async def removesong(self, ctx, *, index=1):&#xA;        """Remove a song in the queue."""&#xA;        &#xA;        # do some checking before executing this command&#xA;        if not await checks(ctx):&#xA;            return&#xA;        &#xA;        index -= 1 # decrement the &#x27;index&#x27; to match the zero-based index of Python&#xA;        &#xA;        # if index is equal to 0, that means remove the currently playing song&#xA;        # do some extra stuff before removing the current song&#xA;        if index == 0:&#xA;            # try to remove a song in queue&#xA;            try:&#xA;                self.guilds(ctx).queue.dequeue() # dequeue a song in the queue&#xA;                self.guilds(ctx).queue.shift(-1) # shift the queue to the right so that the next song will be played instead of the next next song&#xA;                await ctx.invoke(self.bot.get_command("next")) # finally, play the next song&#xA;            # except when the queue is empty&#xA;            except IndexError:&#xA;                await ctx.send("I haven&#x27;t even started yet.")&#xA;        # otherwise, just remove a song in queue&#xA;        else:&#xA;            # try to remove the song in queue&#xA;            try:&#xA;                self.guilds(ctx).queue.pop(index)&#xA;                await ctx.send("Song removed")&#xA;            # except if the song is not in the queue&#xA;            except IndexError:&#xA;                # check if the bot has not started playing yet&#xA;                if not self.guilds(ctx).has_played_voice:&#xA;                    await ctx.send("I haven&#x27;t even started yet...")&#xA;                else:&#xA;                    await ctx.send(f"I can&#x27;t remove that {ctx.author.name} because it doesn&#x27;t exist.")&#xA;    @removesong.error&#xA;    async def remove_error(self, ctx, error):&#xA;        """Error handler for the &#x27;remove&#x27; command."""&#xA;        &#xA;        # check if the argument is bad&#xA;        if isinstance(error, commands.errors.BadArgument):&#xA;            await ctx.send(f"I can&#x27;t remove that {ctx.author.name}.")&#xA;            await ctx.send("The argument must only be a number or leave it none.")&#xA;    &#xA;    @commands.command()&#xA;    @commands.check(is_connected)&#xA;    async def stop(self, ctx):&#xA;        """Stop all the songs."""&#xA;        &#xA;        # do some checking before executing this command&#xA;        if not await checks(ctx):&#xA;            return&#xA;        &#xA;        vc = ctx.voice_client # get the voice client&#xA;        &#xA;        # ensure that the bot is connected to the voice client&#xA;        if vc.is_playing() or vc.is_paused():&#xA;            self.guilds(ctx).queue.clear() # reset the queue&#xA;            ctx.voice_client.stop() # stop the bot&#x27;s voice&#xA;            await ctx.send("Playback stopped")&#xA;        # the bot haven&#x27;t played yet&#xA;        elif not self.guilds(ctx).has_played_voice:&#xA;            await ctx.send("I haven&#x27;t even started yet.")&#xA;        else:&#xA;            await ctx.send("I already stopped.")&#xA;    &#xA;    @commands.command()&#xA;    @commands.check(is_connected)&#xA;    async def queue(self, ctx):&#xA;        """Show the queue of songs."""&#xA;        &#xA;        SIP = STREAM_INDICATOR_PREFIX # shorten the variable name&#xA;        &#xA;        # do some checking before executing this command&#xA;        if not await checks(ctx):&#xA;            return&#xA;        &#xA;        # try to send the songs in the queue&#xA;        try:&#xA;            # format the queue to make it readable&#xA;            queue = [&#xA;                f"{i}." &#x2B; (" (STREAM) " if q.startswith(SIP) else " ") &#x2B; q.split(SIP)[-1]&#xA;                for i, q in enumerate(self.guilds(ctx).queue.queue, 1)&#xA;            ]&#xA;            &#xA;            await ctx.send("\n".join(queue))&#xA;        # except if it is empty&#xA;        except HTTPException:&#xA;            await ctx.send("No songs in queue.")&#xA;&#xA;class YTDLSource(discord.PCMVolumeTransformer):&#xA;    """Creates a youtube_dl audio source with volume control."""&#xA;    &#xA;    def __init__(self, source, *, data, volume=1):&#xA;        super().__init__(source, volume)&#xA;        self.data = data&#xA;        self.title = data.get("title")&#xA;        self.url = data.get("url")&#xA;    &#xA;    @classmethod&#xA;    async def from_url(cls, url, loop):&#xA;        """Get source by URL."""&#xA;        &#xA;        # check if the URL is must be streamed&#xA;        if url.startswith(STREAM_INDICATOR_PREFIX):&#xA;            stream = True&#xA;        else:&#xA;            stream = False&#xA;        &#xA;        # get data from the given URL&#xA;        data = await loop.run_in_executor(&#xA;            None,&#xA;            (lambda:&#xA;                ytdl.extract_info(&#xA;                    url.split(STREAM_INDICATOR_PREFIX)[-1], # remove the prefix from the URL&#xA;                    download=not stream&#xA;                ))&#xA;        )&#xA;        ##$$$$ fix error somtimes&#xA;        # take the first item from the entries if there&#x27;s any&#xA;        if "entries" in data:&#xA;            try:&#xA;                data = data["entries"][0]&#xA;            except Exception as e:&#xA;                music_logger.exception(e)&#xA;                return None&#xA;        &#xA;        filepath = data["url"] if stream else ytdl.prepare_filename(data) # source url or download path of the file, depends on the &#x27;stream&#x27; parameter&#xA;        return cls(discord.FFmpegPCMAudio("C:/Users/Motzumoto/Desktop/AGB/ffmpeg/bin", **ffmpeg_options), data=data) # create and return the source&#xA;&#xA;def setup(bot):&#xA;    bot.add_cog(Music(bot))&#xA;&#xA;

    &#xA;