Recherche avancée

Médias (0)

Mot : - Tags -/upload

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

Autres articles (112)

  • Personnaliser en ajoutant son logo, sa bannière ou son image de fond

    5 septembre 2013, par

    Certains thèmes prennent en compte trois éléments de personnalisation : l’ajout d’un logo ; l’ajout d’une bannière l’ajout d’une image de fond ;

  • Websites made ​​with MediaSPIP

    2 mai 2011, par

    This page lists some websites based on MediaSPIP.

  • Creating farms of unique websites

    13 avril 2011, par

    MediaSPIP platforms can be installed as a farm, with a single "core" hosted on a dedicated server and used by multiple websites.
    This allows (among other things) : implementation costs to be shared between several different projects / individuals rapid deployment of multiple unique sites creation of groups of like-minded sites, making it possible to browse media in a more controlled and selective environment than the major "open" (...)

Sur d’autres sites (14628)

  • "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 :

    


    import asyncio
import discord
from discord import FFmpegOpusAudio, Embed
import os

async def handle_help(message):
    embed = discord.Embed(
        title="Danh sách lệnh cho Bé Mèo",
        description="Dưới đây là các lệnh mà chủ nhân có thể bắt Bé Mèo phục vụ:",
        color=discord.Color.blue()
    )
    embed.add_field(name="!play", value="Phát một bài hát từ YouTube.", inline=False)
    embed.add_field(name="!pause", value="Tạm dừng bài hát đang phát.", inline=False)
    embed.add_field(name="!resume", value="Tiếp tục bài hát đang bị tạm dừng.", inline=False)
    embed.add_field(name="!skip", value="Chuyển đến bài hát tiếp theo trong danh sách chờ.", inline=False)
    embed.add_field(name="!stop", value="Dừng phát nhạc và cho phép Bé Mèo đi ngủ tiếp.", inline=False)
    # Thêm các lệnh khác theo cùng mẫu trên
    await message.channel.send(embed=embed)

class Song:
    def __init__(self, title, player):
        self.title = title  # Lưu trữ tiêu đề bài hát ở đây
        self.player = player

# Thêm đối tượng Song vào hàng đợi
def add_song_to_queue(guild_id, queues, song):
    queues.setdefault(guild_id, []).append(song)

async def handle_list(message, queues):
    log_file_path = "C:\\Bot Music 2\\song_log.txt"
    if os.path.exists(log_file_path):
        with open(log_file_path, "r", encoding="utf-8") as f:
            song_list = f.readlines()

        if song_list:
            embed = discord.Embed(
                title="Danh sách bài hát",
                description="Danh sách các bài hát đã phát:",
                color=discord.Color.blue()
            )

            for i, song in enumerate(song_list, start=1):
                if i == 1:
                    song = "- Đang phát: " + song.strip()
                embed.add_field(name=f"Bài hát {i}", value=song, inline=False)

            await message.channel.send(embed=embed)
        else:
            await message.channel.send("Hiện không có dữ liệu trong file log.")
    else:
        await message.channel.send("File log không tồn tại.")

