Recherche avancée

Médias (0)

Mot : - Tags -/clipboard

Aucun média correspondant à vos critères n’est disponible sur le site.

Autres articles (41)

  • 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

  • Initialisation de MediaSPIP (préconfiguration)

    20 février 2010, par

    Lors de l’installation de MediaSPIP, celui-ci est préconfiguré pour les usages les plus fréquents.
    Cette préconfiguration est réalisée par un plugin activé par défaut et non désactivable appelé MediaSPIP Init.
    Ce plugin sert à préconfigurer de manière correcte chaque instance de MediaSPIP. Il doit donc être placé dans le dossier plugins-dist/ du site ou de la ferme pour être installé par défaut avant de pouvoir utiliser le site.
    Dans un premier temps il active ou désactive des options de SPIP qui ne le (...)

  • Taille des images et des logos définissables

    9 février 2011, par

    Dans beaucoup d’endroits du site, logos et images sont redimensionnées pour correspondre aux emplacements définis par les thèmes. L’ensemble des ces tailles pouvant changer d’un thème à un autre peuvent être définies directement dans le thème et éviter ainsi à l’utilisateur de devoir les configurer manuellement après avoir changé l’apparence de son site.
    Ces tailles d’images sont également disponibles dans la configuration spécifique de MediaSPIP Core. La taille maximale du logo du site en pixels, on permet (...)

Sur d’autres sites (4933)

  • "Application provided invalid, non monotonically increasing dts to muxer in stream 0 : 47104 >= -4251" in C ffmpeg video & audio streams processing

    30 décembre 2023, par M.Hakim

    For an input.mp4 file containing a video stream and an audio stream, intend to convert the video stream into h264 codec and the audio stream into aac codec and combine the two streams in output.mp4 file using C and ffmpeg libraries.
