Recherche avancée

Médias (1)

Mot : - Tags -/MediaSPIP

Autres articles (36)

  • La file d’attente de SPIPmotion

    28 novembre 2010, par

    Une file d’attente stockée dans la base de donnée
    Lors de son installation, SPIPmotion crée une nouvelle table dans la base de donnée intitulée spip_spipmotion_attentes.
    Cette nouvelle table est constituée des champs suivants : id_spipmotion_attente, l’identifiant numérique unique de la tâche à traiter ; id_document, l’identifiant numérique du document original à encoder ; id_objet l’identifiant unique de l’objet auquel le document encodé devra être attaché automatiquement ; objet, le type d’objet auquel (...)

  • 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 ;

  • Ecrire une actualité

    21 juin 2013, par

    Présentez les changements dans votre MédiaSPIP ou les actualités de vos projets sur votre MédiaSPIP grâce à la rubrique actualités.
    Dans le thème par défaut spipeo de MédiaSPIP, les actualités sont affichées en bas de la page principale sous les éditoriaux.
    Vous pouvez personnaliser le formulaire de création d’une actualité.
    Formulaire de création d’une actualité Dans le cas d’un document de type actualité, les champs proposés par défaut sont : Date de publication ( personnaliser la date de publication ) (...)

Sur d’autres sites (8502)

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

  • Sporadic "Error parsing Cues... Operation not permitted" errors when trying to generate a DASH manifest

    22 novembre 2023, par kshetline

    I have already-generated .webm audio and video files (1 audio, 3 video resolutions for each video I want to stream). The video has been generated not (directly) by ffmpeg, but HandbrakeCLI 1.7.0, with V9 encoding. The audio (which has never caused an error) is generated by ffmpeg using libvorbis.

    &#xA;

    Most of the time ffmpeg (version 6.1) creates a manifest without any problem. Sporadically, however, "Error parsing Cues" comes up (frequently with the latest videos I've been trying to process) and I can't create a manifest. Since this is happening during an automated process to process many videos for streaming, the audio and video sources are being created exactly the same way whether ffmpeg succeeds or fails in generating a manifest, making this all the more confusing.

    &#xA;

    The video files ffmpeg chokes on play perfectly well using VLC, and mediainfo doesn't show any problems with these files.

    &#xA;

    Here's the way I've been (sometimes successfully, sometimes not) generating a manifest, with extra logging added :

    &#xA;

    ffmpeg -v 9 -loglevel 99 \&#xA;  -f webm_dash_manifest -i &#x27;.\Sample Video.v480.webm&#x27; \&#xA;  -f webm_dash_manifest -i &#x27;.\Sample Video.v720.webm&#x27; \&#xA;  -f webm_dash_manifest -i &#x27;.\Sample Video.v1080.webm&#x27; \&#xA;  -f webm_dash_manifest -i &#x27;.\Sample Video.audio.webm&#x27; \&#xA;  -c copy -map 0 -map 1 -map 2 -map 3 \&#xA;  -f webm_dash_manifest -adaptation_sets "id=0,streams=0,1,2 id=1,streams=3" \&#xA;  &#x27;.\Sample Video.mpd&#x27;&#xA;

    &#xA;

    Here's the result when it fails :

    &#xA;

    ffmpeg version 6.1-full_build-www.gyan.dev Copyright (c) 2000-2023 the FFmpeg developers&#xA;  built with gcc 12.2.0 (Rev10, Built by MSYS2 project)&#xA;  configuration: --enable-gpl --enable-version3 --enable-static --pkg-config=pkgconf --disable-w32threads --disable-autodetect --enable-fontconfig --enable-iconv --enable-gnutls --enable-libxml2 --enable-gmp --enable-bzlib --enable-lzma --enable-libsnappy --enable-zlib --enable-librist --enable-libsrt --enable-libssh --enable-libzmq --enable-avisynth --enable-libbluray --enable-libcaca --enable-sdl2 --enable-libaribb24 --enable-libaribcaption --enable-libdav1d --enable-libdavs2 --enable-libuavs3d --enable-libzvbi --enable-librav1e --enable-libsvtav1 --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxavs2 --enable-libxvid --enable-libaom --enable-libjxl --enable-libopenjpeg --enable-libvpx --enable-mediafoundation --enable-libass --enable-frei0r --enable-libfreetype --enable-libfribidi --enable-libharfbuzz --enable-liblensfun --enable-libvidstab --enable-libvmaf --enable-libzimg --enable-amf --enable-cuda-llvm --enable-cuvid --enable-ffnvcodec --enable-nvdec --enable-nvenc --enable-dxva2 --enable-d3d11va --enable-libvpl --enable-libshaderc --enable-vulkan --enable-libplacebo --enable-opencl --enable-libcdio --enable-libgme --enable-libmodplug --enable-libopenmpt --enable-libopencore-amrwb --enable-libmp3lame --enable-libshine --enable-libtheora --enable-libtwolame --enable-libvo-amrwbenc --enable-libcodec2 --enable-libilbc --enable-libgsm --enable-libopencore-amrnb --enable-libopus --enable-libspeex --enable-libvorbis --enable-ladspa --enable-libbs2b --enable-libflite --enable-libmysofa --enable-librubberband --enable-libsoxr --enable-chromaprint&#xA;  libavutil      58. 29.100 / 58. 29.100&#xA;  libavcodec     60. 31.102 / 60. 31.102&#xA;  libavformat    60. 16.100 / 60. 16.100&#xA;  libavdevice    60.  3.100 / 60.  3.100&#xA;  libavfilter     9. 12.100 /  9. 12.100&#xA;  libswscale      7.  5.100 /  7.  5.100&#xA;  libswresample   4. 12.100 /  4. 12.100&#xA;  libpostproc    57.  3.100 / 57.  3.100&#xA;Splitting the commandline.&#xA;Reading option &#x27;-v&#x27; ... matched as option &#x27;v&#x27; (set logging level) with argument &#x27;9&#x27;.&#xA;Reading option &#x27;-loglevel&#x27; ... matched as option &#x27;loglevel&#x27; (set logging level) with argument &#x27;99&#x27;.&#xA;Reading option &#x27;-f&#x27; ... matched as option &#x27;f&#x27; (force format) with argument &#x27;webm_dash_manifest&#x27;.&#xA;Reading option &#x27;-i&#x27; ... matched as output url with argument &#x27;.\Sample Video.v480.webm&#x27;.&#xA;Reading option &#x27;-f&#x27; ... matched as option &#x27;f&#x27; (force format) with argument &#x27;webm_dash_manifest&#x27;.&#xA;Reading option &#x27;-i&#x27; ... matched as output url with argument &#x27;.\Sample Video.v720.webm&#x27;.&#xA;Reading option &#x27;-f&#x27; ... matched as option &#x27;f&#x27; (force format) with argument &#x27;webm_dash_manifest&#x27;.&#xA;Reading option &#x27;-i&#x27; ... matched as output url with argument &#x27;.\Sample Video.v1080.webm&#x27;.&#xA;Reading option &#x27;-f&#x27; ... matched as option &#x27;f&#x27; (force format) with argument &#x27;webm_dash_manifest&#x27;.&#xA;Reading option &#x27;-i&#x27; ... matched as output url with argument &#x27;.\Sample Video.audio.webm&#x27;.&#xA;Reading option &#x27;-c&#x27; ... matched as option &#x27;c&#x27; (codec name) with argument &#x27;copy&#x27;.&#xA;Reading option &#x27;-map&#x27; ... matched as option &#x27;map&#x27; (set input stream mapping) with argument &#x27;0&#x27;.&#xA;Reading option &#x27;-map&#x27; ... matched as option &#x27;map&#x27; (set input stream mapping) with argument &#x27;1&#x27;.&#xA;Reading option &#x27;-map&#x27; ... matched as option &#x27;map&#x27; (set input stream mapping) with argument &#x27;2&#x27;.&#xA;Reading option &#x27;-map&#x27; ... matched as option &#x27;map&#x27; (set input stream mapping) with argument &#x27;3&#x27;.&#xA;Reading option &#x27;-f&#x27; ... matched as option &#x27;f&#x27; (force format) with argument &#x27;webm_dash_manifest&#x27;.&#xA;Reading option &#x27;-adaptation_sets&#x27; ... matched as AVOption &#x27;adaptation_sets&#x27; with argument &#x27;id=0,streams=0,1,2 id=1,streams=3&#x27;.&#xA;Reading option &#x27;.\Sample Video.mpd&#x27; ... matched as output url.&#xA;Finished splitting the commandline.&#xA;Parsing a group of options: global .&#xA;Applying option v (set logging level) with argument 9.&#xA;Successfully parsed a group of options.&#xA;Parsing a group of options: input url .\Sample Video.v480.webm.&#xA;Applying option f (force format) with argument webm_dash_manifest.&#xA;Successfully parsed a group of options.&#xA;Opening an input file: .\Sample Video.v480.webm.&#xA;[webm_dash_manifest @ 000002bbcb41dc80] Opening &#x27;.\Sample Video.v480.webm&#x27; for reading&#xA;[file @ 000002bbcb41e300] Setting default whitelist &#x27;file,crypto,data&#x27;&#xA;st:0 removing common factor 1000000 from timebase&#xA;[webm_dash_manifest @ 000002bbcb41dc80] Error parsing Cues&#xA;[AVIOContext @ 000002bbcb41e5c0] Statistics: 102283 bytes read, 4 seeks&#xA;[in#0 @ 000002bbcb41dac0] Error opening input: Operation not permitted&#xA;Error opening input file .\Sample Video.v480.webm.&#xA;Error opening input files: Operation not permitted&#xA;

    &#xA;

    This is mediainfo for the offending input file, Sample Video.v480.webm :

    &#xA;

    General&#xA;Complete name                            : .\Sample Video.v480.webm&#xA;Format                                   : WebM&#xA;Format version                           : Version 2&#xA;File size                                : 628 MiB&#xA;Duration                                 : 1 h 34 min&#xA;Overall bit rate                         : 926 kb/s&#xA;Frame rate                               : 23.976 FPS&#xA;Encoded date                             : 2023-11-21 16:48:35 UTC&#xA;Writing application                      : HandBrake 1.7.0 2023111500&#xA;Writing library                          : Lavf60.16.100&#xA;&#xA;Video&#xA;ID                                       : 1&#xA;Format                                   : VP9&#xA;Format profile                           : 0&#xA;Codec ID                                 : V_VP9&#xA;Duration                                 : 1 h 34 min&#xA;Bit rate                                 : 882 kb/s&#xA;Width                                    : 720 pixels&#xA;Height                                   : 480 pixels&#xA;Display aspect ratio                     : 16:9&#xA;Frame rate mode                          : Constant&#xA;Frame rate                               : 23.976 (24000/1001) FPS&#xA;Color space                              : YUV&#xA;Chroma subsampling                       : 4:2:0&#xA;Bit depth                                : 8 bits&#xA;Bits/(Pixel*Frame)                       : 0.106&#xA;Stream size                              : 598 MiB (95%)&#xA;Default                                  : Yes&#xA;Forced                                   : No&#xA;Color range                              : Limited&#xA;Color primaries                          : BT.709&#xA;Transfer characteristics                 : BT.709&#xA;Matrix coefficients                      : BT.709&#xA;

    &#xA;

    I don't know if I need different command line options, or whether this might be an ffmpeg or Handbrake bug. It has taken many, many hours to generate these video files (VP9 is painfully slow to encode), so I hate to do a lot of this over again, especially doing it again encoding the video with ffmpeg instead of Handbrake, as Handbrake is (oddly enough, considering it uses ffmpeg under the hood) noticeably faster.

    &#xA;

    I have no idea what these "Cues" are that ffmpeg wants and can't parse, or how I would change them.

    &#xA;