async def handle_commands(message, client, queues, voice_clients, yt_dl_options, ytdl, ffmpeg_options=None, guild_id=None, data=None):
    # Nếu không có ffmpeg_options, sử dụng các thiết lập mặc định
    if ffmpeg_options is None:
        ffmpeg_options = {
            'before_options': '-reconnect 1 -reconnect_streamed 1 -reconnect_delay_max 5',
            'options': '-vn -filter:a "volume=0.25"'
        }
    
    # Khởi tạo voice_client
    if guild_id is None:
        guild_id = message.guild.id

    if guild_id in voice_clients:
        voice_client = voice_clients[guild_id]
    else:
        voice_client = None

    # Xử lý lệnh !play
    if message.content.startswith("!play"):
        try:
            # Kiểm tra xem người gửi tin nhắn có đang ở trong kênh voice không
            voice_channel = message.author.voice.channel
            # Kiểm tra xem bot có đang ở trong kênh voice của guild không
            if voice_client and voice_client.is_connected():
                await voice_client.move_to(voice_channel)
            else:
                voice_client = await voice_channel.connect()
                voice_clients[guild_id] = voice_client
        except Exception as e:
            print(e)

        try:
            query = ' '.join(message.content.split()[1:])
            if query.startswith('http'):
                url = query
            else:
                query = 'ytsearch:' + query
                loop = asyncio.get_event_loop()
                data = await loop.run_in_executor(None, lambda: ytdl.extract_info(query, download=False))
                if not data:
                    raise ValueError("Không có dữ liệu trả về từ YouTube.")
                url = data['entries'][0]['url']

            player = FFmpegOpusAudio(url, **ffmpeg_options)
            # Lấy thông tin của bài hát mới đang được yêu cầu
            title = data['entries'][0]['title']
            duration = data['entries'][0]['duration']
            creator = data['entries'][0]['creator'] if 'creator' in data['entries'][0] else "Unknown"
            requester = message.author.nick if message.author.nick else message.author.name
                    
            # Tạo embed để thông báo thông tin bài hát mới
            embed = discord.Embed(
                title="Thông tin bài hát mới",
                description=f"**Bài hát:** *{title}*\n**Thời lượng:** *{duration}*\n**Tác giả:** *{creator}*\n**Người yêu cầu:** *{requester}*",
                color=discord.Color.green()
            )
            await message.channel.send(embed=embed)
            
            # Sau khi lấy thông tin của bài hát diễn ra, gọi hàm log_song_title với title của bài hát
            # Ví dụ:
            title = data['entries'][0]['title']
            await log_song_title(title)

            # Thêm vào danh sách chờ nếu có bài hát đang phát
            if voice_client.is_playing():
                queues.setdefault(guild_id, []).append(player)
            else:
                voice_client.play(player)
                
        except Exception as e:
            print(e)
            
    if message.content.startswith("!link"):
            try:
                voice_client = await message.author.voice.channel.connect()
                voice_clients[voice_client.guild.id] = voice_client
            except Exception as e:
                print(e)

            try:
                url = message.content.split()[1]

                loop = asyncio.get_event_loop()
                data = await loop.run_in_executor(None, lambda: ytdl.extract_info(url, download=False))

                song = data['url']
                player = discord.FFmpegOpusAudio(song, **ffmpeg_options)

                voice_clients[message.guild.id].play(player)
            except Exception as e:
                print(e)

    # Xử lý lệnh !queue
    elif message.content.startswith("!queue"):
        queue = queues.get(guild_id, [])
        if queue:
            await message.channel.send("Danh sách chờ:")
            for index, item in enumerate(queue, 1):
                await message.channel.send(f"{index}. {item.title}")
        else:
            await message.channel.send("Không có bài hát nào trong danh sách chờ.")

    # Xử lý lệnh !skip
    elif message.content.startswith("!skip"):
        try:
            if voice_client and voice_client.is_playing():
                voice_client.stop()
                await play_next_song(guild_id, queues, voice_client, skip=True)
                await remove_first_line_from_log()
        except Exception as e:
            print(e)

    # Xử lý các lệnh như !pause, !resume, !stop
    elif message.content.startswith("!pause"):
        try:
            if voice_client and voice_client.is_playing():
                voice_client.pause()
        except Exception as e:
            print(e)

    elif message.content.startswith("!resume"):
        try:
            if voice_client and not voice_client.is_playing():
                voice_client.resume()
        except Exception as e:
            print(e)

    elif message.content.startswith("!stop"):
        try:
            if voice_client:
                voice_client.stop()
                await voice_client.disconnect()
                del voice_clients[guild_id]  # Xóa voice_client sau khi dừng
        except Exception as e:
            print(e)

async def log_song_title(title):
    log_file_path = "C:\\Bot Music 2\\song_log.txt"
    try:
        # Kiểm tra xem tệp tin log đã tồn tại chưa
        if not os.path.exists(log_file_path):
            # Nếu chưa tồn tại, tạo tệp tin mới và ghi title vào tệp tin đó
            with open(log_file_path, 'w', encoding='utf-8') as file:
                file.write(title + '\n')
        else:
            # Nếu tệp tin log đã tồn tại, mở tệp tin và chèn title vào cuối tệp tin
            with open(log_file_path, 'a', encoding='utf-8') as file:
                file.write(title + '\n')
    except Exception as e:
        print(f"Error logging song title: {e}")

async def remove_first_line_from_log():
    log_file_path = "C:\\Bot Music 2\\song_log.txt"
    try:
        with open(log_file_path, "r", encoding="utf-8") as f:
            lines = f.readlines()
        # Xóa dòng đầu tiên trong list lines
        lines = lines[1:]
        with open(log_file_path, "w", encoding="utf-8") as f:
            for line in lines:
                f.write(line)
    except Exception as e:
        print(f"Error removing first line from log: {e}")
        
async def clear_log_file():
    log_file_path = "C:\\Bot Music 2\\song_log.txt"
    try:
        with open(log_file_path, "w", encoding="utf-8") as f:
            f.truncate(0)
    except Exception as e:
        print(f"Error clearing log file: {e}")


