leandromoreira / ffmpeg-libav-tutorial

FFmpeg libav tutorial - learn how media works from basic to transmuxing, transcoding and more. Translations: πŸ‡ΊπŸ‡Έ πŸ‡¨πŸ‡³ πŸ‡°πŸ‡· πŸ‡ͺπŸ‡Έ πŸ‡»πŸ‡³ πŸ‡§πŸ‡·
https://github.com/leandromoreira/ffmpeg-libav-tutorial
BSD 3-Clause "New" or "Revised" License
9.93k stars 956 forks source link

warning messages (forced frame type (5) at 80 was changed to frame type (3)) Solution #101

Open LentilStew opened 3 years ago

LentilStew commented 3 years ago

I'm making a transcoder and I had a similar issue, console output image

I found out, that if you copy the decoded frame to a new AVFrame and free the old frame, this doesn't appear anymore new console output image

I didn't make a pull request because I tried running the 3_transcoding.c file on my computer and I didn't see this error in the console, and I also don't know if this fix, is what you are looking for, or if it was already fixed

Now, to be honest, this was harder than I thought it'd be and I had to dig into the FFmpeg command line source code and test it a lot and I think I'm missing something because I had to enforce force-cfr for the h264 to work and I'm still seeing some warning messages like warning messages (forced frame type (5) at 80 was changed to frame type (3)).

C code copyFrame function snippet

int copyFrame(AVFrame* oldFrame, AVFrame* newFrame)
{
    int response;
    newFrame->pts = oldFrame->pts;
    newFrame->format = oldFrame->format;
    newFrame->width = oldFrame->width;
    newFrame->height = oldFrame->height;
    newFrame->channels = oldFrame->channels;
    newFrame->channel_layout = oldFrame->channel_layout;
    newFrame->nb_samples = oldFrame->nb_samples;
    response = av_frame_get_buffer(newFrame, 32);
    if (response != 0)
    {
        return ERROR;
    }
    response = av_frame_copy(newFrame, oldFrame);
    if (response >= 0)
    {
        return ERROR;
    }
    response = av_frame_copy_props(newFrame, oldFrame);
    if (response == NULL)
    {
        return ERROR;
    }
    return 0;
}

I don't have much experience using github, let me know if this is not the correct use for the issues page

leandromoreira commented 3 years ago

@LentilStew thanks for sharing, I'll try it later :) (the way I made it disappear, I think was by introducing the keyint parameters)