Am getting an error [mp4 @ 0x5583c88fd340] Application provided invalid, non monotonically increasing dts to muxer in stream 0 : 47104 >= -4251
How do i solve that error ?

    


    #include &#xA;#include <libavcodec></libavcodec>avcodec.h>&#xA;#include <libavformat></libavformat>avformat.h>    &#xA;#include <libavutil></libavutil>opt.h>&#xA;&#xA;int encodeVideoAndAudio4(char *pInName, char *pOutName) {&#xA;&#xA;    AVFormatContext *format_ctx = avformat_alloc_context();&#xA;&#xA;    AVCodecContext *video_dec_ctx = NULL;&#xA;    AVCodecContext *video_enc_ctx = NULL;&#xA;    AVCodec *video_dec_codec = NULL;&#xA;    AVCodec *video_enc_codec = NULL;&#xA;    AVDictionary *video_enc_opts = NULL;&#xA;&#xA;    AVCodecContext *audio_dec_ctx = NULL;&#xA;    AVCodecContext *audio_enc_ctx = NULL;&#xA;    AVCodec *audio_dec_codec = NULL;&#xA;    AVCodec *audio_enc_codec = NULL;&#xA;&#xA;&#xA;    if (avformat_open_input(&amp;format_ctx, pInName, NULL, NULL) &lt; 0) {&#xA;        fprintf(stderr, "Error: Could not open input file\n");&#xA;        return 1;&#xA;    }&#xA;&#xA;    if (avformat_find_stream_info(format_ctx, NULL) &lt; 0) {&#xA;        fprintf(stderr, "Error: Could not find stream information\n");&#xA;        return 1;&#xA;    }&#xA;&#xA;    for (int i = 0; i &lt; format_ctx->nb_streams; i&#x2B;&#x2B;) {&#xA;        AVStream *stream = format_ctx->streams[i];&#xA;        const char *media_type_str = av_get_media_type_string(stream->codecpar->codec_type);&#xA;        AVRational time_base = stream->time_base;&#xA;&#xA;    }&#xA;&#xA;    int video_stream_index = -1;&#xA;    for (int i = 0; i &lt; format_ctx->nb_streams; i&#x2B;&#x2B;) {&#xA;        if (format_ctx->streams[i]->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) {&#xA;            video_stream_index = i;&#xA;            break;&#xA;        }&#xA;    }&#xA;    if (video_stream_index == -1) {&#xA;        fprintf(stderr, "Error: Could not find a video stream\n");&#xA;        return 1;&#xA;    }&#xA;&#xA;    AVStream *videoStream = format_ctx->streams[video_stream_index];&#xA;    video_dec_ctx = avcodec_alloc_context3(NULL);&#xA;    avcodec_parameters_to_context(video_dec_ctx, videoStream->codecpar);&#xA;&#xA;    video_dec_codec = avcodec_find_decoder(video_dec_ctx->codec_id);&#xA;&#xA;    if (!video_dec_codec) {&#xA;        fprintf(stderr, "Unsupported video codec!\n");&#xA;        return 1;&#xA;    }&#xA;&#xA;    if (avcodec_open2(video_dec_ctx, video_dec_codec, NULL) &lt; 0) {&#xA;        fprintf(stderr, "Error: Could not open a video decoder codec\n");&#xA;        return 1;&#xA;    }&#xA;&#xA;    video_enc_codec = avcodec_find_encoder(AV_CODEC_ID_H264);&#xA;    if (!video_enc_codec) {&#xA;        fprintf(stderr, "Error: Video Encoder codec not found\n");&#xA;        return 1;&#xA;    }&#xA;&#xA;    video_enc_ctx = avcodec_alloc_context3(video_enc_codec);&#xA;    if (!video_enc_ctx) {&#xA;        fprintf(stderr, "Error: Could not allocate video encoder codec context\n");&#xA;        return 1;&#xA;    }&#xA;&#xA;    videoStream->time_base = (AVRational){1, 25};&#xA;&#xA;    video_enc_ctx->bit_rate = 1000; &#xA;    video_enc_ctx->width = video_dec_ctx->width;&#xA;    video_enc_ctx->height = video_dec_ctx->height;&#xA;    video_enc_ctx->time_base = (AVRational){1, 25};&#xA;    video_enc_ctx->gop_size = 10;&#xA;    video_enc_ctx->max_b_frames = 1;&#xA;    video_enc_ctx->pix_fmt = AV_PIX_FMT_YUV420P;&#xA;&#xA;    if (avcodec_open2(video_enc_ctx, video_enc_codec, NULL) &lt; 0) {&#xA;        fprintf(stderr, "Error: Could not open encoder codec\n");&#xA;        return 1;&#xA;    }&#xA;&#xA;    av_dict_set(&amp;video_enc_opts, "preset", "medium", 0);&#xA;    av_opt_set_dict(video_enc_ctx->priv_data, &amp;video_enc_opts);&#xA;&#xA;    AVPacket video_pkt;&#xA;    av_init_packet(&amp;video_pkt);&#xA;    video_pkt.data = NULL;&#xA;    video_pkt.size = 0;&#xA;&#xA;    AVPacket pkt;&#xA;    av_init_packet(&amp;pkt);&#xA;    pkt.data = NULL;&#xA;    pkt.size = 0;&#xA;&#xA;    AVFrame *video_frame = av_frame_alloc();&#xA;    if (!video_frame) {&#xA;        fprintf(stderr, "Error: Could not allocate video frame\n");&#xA;        return 1;&#xA;    }&#xA;&#xA;    video_frame->format = video_enc_ctx->pix_fmt;&#xA;    video_frame->width = video_enc_ctx->width;&#xA;    video_frame->height = video_enc_ctx->height;&#xA;   &#xA;    int audio_stream_index = -1;&#xA;    for (int i = 0; i &lt; format_ctx->nb_streams; i&#x2B;&#x2B;) {&#xA;        if (format_ctx->streams[i]->codecpar->codec_type == AVMEDIA_TYPE_AUDIO) {&#xA;            audio_stream_index = i;&#xA;            break;&#xA;        }&#xA;    }&#xA;&#xA;    if (audio_stream_index == -1) {&#xA;        fprintf(stderr, "Error: Could not find an audio stream\n");&#xA;        return 1;&#xA;    }&#xA;    &#xA;    AVStream *audioStream = format_ctx->streams[audio_stream_index];&#xA;    audio_dec_ctx = avcodec_alloc_context3(NULL);&#xA;    avcodec_parameters_to_context(audio_dec_ctx, audioStream->codecpar);&#xA;    &#xA;    audio_dec_codec = avcodec_find_decoder(audio_dec_ctx->codec_id);&#xA;   &#xA;    if (!audio_dec_codec) {&#xA;        fprintf(stderr, "Unsupported audio codec!\n");&#xA;        return 1;&#xA;    }&#xA;   &#xA;    if (avcodec_open2(audio_dec_ctx, audio_dec_codec, NULL) &lt; 0) {&#xA;        fprintf(stderr, "Error: Could not open Audio decoder codec\n");&#xA;        return 1;&#xA;    }&#xA;    &#xA;    audio_enc_codec = avcodec_find_encoder(AV_CODEC_ID_AAC);&#xA;    if (!audio_enc_codec) {&#xA;        fprintf(stderr, "Error: Audio Encoder codec not found\n");&#xA;        return 1;&#xA;    }&#xA;   &#xA;    audio_enc_ctx = avcodec_alloc_context3(audio_enc_codec);&#xA;    if (!audio_enc_ctx) {&#xA;        fprintf(stderr, "Error: Could not allocate audio encoder codec context\n");&#xA;        return 1;&#xA;    }&#xA;&#xA;    audioStream->time_base = (AVRational){1, audio_dec_ctx->sample_rate};&#xA;    &#xA;    audio_enc_ctx->bit_rate = 64000; &#xA;    audio_enc_ctx->sample_rate = audio_dec_ctx->sample_rate;&#xA;    audio_enc_ctx->channels = audio_dec_ctx->channels;&#xA;    audio_enc_ctx->channel_layout = av_get_default_channel_layout(audio_enc_ctx->channels);&#xA;    audio_enc_ctx->sample_fmt = AV_SAMPLE_FMT_FLTP;&#xA;    audio_enc_ctx->profile = FF_PROFILE_AAC_LOW;&#xA;    &#xA;    if (avcodec_open2(audio_enc_ctx, audio_enc_codec, NULL) &lt; 0) {&#xA;        fprintf(stderr, "Error: Could not open encoder codec\n");&#xA;        return 1;&#xA;    }&#xA;   &#xA;    AVPacket audio_pkt;&#xA;    av_init_packet(&amp;audio_pkt);&#xA;    audio_pkt.data = NULL;&#xA;    audio_pkt.size = 0;&#xA;   &#xA;    AVFrame *audio_frame = av_frame_alloc();&#xA;    if (!audio_frame) {&#xA;        fprintf(stderr, "Error: Could not allocate audio frame\n");&#xA;        return 1;&#xA;    }&#xA;&#xA;    audio_frame->format = audio_enc_ctx->sample_fmt;&#xA;    audio_frame->sample_rate = audio_enc_ctx->sample_rate;&#xA;    audio_frame->channels = audio_enc_ctx->channels;&#xA;   &#xA;    AVFormatContext *output_format_ctx = NULL;&#xA;    if (avformat_alloc_output_context2(&amp;output_format_ctx, NULL, NULL, pOutName) &lt; 0) {&#xA;        fprintf(stderr, "Error: Could not create output context\n");&#xA;        return 1;&#xA;    }&#xA;    &#xA;    if (avio_open(&amp;output_format_ctx->pb, pOutName, AVIO_FLAG_WRITE) &lt; 0) {&#xA;        fprintf(stderr, "Error: Could not open output file\n");&#xA;        return 1;&#xA;    }&#xA;   &#xA;    AVStream *video_stream = avformat_new_stream(output_format_ctx, video_enc_codec);&#xA;    if (!video_stream) {&#xA;        fprintf(stderr, "Error: Could not create video stream\n");&#xA;        return 1;&#xA;    }&#xA;   &#xA;    av_dict_set(&amp;video_stream->metadata, "rotate", "90", 0);&#xA;    &#xA;    if (avcodec_parameters_from_context(video_stream->codecpar, video_enc_ctx) &lt; 0) {&#xA;        fprintf(stderr, "Error: Could not copy video codec parameters\n");&#xA;        return 1;&#xA;    }&#xA;  &#xA;    AVStream *audio_stream = avformat_new_stream(output_format_ctx, audio_enc_codec);&#xA;    if (!audio_stream) {&#xA;        fprintf(stderr, "Error: Could not create audio stream\n");&#xA;        return 1;&#xA;    }&#xA;   &#xA;    if (avcodec_parameters_from_context(audio_stream->codecpar, audio_enc_ctx) &lt; 0) {&#xA;        fprintf(stderr, "Error: Could not copy audio codec parameters\n");&#xA;        return 1;&#xA;    }&#xA;  &#xA;    if (avformat_write_header(output_format_ctx, NULL) &lt; 0) {&#xA;        fprintf(stderr, "Error: Could not write header\n");&#xA;        return 1;&#xA;    }&#xA;  &#xA;     int video_frame_count = 0, audio_frame_count = 0;&#xA;    &#xA;    while (1) {&#xA;&#xA;        if (av_read_frame(format_ctx, &amp;pkt) &lt; 0) {&#xA;            fprintf(stderr, "BREAK FROM MAIN WHILE LOOP\n");&#xA;            break;&#xA;        }&#xA;&#xA;        if (pkt.stream_index == video_stream_index) {&#xA;&#xA;            if (avcodec_send_packet(video_dec_ctx, &amp;pkt) &lt; 0) {&#xA;                fprintf(stderr, "Error: Could not send video packet for decoding\n");&#xA;                return 1;&#xA;            }&#xA;&#xA;            while (avcodec_receive_frame(video_dec_ctx, video_frame) == 0) { &#xA;&#xA;                if (avcodec_send_frame(video_enc_ctx, video_frame) &lt; 0) {&#xA;                    fprintf(stderr, "Error: Could not send video frame for encoding\n");&#xA;                    return 1;&#xA;                }&#xA;&#xA;                while (avcodec_receive_packet(video_enc_ctx, &amp;video_pkt) == 0) {&#xA;                    &#xA;                    if (av_write_frame(output_format_ctx, &amp;video_pkt) &lt; 0) {&#xA;                        fprintf(stderr, "Error: Could not write video packet to output file.\n");&#xA;                        return 1;&#xA;                    }&#xA;&#xA;                    av_packet_unref(&amp;video_pkt);&#xA;                }&#xA;&#xA;                video_frame_count&#x2B;&#x2B;;&#xA;            }&#xA;        } else if (pkt.stream_index == audio_stream_index) {&#xA;&#xA;            if (avcodec_send_packet(audio_dec_ctx, &amp;pkt) &lt; 0) {&#xA;                fprintf(stderr, "Error: Could not send audio packet for decoding\n");&#xA;                return 1;&#xA;            }&#xA;&#xA;            while (avcodec_receive_frame(audio_dec_ctx, audio_frame) == 0) { &#xA; &#xA;                if (avcodec_send_frame(audio_enc_ctx, audio_frame) &lt; 0) {&#xA;                    fprintf(stderr, "Error: Could not send audio frame for encoding\n");&#xA;                    return 1;&#xA;                }&#xA;&#xA;                while (avcodec_receive_packet(audio_enc_ctx, &amp;audio_pkt) == 0) {                    if (av_write_frame(output_format_ctx, &amp;audio_pkt) &lt; 0) {&#xA;                        fprintf(stderr, "Error: Could not write audio packet to output file\n");&#xA;                        return 1;&#xA;                    }&#xA;&#xA;                    av_packet_unref(&amp;audio_pkt);&#xA;                }&#xA;&#xA;                audio_frame_count&#x2B;&#x2B;;&#xA;            }&#xA;        }&#xA;&#xA;        av_packet_unref(&amp;pkt);&#xA;    }&#xA;&#xA;    if (av_write_trailer(output_format_ctx) &lt; 0) {&#xA;        fprintf(stderr, "Error: Could not write trailer\n");&#xA;        return 1;&#xA;    }  &#xA;    &#xA;    avformat_close_input(&amp;format_ctx);&#xA;    avio_close(output_format_ctx->pb);&#xA;    avformat_free_context(output_format_ctx);&#xA;    &#xA;    av_frame_free(&amp;video_frame);&#xA;    avcodec_free_context(&amp;video_dec_ctx);&#xA;    avcodec_free_context(&amp;video_enc_ctx);&#xA;    av_dict_free(&amp;video_enc_opts);&#xA;    &#xA;    av_frame_free(&amp;audio_frame);&#xA;    avcodec_free_context(&amp;audio_dec_ctx);&#xA;    avcodec_free_context(&amp;audio_enc_ctx);&#xA;&#xA;    printf("Conversion complete.  %d video frames processed and %d audio frames processed.\n",video_frame_count, audio_frame_count);&#xA;&#xA;    return 0;&#xA;}&#xA;&#xA;&#xA;int main(int argc, char *argv[]) {&#xA;    if (argc != 3) {&#xA;        printf("Usage: %s  \n", argv[0]);&#xA;        return 1;&#xA;    }&#xA;&#xA;    const char *input_filename = argv[1];&#xA;    const char *output_filename = argv[2];&#xA;&#xA;    avcodec_register_all();&#xA;    av_register_all();&#xA;&#xA;    int returnValue = encodeVideoAndAudio4(input_filename, output_filename);&#xA;    &#xA;    return 0;&#xA;}&#xA;&#xA;

    &#xA;

    When i comment out the blocks that process one of the two streams, the other stream is converted and written to the output.mp4 successfully.&#xA;When each stream is processed in a separate loop, only the first stream is processed and written to the output.mp4 file and the other stream is skipped.&#xA;When both streams are processed in a common loop as it is in the code above, the above mentioned error appears.

    &#xA;

  • "FFmpeg : Error not transitioning to the next song in Discord Bot's queue."

    1er avril 2024, par noober

    I have 3 modules, but I'm sure the error occurs within this module, and here is the entire code within that module :

    &#xA;

    import asyncio&#xA;import discord&#xA;from discord import FFmpegOpusAudio, Embed&#xA;import os&#xA;&#xA;async def handle_help(message):&#xA;    embed = discord.Embed(&#xA;        title="Danh s&#xE1;ch lệnh cho B&#xE9; M&#xE8;o",&#xA;        description="Dưới đ&#xE2;y l&#xE0; c&#xE1;c lệnh m&#xE0; chủ nh&#xE2;n c&#xF3; thể bắt B&#xE9; M&#xE8;o phục vụ:",&#xA;        color=discord.Color.blue()&#xA;    )&#xA;    embed.add_field(name="!play", value="Ph&#xE1;t một b&#xE0;i h&#xE1;t từ YouTube.", inline=False)&#xA;    embed.add_field(name="!pause", value="Tạm dừng b&#xE0;i h&#xE1;t đang ph&#xE1;t.", inline=False)&#xA;    embed.add_field(name="!resume", value="Tiếp tục b&#xE0;i h&#xE1;t đang bị tạm dừng.", inline=False)&#xA;    embed.add_field(name="!skip", value="Chuyển đến b&#xE0;i h&#xE1;t tiếp theo trong danh s&#xE1;ch chờ.", inline=False)&#xA;    embed.add_field(name="!stop", value="Dừng ph&#xE1;t nhạc v&#xE0; cho ph&#xE9;p B&#xE9; M&#xE8;o đi ngủ tiếp.", inline=False)&#xA;    # Th&#xEA;m c&#xE1;c lệnh kh&#xE1;c theo c&#xF9;ng mẫu tr&#xEA;n&#xA;    await message.channel.send(embed=embed)&#xA;&#xA;class Song:&#xA;    def __init__(self, title, player):&#xA;        self.title = title  # Lưu trữ ti&#xEA;u đề b&#xE0;i h&#xE1;t ở đ&#xE2;y&#xA;        self.player = player&#xA;&#xA;# Th&#xEA;m đối tượng Song v&#xE0;o h&#xE0;ng đợi&#xA;def add_song_to_queue(guild_id, queues, song):&#xA;    queues.setdefault(guild_id, []).append(song)&#xA;&#xA;async def handle_list(message, queues):&#xA;    log_file_path = "C:\\Bot Music 2\\song_log.txt"&#xA;    if os.path.exists(log_file_path):&#xA;        with open(log_file_path, "r", encoding="utf-8") as f:&#xA;            song_list = f.readlines()&#xA;&#xA;        if song_list:&#xA;            embed = discord.Embed(&#xA;                title="Danh s&#xE1;ch b&#xE0;i h&#xE1;t",&#xA;                description="Danh s&#xE1;ch c&#xE1;c b&#xE0;i h&#xE1;t đ&#xE3; ph&#xE1;t:",&#xA;                color=discord.Color.blue()&#xA;            )&#xA;&#xA;            for i, song in enumerate(song_list, start=1):&#xA;                if i == 1:&#xA;                    song = "- Đang ph&#xE1;t: " &#x2B; song.strip()&#xA;                embed.add_field(name=f"B&#xE0;i h&#xE1;t {i}", value=song, inline=False)&#xA;&#xA;            await message.channel.send(embed=embed)&#xA;        else:&#xA;            await message.channel.send("Hiện kh&#xF4;ng c&#xF3; dữ liệu trong file log.")&#xA;    else:&#xA;        await message.channel.send("File log kh&#xF4;ng tồn tại.")&#xA;&#xA;async def handle_commands(message, client, queues, voice_clients, yt_dl_options, ytdl, ffmpeg_options=None, guild_id=None, data=None):&#xA;    # Nếu kh&#xF4;ng c&#xF3; ffmpeg_options, sử dụng c&#xE1;c thiết lập mặc định&#xA;    if ffmpeg_options is None:&#xA;        ffmpeg_options = {&#xA;            &#x27;before_options&#x27;: &#x27;-reconnect 1 -reconnect_streamed 1 -reconnect_delay_max 5&#x27;,&#xA;            &#x27;options&#x27;: &#x27;-vn -filter:a "volume=0.25"&#x27;&#xA;        }&#xA;    &#xA;    # Khởi tạo voice_client&#xA;    if guild_id is None:&#xA;        guild_id = message.guild.id&#xA;&#xA;    if guild_id in voice_clients:&#xA;        voice_client = voice_clients[guild_id]&#xA;    else:&#xA;        voice_client = None&#xA;&#xA;    # Xử l&#xFD; lệnh !play&#xA;    if message.content.startswith("!play"):&#xA;        try:&#xA;            # Kiểm tra xem người gửi tin nhắn c&#xF3; đang ở trong k&#xEA;nh voice kh&#xF4;ng&#xA;            voice_channel = message.author.voice.channel&#xA;            # Kiểm tra xem bot c&#xF3; đang ở trong k&#xEA;nh voice của guild kh&#xF4;ng&#xA;            if voice_client and voice_client.is_connected():&#xA;                await voice_client.move_to(voice_channel)&#xA;            else:&#xA;                voice_client = await voice_channel.connect()&#xA;                voice_clients[guild_id] = voice_client&#xA;        except Exception as e:&#xA;            print(e)&#xA;&#xA;        try:&#xA;            query = &#x27; &#x27;.join(message.content.split()[1:])&#xA;            if query.startswith(&#x27;http&#x27;):&#xA;                url = query&#xA;            else:&#xA;                query = &#x27;ytsearch:&#x27; &#x2B; query&#xA;                loop = asyncio.get_event_loop()&#xA;                data = await loop.run_in_executor(None, lambda: ytdl.extract_info(query, download=False))&#xA;                if not data:&#xA;                    raise ValueError("Kh&#xF4;ng c&#xF3; dữ liệu trả về từ YouTube.")&#xA;                url = data[&#x27;entries&#x27;][0][&#x27;url&#x27;]&#xA;&#xA;            player = FFmpegOpusAudio(url, **ffmpeg_options)&#xA;            # Lấy th&#xF4;ng tin của b&#xE0;i h&#xE1;t mới đang được y&#xEA;u cầu&#xA;            title = data[&#x27;entries&#x27;][0][&#x27;title&#x27;]&#xA;            duration = data[&#x27;entries&#x27;][0][&#x27;duration&#x27;]&#xA;            creator = data[&#x27;entries&#x27;][0][&#x27;creator&#x27;] if &#x27;creator&#x27; in data[&#x27;entries&#x27;][0] else "Unknown"&#xA;            requester = message.author.nick if message.author.nick else message.author.name&#xA;                    &#xA;            # Tạo embed để th&#xF4;ng b&#xE1;o th&#xF4;ng tin b&#xE0;i h&#xE1;t mới&#xA;            embed = discord.Embed(&#xA;                title="Th&#xF4;ng tin b&#xE0;i h&#xE1;t mới",&#xA;                description=f"**B&#xE0;i h&#xE1;t:** *{title}*\n**Thời lượng:** *{duration}*\n**T&#xE1;c giả:** *{creator}*\n**Người y&#xEA;u cầu:** *{requester}*",&#xA;                color=discord.Color.green()&#xA;            )&#xA;            await message.channel.send(embed=embed)&#xA;            &#xA;            # Sau khi lấy th&#xF4;ng tin của b&#xE0;i h&#xE1;t diễn ra, gọi h&#xE0;m log_song_title với title của b&#xE0;i h&#xE1;t&#xA;            # V&#xED; dụ:&#xA;            title = data[&#x27;entries&#x27;][0][&#x27;title&#x27;]&#xA;            await log_song_title(title)&#xA;&#xA;            # Th&#xEA;m v&#xE0;o danh s&#xE1;ch chờ nếu c&#xF3; b&#xE0;i h&#xE1;t đang ph&#xE1;t&#xA;            if voice_client.is_playing():&#xA;                queues.setdefault(guild_id, []).append(player)&#xA;            else:&#xA;                voice_client.play(player)&#xA;                &#xA;        except Exception as e:&#xA;            print(e)&#xA;            &#xA;    if message.content.startswith("!link"):&#xA;            try:&#xA;                voice_client = await message.author.voice.channel.connect()&#xA;                voice_clients[voice_client.guild.id] = voice_client&#xA;            except Exception as e:&#xA;                print(e)&#xA;&#xA;            try:&#xA;                url = message.content.split()[1]&#xA;&#xA;                loop = asyncio.get_event_loop()&#xA;                data = await loop.run_in_executor(None, lambda: ytdl.extract_info(url, download=False))&#xA;&#xA;                song = data[&#x27;url&#x27;]&#xA;                player = discord.FFmpegOpusAudio(song, **ffmpeg_options)&#xA;&#xA;                voice_clients[message.guild.id].play(player)&#xA;            except Exception as e:&#xA;                print(e)&#xA;&#xA;    # Xử l&#xFD; lệnh !queue&#xA;    elif message.content.startswith("!queue"):&#xA;        queue = queues.get(guild_id, [])&#xA;        if queue:&#xA;            await message.channel.send("Danh s&#xE1;ch chờ:")&#xA;            for index, item in enumerate(queue, 1):&#xA;                await message.channel.send(f"{index}. {item.title}")&#xA;        else:&#xA;            await message.channel.send("Kh&#xF4;ng c&#xF3; b&#xE0;i h&#xE1;t n&#xE0;o trong danh s&#xE1;ch chờ.")&#xA;&#xA;    # Xử l&#xFD; lệnh !skip&#xA;    elif message.content.startswith("!skip"):&#xA;        try:&#xA;            if voice_client and voice_client.is_playing():&#xA;                voice_client.stop()&#xA;                await play_next_song(guild_id, queues, voice_client, skip=True)&#xA;                await remove_first_line_from_log()&#xA;        except Exception as e:&#xA;            print(e)&#xA;&#xA;    # Xử l&#xFD; c&#xE1;c lệnh như !pause, !resume, !stop&#xA;    elif message.content.startswith("!pause"):&#xA;        try:&#xA;            if voice_client and voice_client.is_playing():&#xA;                voice_client.pause()&#xA;        except Exception as e:&#xA;            print(e)&#xA;&#xA;    elif message.content.startswith("!resume"):&#xA;        try:&#xA;            if voice_client and not voice_client.is_playing():&#xA;                voice_client.resume()&#xA;        except Exception as e:&#xA;            print(e)&#xA;&#xA;    elif message.content.startswith("!stop"):&#xA;        try:&#xA;            if voice_client:&#xA;                voice_client.stop()&#xA;                await voice_client.disconnect()&#xA;                del voice_clients[guild_id]  # X&#xF3;a voice_client sau khi dừng&#xA;        except Exception as e:&#xA;            print(e)&#xA;&#xA;async def log_song_title(title):&#xA;    log_file_path = "C:\\Bot Music 2\\song_log.txt"&#xA;    try:&#xA;        # Kiểm tra xem tệp tin log đ&#xE3; tồn tại chưa&#xA;        if not os.path.exists(log_file_path):&#xA;            # Nếu chưa tồn tại, tạo tệp tin mới v&#xE0; ghi title v&#xE0;o tệp tin đ&#xF3;&#xA;            with open(log_file_path, &#x27;w&#x27;, encoding=&#x27;utf-8&#x27;) as file:&#xA;                file.write(title &#x2B; &#x27;\n&#x27;)&#xA;        else:&#xA;            # Nếu tệp tin log đ&#xE3; tồn tại, mở tệp tin v&#xE0; ch&#xE8;n title v&#xE0;o cuối tệp tin&#xA;            with open(log_file_path, &#x27;a&#x27;, encoding=&#x27;utf-8&#x27;) as file:&#xA;                file.write(title &#x2B; &#x27;\n&#x27;)&#xA;    except Exception as e:&#xA;        print(f"Error logging song title: {e}")&#xA;&#xA;async def remove_first_line_from_log():&#xA;    log_file_path = "C:\\Bot Music 2\\song_log.txt"&#xA;    try:&#xA;        with open(log_file_path, "r", encoding="utf-8") as f:&#xA;            lines = f.readlines()&#xA;        # X&#xF3;a d&#xF2;ng đầu ti&#xEA;n trong list lines&#xA;        lines = lines[1:]&#xA;        with open(log_file_path, "w", encoding="utf-8") as f:&#xA;            for line in lines:&#xA;                f.write(line)&#xA;    except Exception as e:&#xA;        print(f"Error removing first line from log: {e}")&#xA;        &#xA;async def clear_log_file():&#xA;    log_file_path = "C:\\Bot Music 2\\song_log.txt"&#xA;    try:&#xA;        with open(log_file_path, "w", encoding="utf-8") as f:&#xA;            f.truncate(0)&#xA;    except Exception as e:&#xA;        print(f"Error clearing log file: {e}")&#xA;&#xA;&#xA;async def play_next_song(guild_id, queues, voice_client, skip=False):&#xA;    queue = queues.get(guild_id, [])&#xA;    if queue:&#xA;        player = queue.pop(0)&#xA;        voice_client.play(player, after=lambda e: asyncio.run_coroutine_threadsafe(play_next_song(guild_id, queues, voice_client, skip=False), voice_client.loop))&#xA;        if skip:&#xA;            return&#xA;        else:&#xA;            await remove_first_line_from_log()  # X&#xF3;a d&#xF2;ng đầu ti&#xEA;n trong file log&#xA;    elif skip:&#xA;        await remove_first_line_from_log()  # X&#xF3;a d&#xF2;ng đầu ti&#xEA;n trong file log&#xA;        await voice_client.disconnect()&#xA;        del voice_client[guild_id]  # X&#xF3;a voice_client sau khi dừng&#xA;    else:&#xA;        await clear_log_file()  # X&#xF3;a d&#xF2;ng đầu ti&#xEA;n trong file log&#xA;        await voice_client.disconnect()&#xA;        del voice_client[guild_id]  # X&#xF3;a voice_client sau khi dừng&#xA;

    &#xA;

    I have tried asking ChatGPT, Gemini, or Bing, and they always lead me into a loop of errors that cannot be resolved. This error only occurs when the song naturally finishes playing due to its duration. If the song is playing and I use the command !skip, the next song in the queue will play and function normally. I noticed that it seems like if a song ends naturally, the song queue is also cleared immediately. I hope someone can help me with this

    &#xA;

  • Error initializing FFmpegKit : "TypeError : Cannot read property 'getLogLevel' of null" in React Native

    9 janvier, par Md Monirozzaman khan

    I'm developing a React Native application where I need to process videos using the ffmpeg-kit-react-native library. However, I'm encountering an issue during the initialization of FFmpegKitConfig. The error message is :

    &#xA;

    ERROR  Error initializing FFmpegKit: [TypeError: Cannot read property &#x27;getLogLevel&#x27; of null]&#xA;

    &#xA;

    Here is my App.js code

    &#xA;

    &#xD;&#xA;
    &#xD;&#xA;
    import React, { useState, useEffect } from &#x27;react&#x27;;&#xA;import { StyleSheet, Text, View, TouchableOpacity, Alert, Dimensions, ScrollView, LayoutAnimation, UIManager, Platform } from &#x27;react-native&#x27;;&#xA;import * as ImagePicker from &#x27;expo-image-picker&#x27;;&#xA;import * as FileSystem from &#x27;expo-file-system&#x27;;&#xA;import { Video } from &#x27;expo-av&#x27;;&#xA;import { MaterialIcons } from &#x27;@expo/vector-icons&#x27;;&#xA;import { FFmpegKit, FFmpegKitConfig, ReturnCode } from &#x27;ffmpeg-kit-react-native&#x27;;&#xA;&#xA;const windowWidth = Dimensions.get(&#x27;window&#x27;).width;&#xA;&#xA;if (Platform.OS === &#x27;android&#x27;) {&#xA;  UIManager.setLayoutAnimationEnabledExperimental &amp;&amp; UIManager.setLayoutAnimationEnabledExperimental(true);&#xA;}&#xA;&#xA;export default function App() {&#xA;  const [videoFiles, setVideoFiles] = useState([]);&#xA;  const [isGridView, setIsGridView] = useState(false);&#xA;  const [isConverting, setIsConverting] = useState(false);&#xA;&#xA;  useEffect(() => {&#xA;    FFmpegKitConfig.init()&#xA;      .then(() => {&#xA;        console.log(&#x27;FFmpegKit initialized&#x27;);&#xA;      })&#xA;      .catch((error) => {&#xA;        console.error(&#x27;Error initializing FFmpegKit:&#x27;, error);&#xA;      });&#xA;  }, []);&#xA;&#xA;  const pickVideo = async () => {&#xA;    const { status } = await ImagePicker.requestMediaLibraryPermissionsAsync();&#xA;    if (status !== &#x27;granted&#x27;) {&#xA;      alert(&#x27;Sorry, we need media library permissions to make this work!&#x27;);&#xA;      return;&#xA;    }&#xA;&#xA;    let result = await ImagePicker.launchImageLibraryAsync({&#xA;      mediaTypes: ImagePicker.MediaTypeOptions.Videos,&#xA;      allowsMultipleSelection: true,&#xA;    });&#xA;&#xA;    if (!result.canceled &amp;&amp; result.assets.length > 0) {&#xA;      const newFiles = result.assets.filter(&#xA;        (newFile) => !videoFiles.some((existingFile) => existingFile.uri === newFile.uri)&#xA;      );&#xA;&#xA;      if (newFiles.length &lt; result.assets.length) {&#xA;        Alert.alert(&#x27;Duplicate Files&#x27;, &#x27;Some files were already added.&#x27;);&#xA;      }&#xA;&#xA;      LayoutAnimation.configureNext(LayoutAnimation.Presets.easeInEaseOut);&#xA;      setVideoFiles([...videoFiles, ...newFiles]);&#xA;    }&#xA;  };&#xA;&#xA;  const convertVideos = async () => {&#xA;    setIsConverting(true);&#xA;    const outputDir = `${FileSystem.documentDirectory}Output`;&#xA;&#xA;    const dirInfo = await FileSystem.getInfoAsync(outputDir);&#xA;    if (!dirInfo.exists) {&#xA;      await FileSystem.makeDirectoryAsync(outputDir, { intermediates: true });&#xA;    }&#xA;&#xA;    for (const video of videoFiles) {&#xA;      const { uri } = video;&#xA;      const filename = uri.split(&#x27;/&#x27;).pop();&#xA;      const outputFilePath = `${outputDir}/${filename.split(&#x27;.&#x27;).slice(0, -1).join(&#x27;.&#x27;)}_modified.mp4`;&#xA;&#xA;      const ffmpegCommand = `-y -i "${uri}" -af "atempo=1.02, bass=g=4:f=80:w=3, treble=g=4:f=3200:w=3, firequalizer=gain_entry=&#x27;entry(0,0);entry(62,2);entry(125,1.5);entry(250,1);entry(500,1);entry(1000,1);entry(2000,1.5);entry(4000,2.5);entry(8000,3);entry(16000,4)&#x27;, compand=attacks=0.05:decays=0.25:points=-80/-80-50/-15-30/-10-10/-2:soft-knee=4:gain=2, deesser, highpass=f=35, lowpass=f=17000, loudnorm=I=-16:LRA=11:TP=-1.5, volume=3.9dB" -c:v copy -c:a aac -b:a 224k -ar 48000 -threads 0 "${outputFilePath}"`;&#xA;&#xA;      try {&#xA;        const session = await FFmpegKit.execute(ffmpegCommand);&#xA;        const returnCode = await session.getReturnCode();&#xA;&#xA;        if (ReturnCode.isSuccess(returnCode)) {&#xA;          console.log(`Video converted: ${outputFilePath}`);&#xA;        } else if (ReturnCode.isCancel(returnCode)) {&#xA;          console.log(&#x27;Conversion cancelled&#x27;);&#xA;        } else {&#xA;          console.error(`FFmpeg process failed: ${session.getFailStackTrace()}`);&#xA;        }&#xA;      } catch (error) {&#xA;        console.error(`Error converting video: ${error.message}`);&#xA;      }&#xA;    }&#xA;&#xA;    setIsConverting(false);&#xA;    Alert.alert(&#x27;Conversion Complete&#x27;, &#x27;All videos have been converted.&#x27;);&#xA;  };&#xA;&#xA;  const deleteVideo = (uri) => {&#xA;    LayoutAnimation.configureNext(LayoutAnimation.Presets.easeInEaseOut);&#xA;    setVideoFiles(videoFiles.filter((video) => video.uri !== uri));&#xA;  };&#xA;&#xA;  const clearAllVideos = () => {&#xA;    LayoutAnimation.configureNext(LayoutAnimation.Presets.easeInEaseOut);&#xA;    setVideoFiles([]);&#xA;  };&#xA;&#xA;  const toggleLayout = () => {&#xA;    LayoutAnimation.configureNext(LayoutAnimation.Presets.easeInEaseOut);&#xA;    setIsGridView(!isGridView);&#xA;  };&#xA;&#xA;  return (&#xA;    <view style="{styles.container}">&#xA;      <text style="{styles.header}">Video Converter App</text>&#xA;      <touchableopacity style="{styles.addButton}">&#xA;        <text style="{styles.addButtonText}">Select or Browse Videos</text>&#xA;      </touchableopacity>&#xA;      <view style="{styles.headerContainer}">&#xA;        <text style="{styles.videoCount}">Total Videos: {videoFiles.length}</text>&#xA;        {videoFiles.length > 0 &amp;&amp; (&#xA;          &lt;>&#xA;            <touchableopacity style="{styles.clearButtonContainer}">&#xA;              <materialicons size="{24}" color="red" style="{styles.clearIcon}"></materialicons>&#xA;              <text style="{styles.clearAllText}">Clear All</text>&#xA;            </touchableopacity>&#xA;            <touchableopacity style="{styles.toggleLayoutButton}">&#xA;              <materialicons size="{24}" color="#fff"></materialicons>&#xA;            </touchableopacity>&#xA;          >&#xA;        )}&#xA;      </view>&#xA;      {isGridView ? (&#xA;        <scrollview contentcontainerstyle="{styles.gridContainer}">&#xA;          {videoFiles.map((item, index) => (&#xA;            <view key="{index}" style="{styles.videoItemGrid}">&#xA;              &#xA;              <touchableopacity>> deleteVideo(item.uri)} style={styles.deleteButtonGrid}>&#xA;                <materialicons size="{24}" color="red"></materialicons>&#xA;              </touchableopacity>&#xA;            </view>&#xA;          ))}&#xA;        </scrollview>&#xA;      ) : (&#xA;        <view style="{styles.list}">&#xA;          {videoFiles.map((item, index) => (&#xA;            <view key="{index}" style="{styles.videoItem}">&#xA;              &#xA;              <text style="{styles.fileName}">{decodeURI(item.fileName || item.uri.split(&#x27;/&#x27;).pop() || &#x27;Unknown File&#x27;)}</text>&#xA;              <touchableopacity>> deleteVideo(item.uri)} style={styles.deleteButton}>&#xA;                <materialicons size="{24}" color="red"></materialicons>&#xA;              </touchableopacity>&#xA;            </view>&#xA;          ))}&#xA;        </view>&#xA;      )}&#xA;      {videoFiles.length > 0 &amp;&amp; (&#xA;        <touchableopacity style="{styles.convertButton}" disabled="{isConverting}">&#xA;          <text style="{styles.convertButtonText}">{isConverting ? &#x27;Converting...&#x27; : &#x27;Convert&#x27;}</text>&#xA;        </touchableopacity>&#xA;      )}&#xA;    </view>&#xA;  );&#xA;}&#xA;&#xA;const styles = StyleSheet.create({&#xA;  container: {&#xA;    flex: 1,&#xA;    backgroundColor: &#x27;#fff&#x27;,&#xA;    alignItems: &#x27;center&#x27;,&#xA;    padding: 10,&#xA;  },&#xA;  header: {&#xA;    fontSize: 24,&#xA;    fontWeight: &#x27;bold&#x27;,&#xA;    marginBottom: 5,&#xA;  },&#xA;  addButton: {&#xA;    backgroundColor: &#x27;#007BFF&#x27;,&#xA;    padding: 15,&#xA;    borderRadius: 10,&#xA;    alignItems: &#x27;center&#x27;,&#xA;    marginBottom: 5,&#xA;    width: &#x27;100%&#x27;,&#xA;    elevation: 2,&#xA;    shadowColor: &#x27;#000&#x27;,&#xA;    shadowOffset: { width: 0, height: 5 },&#xA;    shadowOpacity: 0.8,&#xA;    shadowRadius: 2,&#xA;  },&#xA;  addButtonText: {&#xA;    color: &#x27;#fff&#x27;,&#xA;    fontSize: 18,&#xA;    fontWeight: &#x27;bold&#x27;,&#xA;  },&#xA;  headerContainer: {&#xA;    flexDirection: &#x27;row&#x27;,&#xA;    alignItems: &#x27;center&#x27;,&#xA;    justifyContent: &#x27;space-between&#x27;,&#xA;    width: &#x27;100%&#x27;,&#xA;    marginBottom: 10,&#xA;  },&#xA;  videoCount: {&#xA;    fontSize: 18,&#xA;  },&#xA;  clearButtonContainer: {&#xA;    flexDirection: &#x27;row&#x27;,&#xA;    alignItems: &#x27;center&#x27;,&#xA;    marginRight: 10,&#xA;  },&#xA;  clearIcon: {&#xA;    marginRight: 5,&#xA;  },&#xA;  clearAllText: {&#xA;    fontSize: 16,&#xA;    color: &#x27;red&#x27;,&#xA;    textDecorationLine: &#x27;underline&#x27;,&#xA;  },&#xA;  toggleLayoutButton: {&#xA;    backgroundColor: &#x27;#007BFF&#x27;,&#xA;    padding: 1,&#xA;    borderRadius: 8,&#xA;    alignItems: &#x27;center&#x27;,&#xA;    justifyContent: &#x27;center&#x27;,&#xA;  },&#xA;  list: {&#xA;    flex: 1,&#xA;    width: &#x27;100%&#x27;,&#xA;  },&#xA;  videoItem: {&#xA;    padding: 5,&#xA;    borderBottomColor: &#x27;#ccc&#x27;,&#xA;    borderBottomWidth: 0.7,&#xA;    flexDirection: &#x27;row&#x27;,&#xA;    alignItems: &#x27;center&#x27;,&#xA;  },&#xA;  videoItemGrid: {&#xA;    flexDirection: &#x27;column&#x27;,&#xA;    alignItems: &#x27;center&#x27;,&#xA;    margin: 4,&#xA;    borderWidth: 1,&#xA;    borderColor: &#x27;#ccc&#x27;,&#xA;    borderRadius: 8,&#xA;    padding: 2,&#xA;    position: &#x27;relative&#x27;,&#xA;  },&#xA;  thumbnail: {&#xA;    width: 70,&#xA;    height: 70,&#xA;    marginRight: 10,&#xA;  },&#xA;  thumbnailGrid: {&#xA;    width: 80,&#xA;    height: 80,&#xA;    marginBottom: 0,&#xA;  },&#xA;  fileName: {&#xA;    fontSize: 16,&#xA;    marginLeft: 10,&#xA;    flex: 1,&#xA;  },&#xA;  deleteButton: {&#xA;    marginLeft: 60,&#xA;    width: 20,&#xA;    height: 20,&#xA;  },&#xA;  deleteButtonGrid: {&#xA;    position: &#x27;absolute&#x27;,&#xA;    bottom: 5,&#xA;    right: 5,&#xA;  },&#xA;  convertButton: {&#xA;    backgroundColor: &#x27;#007BFF&#x27;,&#xA;    padding: 15,&#xA;    borderRadius: 10,&#xA;    alignItems: &#x27;center&#x27;,&#xA;    marginTop: 20,&#xA;    width: &#x27;100%&#x27;,&#xA;  },&#xA;  convertButtonText: {&#xA;    color: &#x27;#fff&#x27;,&#xA;    fontSize: 18,&#xA;    fontWeight: &#x27;bold&#x27;,&#xA;  },&#xA;  gridContainer: {&#xA;    flexDirection: &#x27;row&#x27;,&#xA;    flexWrap: &#x27;wrap&#x27;,&#xA;    justifyContent: &#x27;flex-start&#x27;,&#xA;    paddingVertical: 5,&#xA;    paddingHorizontal: 5,&#xA;    width: &#x27;100%&#x27;,&#xA;  },&#xA;});

    &#xD;&#xA;

    &#xD;&#xA;

    &#xD;&#xA;&#xA;

    App.json

    &#xA;

    &#xD;&#xA;
    &#xD;&#xA;
    {&#xA;  "expo": {&#xA;    "name": "VidoeConvert",&#xA;    "slug": "VidoeConvert",&#xA;    "version": "1.0.0",&#xA;    "orientation": "portrait",&#xA;    "icon": "./assets/icon.png",&#xA;    "userInterfaceStyle": "light",&#xA;    "splash": {&#xA;      "image": "./assets/splash.png",&#xA;      "resizeMode": "contain",&#xA;      "backgroundColor": "#ffffff"&#xA;    },&#xA;    "ios": {&#xA;      "supportsTablet": true&#xA;    },&#xA;    "android": {&#xA;      "adaptiveIcon": {&#xA;        "foregroundImage": "./assets/adaptive-icon.png",&#xA;        "backgroundColor": "#ffffff"&#xA;      },&#xA;      "package": "com.anonymous.VidoeConvert"&#xA;    },&#xA;    "web": {&#xA;      "favicon": "./assets/favicon.png"&#xA;    },&#xA;    "plugins": [&#xA;      "@config-plugins/ffmpeg-kit-react-native",&#xA;      "expo-build-properties"&#xA;    ]&#xA;  }&#xA;}

    &#xD;&#xA;

    &#xD;&#xA;

    &#xD;&#xA;&#xA;

    Package.json

    &#xA;

    &#xD;&#xA;
    &#xD;&#xA;
    {&#xA;  "name": "vidoeconvert",&#xA;  "version": "1.0.0",&#xA;  "main": "expo/AppEntry.js",&#xA;  "scripts": {&#xA;    "start": "expo start",&#xA;    "android": "expo run:android",&#xA;    "ios": "expo run:ios",&#xA;    "web": "expo start --web"&#xA;  },&#xA;  "dependencies": {&#xA;    "@config-plugins/ffmpeg-kit-react-native": "^8.0.0",&#xA;    "@expo/metro-runtime": "~3.2.1",&#xA;    "expo": "~51.0.17",&#xA;    "expo-asset": "~10.0.10",&#xA;    "expo-av": "^14.0.6",&#xA;    "expo-document-picker": "~12.0.2",&#xA;    "expo-file-system": "~17.0.1",&#xA;    "expo-image-picker": "~15.0.7",&#xA;    "expo-media-library": "~16.0.4",&#xA;    "expo-status-bar": "~1.12.1",&#xA;    "ffmpeg-kit-react-native": "^6.0.2",&#xA;    "react": "18.2.0",&#xA;    "react-dom": "18.2.0",&#xA;    "react-native": "^0.74.3",&#xA;    "react-native-document-picker": "^9.3.0",&#xA;    "react-native-ffmpeg": "^0.5.2",&#xA;    "react-native-vector-icons": "^10.1.0",&#xA;    "react-native-web": "~0.19.10",&#xA;    "expo-build-properties": "~0.12.3"&#xA;  },&#xA;  "devDependencies": {&#xA;    "@babel/core": "^7.20.0"&#xA;  },&#xA;  "private": true&#xA;}

    &#xD;&#xA;

    &#xD;&#xA;

    &#xD;&#xA;&#xA;

    Has anyone encountered a similar issue or can point me in the right direction to resolve this error ? Any help would be greatly appreciated !

    &#xA;

    How to remove the error ?

    &#xA;

    any configruation required for this project ?

    &#xA;