async def play_next_song(guild_id, queues, voice_client, skip=False):
    queue = queues.get(guild_id, [])
    if queue:
        player = queue.pop(0)
        voice_client.play(player, after=lambda e: asyncio.run_coroutine_threadsafe(play_next_song(guild_id, queues, voice_client, skip=False), voice_client.loop))
        if skip:
            return
        else:
            await remove_first_line_from_log()  # Xóa dòng đầu tiên trong file log
    elif skip:
        await remove_first_line_from_log()  # Xóa dòng đầu tiên trong file log
        await voice_client.disconnect()
        del voice_client[guild_id]  # Xóa voice_client sau khi dừng
    else:
        await clear_log_file()  # Xóa dòng đầu tiên trong file log
        await voice_client.disconnect()
        del voice_client[guild_id]  # Xóa voice_client sau khi dừng


    


    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

    


  • "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 "avcodec_send_frame" return "invalid argument"

    17 octobre 2023, par Paulo Coutinho

    I have a problem in function avcodec_send_frame throwing error Error sending frame for encoding: Invalid argument (-22). I already search, check, recheck and nothing. It is near the ffmpeg examples. Can anyone help me ? Thanks.

    &#xA;

    This is my code :

    &#xA;

    static void callbackAddSubtitle(const Message &amp;m, const Response r)&#xA;{&#xA;    try&#xA;    {&#xA;        av_log_set_level(AV_LOG_DEBUG);&#xA;&#xA;        spdlog::debug("[Mapping :: callbackAddSubtitle] Adding subtitle...");&#xA;&#xA;        auto inputOpt = m.get("input");&#xA;        auto outputOpt = m.get("output");&#xA;&#xA;        if (!inputOpt.has_value() || !outputOpt.has_value())&#xA;        {&#xA;            r(std::string{"INVALID-PARAMS"});&#xA;            return;&#xA;        }&#xA;&#xA;        const std::string &amp;input = inputOpt.value();&#xA;        const std::string &amp;output = outputOpt.value();&#xA;&#xA;        // initialize input&#xA;        spdlog::debug("[Mapping :: callbackAddSubtitle] Initializing input video...");&#xA;&#xA;        AVFormatContext *inputFormatCtx = avformat_alloc_context();&#xA;        if (avformat_open_input(&amp;inputFormatCtx, input.c_str(), nullptr, nullptr) != 0)&#xA;        {&#xA;            spdlog::error("Failed to open input");&#xA;            r(std::string{"ERROR-OPEN-INPUT"});&#xA;            return;&#xA;        }&#xA;&#xA;        if (avformat_find_stream_info(inputFormatCtx, nullptr) &lt; 0)&#xA;        {&#xA;            spdlog::error("Failed to find stream information");&#xA;            avformat_close_input(&amp;inputFormatCtx);&#xA;            r(std::string{"ERROR-FIND-STREAM"});&#xA;            return;&#xA;        }&#xA;&#xA;        int videoStreamIndex = av_find_best_stream(inputFormatCtx, AVMEDIA_TYPE_VIDEO, -1, -1, nullptr, 0);&#xA;        if (videoStreamIndex &lt; 0)&#xA;        {&#xA;            spdlog::error("Could not find a video stream");&#xA;            r(std::string{"ERROR-FIND-VIDEO-STREAM"});&#xA;            return;&#xA;        }&#xA;&#xA;        AVRational timeBase = inputFormatCtx->streams[videoStreamIndex]->time_base;&#xA;&#xA;        AVCodecParameters *inputCodecPar = inputFormatCtx->streams[videoStreamIndex]->codecpar;&#xA;        const AVCodec *inputCodec = avcodec_find_decoder(inputCodecPar->codec_id);&#xA;        AVCodecContext *inputCodecCtx = avcodec_alloc_context3(inputCodec);&#xA;&#xA;        avcodec_parameters_to_context(inputCodecCtx, inputCodecPar);&#xA;        avcodec_open2(inputCodecCtx, inputCodec, nullptr);&#xA;&#xA;        // initialize input audio&#xA;        spdlog::debug("[Mapping :: callbackAddSubtitle] Initializing input audio...");&#xA;&#xA;        int audioStreamIndex = av_find_best_stream(inputFormatCtx, AVMEDIA_TYPE_AUDIO, -1, -1, nullptr, 0);&#xA;        if (audioStreamIndex &lt; 0)&#xA;        {&#xA;            spdlog::error("Could not find an audio stream");&#xA;            r(std::string{"ERROR-FIND-AUDIO-STREAM"});&#xA;            return;&#xA;        }&#xA;&#xA;        AVCodecParameters *inputAudioCodecPar = inputFormatCtx->streams[audioStreamIndex]->codecpar;&#xA;        const AVCodec *inputAudioCodec = avcodec_find_decoder(inputAudioCodecPar->codec_id);&#xA;        AVCodecContext *inputAudioCodecCtx = avcodec_alloc_context3(inputAudioCodec);&#xA;&#xA;        avcodec_parameters_to_context(inputAudioCodecCtx, inputAudioCodecPar);&#xA;        avcodec_open2(inputAudioCodecCtx, inputAudioCodec, nullptr);&#xA;&#xA;        // initialize output video&#xA;        spdlog::debug("[Mapping :: callbackAddSubtitle] Initializing output video...");&#xA;&#xA;        AVFormatContext *outputFormatCtx = nullptr;&#xA;        avformat_alloc_output_context2(&amp;outputFormatCtx, nullptr, nullptr, output.c_str());&#xA;        AVStream *outputStream = avformat_new_stream(outputFormatCtx, nullptr);&#xA;&#xA;        AVCodecContext *outputCodecCtx = avcodec_alloc_context3(inputCodec);&#xA;        avcodec_parameters_to_context(outputCodecCtx, inputCodecPar);&#xA;        int retOutVideo = avcodec_open2(outputCodecCtx, inputCodec, nullptr);&#xA;&#xA;        if (retOutVideo &lt; 0)&#xA;        {&#xA;            char err[AV_ERROR_MAX_STRING_SIZE];&#xA;            av_make_error_string(err, AV_ERROR_MAX_STRING_SIZE, retOutVideo);&#xA;            spdlog::error("Failed to initialize output video: {}", err);&#xA;            r(std::string{"ERROR-INIT-OUTPUT-VIDEO"});&#xA;            return;&#xA;        }&#xA;&#xA;        outputStream->codecpar->codec_type = AVMEDIA_TYPE_VIDEO;&#xA;        outputStream->codecpar->codec_id = inputCodec->id;&#xA;        avcodec_parameters_from_context(outputStream->codecpar, outputCodecCtx);&#xA;&#xA;        if (!(outputFormatCtx->oformat->flags &amp; AVFMT_NOFILE))&#xA;        {&#xA;            avio_open(&amp;outputFormatCtx->pb, output.c_str(), AVIO_FLAG_WRITE);&#xA;        }&#xA;&#xA;        const char *pixelFormatName = getPixelFormatName(outputCodecCtx->pix_fmt);&#xA;        spdlog::debug("Pixel Format: {}", pixelFormatName);&#xA;&#xA;        // initialize output audio&#xA;        spdlog::debug("[Mapping :: callbackAddSubtitle] Initializing output audio...");&#xA;&#xA;        AVStream *outputAudioStream = avformat_new_stream(outputFormatCtx, nullptr);&#xA;        AVCodecContext *outputAudioCodecCtx = avcodec_alloc_context3(inputAudioCodec);&#xA;        avcodec_parameters_to_context(outputAudioCodecCtx, inputAudioCodecPar);&#xA;        int retOutAudio = avcodec_open2(outputAudioCodecCtx, inputAudioCodec, nullptr);&#xA;&#xA;        if (retOutAudio &lt; 0)&#xA;        {&#xA;            char err[AV_ERROR_MAX_STRING_SIZE];&#xA;            av_make_error_string(err, AV_ERROR_MAX_STRING_SIZE, retOutAudio);&#xA;            spdlog::error("Failed to initialize output audio: {}", err);&#xA;            r(std::string{"ERROR-INIT-OUTPUT-AUDIO"});&#xA;            return;&#xA;        }&#xA;&#xA;        outputAudioStream->codecpar->codec_type = AVMEDIA_TYPE_AUDIO;&#xA;        outputAudioStream->codecpar->codec_id = inputAudioCodec->id;&#xA;        avcodec_parameters_from_context(outputAudioStream->codecpar, outputAudioCodecCtx);&#xA;&#xA;        // initialize filters&#xA;        spdlog::debug("[Mapping :: callbackAddSubtitle] Initializing filters...");&#xA;&#xA;        AVFilterGraph *filterGraph = avfilter_graph_alloc();&#xA;        if (!filterGraph)&#xA;        {&#xA;            spdlog::error("Failed to allocate filter graph");&#xA;            r(std::string{"ERROR-FILTER-GRAPH"});&#xA;            return;&#xA;        }&#xA;&#xA;        AVFilterContext *bufferSinkCtx;&#xA;        AVFilterContext *bufferSrcCtx;&#xA;&#xA;        const AVFilter *bufferSink = avfilter_get_by_name("buffersink");&#xA;        const AVFilter *bufferSrc = avfilter_get_by_name("buffer");&#xA;&#xA;        // input filter&#xA;        char filterInArgs[512];&#xA;        snprintf(filterInArgs, sizeof(filterInArgs), "video_size=%dx%d:pix_fmt=%d:time_base=%d/%d:pixel_aspect=%d/%d", inputCodecPar->width, inputCodecPar->height, inputCodecCtx->pix_fmt, timeBase.num, timeBase.den, inputCodecCtx->sample_aspect_ratio.num, inputCodecCtx->sample_aspect_ratio.den);&#xA;&#xA;        spdlog::debug("[Mapping :: callbackAddSubtitle] Buffer src args: {}", filterInArgs);&#xA;&#xA;        int retFilterIn = avfilter_graph_create_filter(&amp;bufferSrcCtx, bufferSrc, "in", filterInArgs, nullptr, filterGraph);&#xA;        if (retFilterIn &lt; 0)&#xA;        {&#xA;            char err[AV_ERROR_MAX_STRING_SIZE];&#xA;            av_make_error_string(err, AV_ERROR_MAX_STRING_SIZE, retFilterIn);&#xA;            spdlog::error("Failed to create bufferSrcCtx: {}", err);&#xA;            r(std::string{"ERROR-CREATE-FILTER-SRC"});&#xA;            return;&#xA;        }&#xA;&#xA;        // output filter&#xA;        int retFilterOut = avfilter_graph_create_filter(&amp;bufferSinkCtx, bufferSink, "out", nullptr, nullptr, filterGraph);&#xA;&#xA;        if (retFilterOut &lt; 0)&#xA;        {&#xA;            char err[AV_ERROR_MAX_STRING_SIZE];&#xA;            av_make_error_string(err, AV_ERROR_MAX_STRING_SIZE, retFilterOut);&#xA;            spdlog::error("Failed to create bufferSinkCtx: {}", err);&#xA;            r(std::string{"ERROR-CREATE-FILTER-SINK"});&#xA;            return;&#xA;        }&#xA;&#xA;        enum AVPixelFormat pix_fmts[] = {AV_PIX_FMT_YUV420P, AV_PIX_FMT_NONE};&#xA;        av_opt_set_int_list(bufferSinkCtx, "pix_fmts", pix_fmts, AV_PIX_FMT_NONE, AV_OPT_SEARCH_CHILDREN);&#xA;&#xA;        // add filters to graph and link them&#xA;        const char *filterSpec = "drawtext=text=&#x27;Legenda Adicionada Automaticamente Via FFMPEG e C&#x2B;&#x2B;&#x27;: fontcolor=yellow: bordercolor=black: fontfile=&#x27;/Users/paulo/Downloads/roboto/Roboto-Black.ttf&#x27;";&#xA;        const AVFilter *filter = avfilter_get_by_name("drawtext");&#xA;&#xA;        AVFilterInOut *outputs = avfilter_inout_alloc();&#xA;        AVFilterInOut *inputs = avfilter_inout_alloc();&#xA;&#xA;        outputs->name = av_strdup("in");&#xA;        outputs->filter_ctx = bufferSrcCtx;&#xA;        outputs->pad_idx = 0;&#xA;        outputs->next = nullptr;&#xA;        inputs->name = av_strdup("out");&#xA;        inputs->filter_ctx = bufferSinkCtx;&#xA;        inputs->pad_idx = 0;&#xA;        inputs->next = nullptr;&#xA;&#xA;        if (avfilter_graph_parse_ptr(filterGraph, filterSpec, &amp;inputs, &amp;outputs, nullptr) &lt; 0)&#xA;        {&#xA;            spdlog::error("Failed to parse filter graph");&#xA;            r(std::string{"ERROR-PARSE-FILTER"});&#xA;            return;&#xA;        }&#xA;&#xA;        if (avfilter_graph_config(filterGraph, nullptr) &lt; 0)&#xA;        {&#xA;            spdlog::error("Failed to configure filter graph");&#xA;            r(std::string{"ERROR-CONFIG-FILTER"});&#xA;            return;&#xA;        }&#xA;&#xA;        // header&#xA;        spdlog::debug("[Mapping :: callbackAddSubtitle] Writing header...");&#xA;&#xA;        if (avformat_write_header(outputFormatCtx, nullptr) &lt; 0)&#xA;        {&#xA;            spdlog::error("Error writing header");&#xA;            r(std::string{"ERROR-WRITE-HEADER"});&#xA;            return;&#xA;        }&#xA;&#xA;        // read frames and write to output&#xA;        AVPacket *packet = av_packet_alloc();&#xA;        AVFrame *frame = av_frame_alloc();&#xA;&#xA;        frame->format = inputCodecCtx->pix_fmt;&#xA;        frame->width = inputCodecCtx->width;&#xA;        frame->height = inputCodecCtx->height;&#xA;&#xA;        AVFrame *filt_frame = av_frame_alloc();&#xA;&#xA;        filt_frame->format = inputCodecCtx->pix_fmt;&#xA;        filt_frame->width = inputCodecCtx->width;&#xA;        filt_frame->height = inputCodecCtx->height;&#xA;&#xA;        while (av_read_frame(inputFormatCtx, packet) >= 0)&#xA;        {&#xA;            if (packet->stream_index == videoStreamIndex)&#xA;            {&#xA;                if (avcodec_send_packet(inputCodecCtx, packet) &lt; 0)&#xA;                {&#xA;                    spdlog::error("Error sending packet for decoding");&#xA;                    r(std::string{"ERROR-SEND-PACKET-DECODE"});&#xA;                    return;&#xA;                }&#xA;&#xA;                while (avcodec_receive_frame(inputCodecCtx, frame) == 0)&#xA;                {&#xA;                    // Envia o quadro decodificado para o gr&#xE1;fico de filtro&#xA;                    if (av_buffersrc_add_frame_flags(bufferSrcCtx, frame, AV_BUFFERSRC_FLAG_KEEP_REF) &lt; 0)&#xA;                    {&#xA;                        spdlog::error("Error while feeding the filtergraph");&#xA;                        r(std::string{"ERROR-FEED-FILTERGRAPH"});&#xA;                        return;&#xA;                    }&#xA;&#xA;                    // Recebe um quadro do gr&#xE1;fico de filtro&#xA;                    if (av_buffersink_get_frame(bufferSinkCtx, filt_frame) &lt; 0)&#xA;                    {&#xA;                        spdlog::error("Error while receiving the filtered frame");&#xA;                        r(std::string{"ERROR-RECEIVE-FILTERED-FRAME"});&#xA;                        return;&#xA;                    }&#xA;&#xA;                    // Envia o quadro decodificado para re-codifica&#xE7;&#xE3;o&#xA;                    int retSendFrame = avcodec_send_frame(outputCodecCtx, filt_frame);&#xA;                    if (retSendFrame &lt; 0)&#xA;                    {&#xA;                        char err[AV_ERROR_MAX_STRING_SIZE];&#xA;                        av_make_error_string(err, AV_ERROR_MAX_STRING_SIZE, retSendFrame);&#xA;                        spdlog::error("Error sending frame for encoding: {}", err);&#xA;                        r(std::string{"ERROR-SEND-FRAME-ENCODE"});&#xA;                        return;&#xA;                    }&#xA;&#xA;                    AVPacket *output_packet = av_packet_alloc();&#xA;                    output_packet->data = nullptr;&#xA;                    output_packet->size = 0;&#xA;&#xA;                    // Re-codifica filt_frame para um pacote&#xA;                    if (avcodec_receive_packet(outputCodecCtx, output_packet) == 0)&#xA;                    {&#xA;                        // Escreve o pacote no fluxo de sa&#xED;da&#xA;                        av_write_frame(outputFormatCtx, output_packet);&#xA;                        av_packet_unref(output_packet);&#xA;                    }&#xA;&#xA;                    av_frame_unref(filt_frame);&#xA;                }&#xA;&#xA;                // time&#xA;                packet->pts = av_rescale_q_rnd(packet->pts, inputFormatCtx->streams[videoStreamIndex]->time_base, outputFormatCtx->streams[videoStreamIndex]->time_base, (AVRounding)(AV_ROUND_NEAR_INF | AV_ROUND_PASS_MINMAX));&#xA;                packet->dts = av_rescale_q_rnd(packet->dts, inputFormatCtx->streams[videoStreamIndex]->time_base, outputFormatCtx->streams[videoStreamIndex]->time_base, (AVRounding)(AV_ROUND_NEAR_INF | AV_ROUND_PASS_MINMAX));&#xA;                packet->duration = av_rescale_q(packet->duration, inputFormatCtx->streams[videoStreamIndex]->time_base, outputFormatCtx->streams[videoStreamIndex]->time_base);&#xA;                packet->stream_index = videoStreamIndex;&#xA;&#xA;                // write packet to output video stream&#xA;                av_interleaved_write_frame(outputFormatCtx, packet);&#xA;            }&#xA;            else if (packet->stream_index == audioStreamIndex)&#xA;            {&#xA;                // rescale timestamps&#xA;                packet->pts = av_rescale_q_rnd(packet->pts, inputFormatCtx->streams[audioStreamIndex]->time_base, outputFormatCtx->streams[audioStreamIndex]->time_base, (AVRounding)(AV_ROUND_NEAR_INF | AV_ROUND_PASS_MINMAX));&#xA;                packet->dts = av_rescale_q_rnd(packet->dts, inputFormatCtx->streams[audioStreamIndex]->time_base, outputFormatCtx->streams[audioStreamIndex]->time_base, (AVRounding)(AV_ROUND_NEAR_INF | AV_ROUND_PASS_MINMAX));&#xA;                packet->duration = av_rescale_q(packet->duration, inputFormatCtx->streams[audioStreamIndex]->time_base, outputFormatCtx->streams[audioStreamIndex]->time_base);&#xA;                packet->stream_index = audioStreamIndex;&#xA;&#xA;                // write packet to output audio stream&#xA;                av_interleaved_write_frame(outputFormatCtx, packet);&#xA;            }&#xA;&#xA;            av_packet_unref(packet);&#xA;        }&#xA;&#xA;        av_packet_free(&amp;packet);&#xA;        av_frame_free(&amp;frame);&#xA;        av_frame_free(&amp;filt_frame);&#xA;&#xA;        spdlog::debug("[Mapping :: callbackAddSubtitle] Writing trailer...");&#xA;&#xA;        if (av_write_trailer(outputFormatCtx) &lt; 0)&#xA;        {&#xA;            spdlog::error("Error writing trailer");&#xA;            r(std::string{"ERROR-WRITE-TRAILER"});&#xA;            return;&#xA;        }&#xA;&#xA;        // cleanup&#xA;        spdlog::debug("[Mapping :: callbackAddSubtitle] Cleaning...");&#xA;&#xA;        if (!(outputFormatCtx->oformat->flags &amp; AVFMT_NOFILE))&#xA;        {&#xA;            avio_closep(&amp;outputFormatCtx->pb);&#xA;        }&#xA;&#xA;        avcodec_free_context(&amp;inputCodecCtx);&#xA;        avcodec_free_context(&amp;inputAudioCodecCtx);&#xA;        avcodec_free_context(&amp;outputCodecCtx);&#xA;        avcodec_free_context(&amp;outputAudioCodecCtx);&#xA;&#xA;        avformat_free_context(inputFormatCtx);&#xA;        avformat_free_context(outputFormatCtx);&#xA;&#xA;        r(std::string{"OK"});&#xA;    }&#xA;    catch (const std::exception &amp;e)&#xA;    {&#xA;        spdlog::error("Error: {}", e.what());&#xA;        r(std::string{"ERROR"});&#xA;    }&#xA;}&#xA;

    &#xA;

    The error is :

    &#xA;

    [2023-10-17 06:30:16.936] [debug] [Mapping :: callbackAddSubtitle] Adding subtitle...&#xA;[2023-10-17 06:30:16.936] [debug] [Mapping :: callbackAddSubtitle] Initializing input video...&#xA;[NULL @ 0x153604a60] Opening &#x27;/Users/paulo/Downloads/movie.mp4&#x27; for reading&#xA;[file @ 0x6000001fd170] Setting default whitelist &#x27;file,crypto,data&#x27;&#xA;[mov,mp4,m4a,3gp,3g2,mj2 @ 0x153604a60] Format mov,mp4,m4a,3gp,3g2,mj2 probed with size=2048 and score=100&#xA;[mov,mp4,m4a,3gp,3g2,mj2 @ 0x153604a60] ISO: File Type Major Brand: isom&#xA;[mov,mp4,m4a,3gp,3g2,mj2 @ 0x153604a60] Unknown dref type 0x206c7275 size 12&#xA;[mov,mp4,m4a,3gp,3g2,mj2 @ 0x153604a60] Processing st: 0, edit list 0 - media time: 0, duration: 2669670&#xA;[mov,mp4,m4a,3gp,3g2,mj2 @ 0x153604a60] Unknown dref type 0x206c7275 size 12&#xA;[mov,mp4,m4a,3gp,3g2,mj2 @ 0x153604a60] Processing st: 1, edit list 0 - media time: 1024, duration: 4272096&#xA;[mov,mp4,m4a,3gp,3g2,mj2 @ 0x153604a60] drop a frame at curr_cts: 0 @ 0&#xA;[mov,mp4,m4a,3gp,3g2,mj2 @ 0x153604a60] Before avformat_find_stream_info() pos: 113542488 bytes read:110788 seeks:1 nb_streams:2&#xA;[h264 @ 0x153604cd0] nal_unit_type: 7(SPS), nal_ref_idc: 3&#xA;[h264 @ 0x153604cd0] Decoding VUI&#xA;[h264 @ 0x153604cd0] nal_unit_type: 8(PPS), nal_ref_idc: 3&#xA;[mov,mp4,m4a,3gp,3g2,mj2 @ 0x153604a60] demuxer injecting skip 1024 / discard 0&#xA;[aac @ 0x1536056f0] skip 1024 / discard 0 samples due to side data&#xA;[h264 @ 0x153604cd0] nal_unit_type: 7(SPS), nal_ref_idc: 3&#xA;[h264 @ 0x153604cd0] Decoding VUI&#xA;[h264 @ 0x153604cd0] nal_unit_type: 8(PPS), nal_ref_idc: 3&#xA;[h264 @ 0x153604cd0] nal_unit_type: 6(SEI), nal_ref_idc: 0&#xA;[h264 @ 0x153604cd0] nal_unit_type: 5(IDR), nal_ref_idc: 3&#xA;[h264 @ 0x153604cd0] Format yuv420p chosen by get_format().&#xA;[h264 @ 0x153604cd0] Reinit context to 1088x1920, pix_fmt: yuv420p&#xA;[mov,mp4,m4a,3gp,3g2,mj2 @ 0x153604a60] All info found&#xA;[mov,mp4,m4a,3gp,3g2,mj2 @ 0x153604a60] After avformat_find_stream_info() pos: 195211 bytes read:305951 seeks:2 frames:2&#xA;[2023-10-17 06:30:18.160] [debug] [Mapping :: callbackAddSubtitle] Initializing input audio...&#xA;[h264 @ 0x143604330] nal_unit_type: 7(SPS), nal_ref_idc: 3&#xA;[h264 @ 0x143604330] Decoding VUI&#xA;[h264 @ 0x143604330] nal_unit_type: 8(PPS), nal_ref_idc: 3&#xA;[2023-10-17 06:30:18.160] [debug] [Mapping :: callbackAddSubtitle] Initializing output video...&#xA;[h264 @ 0x143611ec0] nal_unit_type: 7(SPS), nal_ref_idc: 3&#xA;[h264 @ 0x143611ec0] Decoding VUI&#xA;[h264 @ 0x143611ec0] nal_unit_type: 8(PPS), nal_ref_idc: 3&#xA;[file @ 0x6000001f4000] Setting default whitelist &#x27;file,crypto,data&#x27;&#xA;[2023-10-17 06:30:18.167] [debug] Pixel Format: YUV420P&#xA;[2023-10-17 06:30:18.167] [debug] [Mapping :: callbackAddSubtitle] Initializing output audio...&#xA;[2023-10-17 06:30:18.167] [debug] [Mapping :: callbackAddSubtitle] Initializing filters...&#xA;[2023-10-17 06:30:18.168] [debug] [Mapping :: callbackAddSubtitle] Buffer src args: video_size=1080x1920:pix_fmt=0:time_base=1/30000:pixel_aspect=1/1&#xA;detected 10 logical cores&#xA;[in @ 0x6000004ec0b0] Setting &#x27;video_size&#x27; to value &#x27;1080x1920&#x27;&#xA;[in @ 0x6000004ec0b0] Setting &#x27;pix_fmt&#x27; to value &#x27;0&#x27;&#xA;[in @ 0x6000004ec0b0] Setting &#x27;time_base&#x27; to value &#x27;1/30000&#x27;&#xA;[in @ 0x6000004ec0b0] Setting &#x27;pixel_aspect&#x27; to value &#x27;1/1&#x27;&#xA;[in @ 0x6000004ec0b0] w:1080 h:1920 pixfmt:yuv420p tb:1/30000 fr:0/1 sar:1/1&#xA;[AVFilterGraph @ 0x6000017e8000] Setting &#x27;text&#x27; to value &#x27;Legenda Adicionada Automaticamente Via FFMPEG e C&#x2B;&#x2B;&#x27;&#xA;[AVFilterGraph @ 0x6000017e8000] Setting &#x27;fontcolor&#x27; to value &#x27;yellow&#x27;&#xA;[AVFilterGraph @ 0x6000017e8000] Setting &#x27;bordercolor&#x27; to value &#x27;black&#x27;&#xA;[AVFilterGraph @ 0x6000017e8000] Setting &#x27;fontfile&#x27; to value &#x27;/Users/paulo/Downloads/roboto/Roboto-Black.ttf&#x27;&#xA;[AVFilterGraph @ 0x6000017e8000] query_formats: 3 queried, 2 merged, 0 already done, 0 delayed&#xA;[2023-10-17 06:30:18.172] [debug] [Mapping :: callbackAddSubtitle] Writing header...&#xA;[h264 @ 0x143604330] nal_unit_type: 6(SEI), nal_ref_idc: 0&#xA;[h264 @ 0x143604330] nal_unit_type: 5(IDR), nal_ref_idc: 3&#xA;[h264 @ 0x143604330] Format yuv420p chosen by get_format().&#xA;[h264 @ 0x143604330] Reinit context to 1088x1920, pix_fmt: yuv420p&#xA;[Parsed_drawtext_0 @ 0x6000004f4160] Copying data in avfilter.&#xA;[Parsed_drawtext_0 @ 0x6000004f4160] n:0 t:0.000000 text_w:424 text_h:16 x:0 y:0&#xA;[2023-10-17 06:30:18.182] [error] Error sending frame for encoding: Invalid argument&#xA;Returned Value: ERROR-SEND-FRAME-ENCODE&#xA;

    &#xA;