| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1304 人关注过本帖
标题:求助 E0513 不能将 "void *" 类型的值分配到 "AVPacketList *" 类型的实体 ...
只看楼主 加入收藏
追梦人zmrghy
Rank: 3Rank: 3
等 级:论坛游侠
帖 子:406
专家分:190
注 册:2021-4-9
结帖率:97.26%
收藏
已结贴  问题点数:20 回复次数:17 
求助 E0513 不能将 "void *" 类型的值分配到 "AVPacketList *" 类型的实体
图片附件: 游客没有浏览图片的权限,请 登录注册

图片附件: 游客没有浏览图片的权限,请 登录注册


知道,这是因为FFmpeg库版本引起的问题。
可现在使用的已经是,ffmpeg-4.4.1-full_build-shared版本了。。。
如果使用,ffmpeg-5.0.1-full_build-shared版本,有几十个错误。。。

什么地方可以下载更早的版本呀。。。
FFmpeg官网上全是英文,看不懂。。。

程序代码:
#include <assert.h>
#include <stdio.h>
#include <math.h>
#include <SDL.h>

#include <libavutil/log.h>
#include <libavutil/time.h>
#include <libavutil/avstring.h>
#include <libavformat/avformat.h>
#include <libavcodec/avcodec.h>
#include <libswscale/swscale.h>
#include <libswresample/swresample.h>

#define SDL_AUDIO_BUFFER_SIZE 1024
#define MAX_AUDIO_FRAME_SIZE 192000

#define AV_SYNC_THRESHOLD 0.01
#define AV_NOSYNC_THRESHOLD 10.0

#define MAX_AUDIOQ_SIZE (5*6*1024)      
#define MAX_VEDIOQ_SIZE (5*256*1024) 
#define FF_REFRESH_EVENT (SDL_USEREVENT)
#define FF_QUIT_EVENT (SDL_USEREVENT + 1)

#define VIDEO_PICTURE_QUEUE_SIZE 1 

typedef struct PacketQueue {
    AVPacketList* first_pkt, * last_pkt;
    int nb_packets;
    int size;
    SDL_mutex* mutex;
    SDL_cond* cond;
}PacketQueue;

typedef struct VideoPicture {
    AVPicture* pict;    
    int width, height;
    int allocated;        
    double pts;
}VideoPicture;

typedef struct VideoState {
    char filename[1024];
    AVFormatContext* pFormatCtx;
    int videoStream, audioStream;

    AVStream* audio_st;
    AVCodecContext* audio_ctx; 
    struct SwrContext* audio_swr_cxt;

    uint8_t audio_buf[(MAX_AUDIO_FRAME_SIZE * 3) / 2];
    unsigned int audio_buf_size;
    unsigned int audio_buf_index;
    PacketQueue audioq;
    AVFrame audio_frame;
    AVPacket audio_pkt;
    uint8_t* audio_pkt_data;
    int audio_pkt_size;

    AVStream* video_st;
    AVCodecContext* video_ctx;
    struct SwsContext* sws_ctx;
    PacketQueue videoq;
    VideoPicture pictq[VIDEO_PICTURE_QUEUE_SIZE];  
    int pictq_size; 
    int pictq_rindex; 
    int pictq_windex; 

    SDL_mutex* pictq_mutex;
    SDL_cond* pictq_cond;
    SDL_Thread* parse_tid;
    SDL_Thread* video_tid;

    double audio_clock;
    double video_clock;

    double frame_timer;
    double frame_last_pts;
    double frame_last_delay;


    int quit;
}VideoState;


SDL_mutex* texture_mutex;

SDL_Window* win;
SDL_Renderer* renderer;
SDL_Texture* texture;

VideoState* global_video_state;

void packet_queue_init(PacketQueue* q) {
    memset(q, 0, sizeof(PacketQueue));
    q->mutex = SDL_CreateMutex();
    q->cond = SDL_CreateCond();
}

int packet_queue_get(PacketQueue* q, AVPacket* pkt, int block) {
    AVPacketList* pktl;
    int ret;

    SDL_LockMutex(q->mutex);
    for (;;) {
        if (global_video_state->quit) {
            fprintf(stderr, "quit from queue_get!\n");
            ret = -1;
            break;
        }

        pktl = q->first_pkt;
        if (pktl) {
            q->first_pkt = pktl->next;
            if (!q->first_pkt)
                q->last_pkt = NULL;
            q->nb_packets--;
            q->size -= pktl->pkt.size;
            *pkt = pktl->pkt;
            av_free(pktl);
            ret = 1;
            break;
        }
        else if (!block) {
            ret = 0;
            break;
        }
        else {
            fprintf(stderr, "queue is empty, so wait a moment and wait a cond signal!\n");
            SDL_CondWait(q->cond, q->mutex);
        }
    }
    SDL_UnlockMutex(q->mutex);
    return ret;
}

int packet_queue_put(PacketQueue* q, AVPacket* pkt) {
    AVPacketList* pktl;

    if (av_dup_packet(pkt) < 0) {
        return -1;
    }

    pktl = av_malloc(sizeof(AVPacketList));
    if (!pktl) 
    {
        return -1;
    }

    pktl->pkt = *pkt;
    pktl->next = NULL;

    SDL_LockMutex(q->mutex);
    if (!q->last_pkt)
        q->first_pkt = pktl;
    else
        q->last_pkt->next = pktl;
    q->last_pkt = pktl;
    q->nb_packets++;
    q->size += pktl->pkt.size;

    SDL_CondSignal(q->cond);
    SDL_UnlockMutex(q->mutex);
    return 0;
}

double get_audio_clock(VideoState* is) {
    double pts;
    int hw_buf_size, bytes_per_sec, n;

    pts = is->audio_clock;
    hw_buf_size = is->audio_buf_size - is->audio_buf_index; 
    bytes_per_sec = 0;
    n = is->audio_ctx->channels * 2; 
    if (is->audio_st) {
        bytes_per_sec = is->audio_ctx->sample_rate * n;
    }
    if (bytes_per_sec) {
        pts -= (double)hw_buf_size / bytes_per_sec;
    }
    return pts;
}

int audio_decode_frame(VideoState* is, uint8_t* audio_buf, int buf_size, double* pts_ptr) {
    int len1, data_size = 0, n;
    AVPacket* pkt = &is->audio_pkt;
    double pts;

    for (;;) {
        while (is->audio_pkt_size > 0) {
            int got_frame = 0;
            len1 = avcodec_decode_audio4(is->audio_ctx, &is->audio_frame, &got_frame, pkt);
            if (len1 < 0) {
                printf("Failed to decode audio...\n");
                is->audio_pkt_size = 0;
                break;
            }

            data_size = 0;
            if (got_frame) {
                data_size = 2 * 2 * is->audio_frame.nb_samples;
                assert(data_size <= buf_size);

                swr_convert(is->audio_swr_cxt,
                    &audio_buf,
                    MAX_AUDIO_FRAME_SIZE * 3 / 2,
                    (const uint8_t**)is->audio_frame.data,
                    is->audio_frame.nb_samples);

                is->audio_pkt_size -= len1;
                is->audio_pkt_data += len1;
            }
            if (data_size == 0) 
                continue;
            pts = is->audio_clock;
            *pts_ptr = pts;
            n = 2 * is->audio_ctx->channels;

            is->audio_clock += (double)data_size / (double)(n * is->audio_ctx->sample_rate);    

            return data_size;
        }

        if (pkt->data)
            av_free_packet(pkt);

        if (is->quit) {
            printf("Will quit program...\n");
            return -1;
        }

        if (packet_queue_get(&is->audioq, pkt, 0) <= 0) {
            return -1;
        }

        is->audio_pkt_data = pkt->data;
        is->audio_pkt_size = pkt->size;

        if (pkt->pts != AV_NOPTS_VALUE) {
            is->audio_clock = av_q2d(is->audio_st->time_base) * pkt->pts;
        }
    }
}

void audio_callback(void* userdata, uint8_t* stream, int len) {
    VideoState* is = (VideoState*)userdata;
    int len1, audio_size;
    double pts;
    SDL_memset(stream, 0, len);

    while (len > 0) {
        if (is->audio_buf_index >= is->audio_buf_size) {
            audio_size = audio_decode_frame(is, is->audio_buf, sizeof(is->audio_buf), &pts);
            if (audio_size < 0) {
                is->audio_buf_size = 1024 * 2 * 2;
                printf("--------------no audio packet-------------------\n");
                memset(is->audio_buf, 0, is->audio_buf_size);
            }
            else {
                is->audio_buf_size = audio_size;
            }
            is->audio_buf_index = 0;
        }

        len1 = is->audio_buf_size - is->audio_buf_index;
        if (len1 > len)
            len1 = len;
        //memcpy(stream,(uint8_t*)is->audio_buf+is->audio_buf_index,len1);
        SDL_MixAudio(stream, (uint8_t*)is->audio_buf + is->audio_buf_index, len1, SDL_MIX_MAXVOLUME);
        len -= len1;
        stream += len1;
        is->audio_buf_index += len1;
    }
}


static uint32_t sdl_refresh_timer_cb(uint32_t interval, void* dat) {
    SDL_Event event;

    event.type = FF_REFRESH_EVENT;
    event.user.data1 = dat;
    SDL_PushEvent(&event);
    return 0;
}

static void schedule_refresh(VideoState* is, int delay) {
    SDL_AddTimer(delay, sdl_refresh_timer_cb, is);
}

void video_display(VideoState* is) {
    SDL_Rect rect;
    VideoPicture* vp;

    vp = &is->pictq[is->pictq_rindex];
    if (vp->pict) {
        SDL_UpdateYUVTexture(texture, NULL,
            vp->pict->data[0], vp->pict->linesize[0],
            vp->pict->data[1], vp->pict->linesize[1],
            vp->pict->data[2], vp->pict->linesize[2]);

        rect.x = 0;
        rect.y = 0;
        rect.w = is->video_ctx->width;
        rect.h = is->video_ctx->height;

        SDL_LockMutex(texture_mutex);
        SDL_RenderClear(renderer);
        SDL_RenderCopy(renderer, texture, NULL, &rect);
        SDL_RenderPresent(renderer);
        SDL_UnlockMutex(texture_mutex);
    }
}

void video_refresh_timer(void* userdata) {
    VideoState* is = (VideoState*)userdata;
    VideoPicture* vp;
    /*
    actual_delay:
    delay:
    sync_threshold 
    ref_clock:
    diff:
    */
    double actual_delay, delay, sync_threshold, ref_clock, diff;

    if (is->video_st) {
        if (is->pictq_size == 0) {
            schedule_refresh(is, 1);
        }
        else {
            vp = &is->pictq[is->pictq_rindex];

            delay = vp->pts - is->frame_last_pts;
            if (delay <= 0 || delay >= 1.0) {
                delay = is->frame_last_delay;
            }

            is->frame_last_delay = delay;
            is->frame_last_pts = vp->pts;

            ref_clock = get_audio_clock(is); 
            diff = vp->pts - ref_clock;

            sync_threshold = (delay > AV_SYNC_THRESHOLD) ? delay : AV_SYNC_THRESHOLD;
            if (fabs(diff) < AV_NOSYNC_THRESHOLD) {
                if (diff <= -sync_threshold) {
                    delay = 0;
                }
                else if (diff >= sync_threshold) {
                    delay *= 2;
                }
            }

            is->frame_timer += delay;
            actual_delay = is->frame_timer - (av_gettime() / 1000000.0);

            if (actual_delay < AV_SYNC_THRESHOLD) { 
                actual_delay = AV_SYNC_THRESHOLD; 
            }

            schedule_refresh(is, (int)(actual_delay * 1000 + 0.5));
            video_display(is);
            if (++is->pictq_rindex == VIDEO_PICTURE_QUEUE_SIZE) {
                is->pictq_rindex = 0;
            }

            SDL_LockMutex(is->pictq_mutex);
            is->pictq_size--;
            SDL_CondSignal(is->pictq_cond);
            SDL_UnlockMutex(is->pictq_mutex);
        }
    }
    else {
        schedule_refresh(is, 100);
    }
}

void alloc_picture(void* userdata) {
    VideoState* is = (VideoState*)userdata;
    VideoPicture* vp = &is->pictq[is->pictq_windex];

    if (vp->pict) {
        avpicture_free(vp->pict);
        free(vp->pict);
    }

    SDL_LockMutex(texture_mutex);
    vp->pict = (AVPicture*)malloc(sizeof(AVPicture));
    if (vp->pict) {
        avpicture_alloc(vp->pict,
            AV_PIX_FMT_YUV420P,
            is->video_ctx->width,
            is->video_ctx->height);
    }
    SDL_UnlockMutex(texture_mutex);

    vp->width = is->video_ctx->width;
    vp->height = is->video_ctx->height;
    vp->allocated = 1;
}

int queue_picture(VideoState* is, AVFrame* pFrame, double pts) {
    VideoPicture* vp;
    int dst_pix_fmt;
    AVPicture pict;

    SDL_LockMutex(is->pictq_mutex);
    while (is->pictq_size >= VIDEO_PICTURE_QUEUE_SIZE && !is->quit) {
        SDL_CondWait(is->pictq_cond, is->pictq_mutex);
    }
    SDL_UnlockMutex(is->pictq_mutex);

    if (is->quit) {
        printf("quit from queue picture...\n");
        return -1;
    }

    vp = &is->pictq[is->pictq_windex];
    if (!vp->pict ||
        vp->width != is->video_ctx->width ||
        vp->height != is->video_ctx->height) {
        vp->allocated = 0;
        alloc_picture(is); 
        if (is->quit) {
            printf("quit from queue picture 2...\n");
            return -1;
        }
    }

    if (vp->pict) {
        vp->pts = pts;

        sws_scale(is->sws_ctx, (uint8_t const* const*)pFrame->data,
            pFrame->linesize, 0, is->video_ctx->height,
            vp->pict->data, vp->pict->linesize);

        if (++is->pictq_windex == VIDEO_PICTURE_QUEUE_SIZE) {
            is->pictq_windex = 0;
        }
        SDL_LockMutex(is->pictq_mutex);
        is->pictq_size++;
        SDL_UnlockMutex(is->pictq_mutex);
    }
    return 0;
}

double synchronize_video(VideoState* is, AVFrame* src_frame, double pts) {
    double frame_delay;

    if (pts != 0) {
        is->video_clock = pts;
    }
    else {
        pts = is->video_clock;
    }

    frame_delay = av_q2d(is->video_ctx->time_base);

    frame_delay += src_frame->repeat_pict * (frame_delay * 0.5);
    is->video_clock += frame_delay;

    return pts;
}

int video_thread(void* arg) {
    VideoState* is = (VideoState*)arg;
    AVPacket packet, * pkt = &packet;
    int frameFinished;
    AVFrame* pFrame;
    double pts;

    pFrame = av_frame_alloc();

    for (;;) {
        if (packet_queue_get(&is->videoq, pkt, 1) < 0) {
            break; 
        }

        avcodec_decode_video2(is->video_ctx, pFrame, &frameFinished, pkt);  

        if ((pts = av_frame_get_best_effort_timestamp(pFrame)) == AV_NOPTS_VALUE) { 
            pts = 0;
        }
        pts *= av_q2d(is->video_st->time_base);

        if (frameFinished) {
            pts = synchronize_video(is, pFrame, pts);
            if (queue_picture(is, pFrame, pts) < 0) {
                break;
            }
        }

        av_free_packet(pkt);
    }
    av_frame_free(&pFrame);
    return 0;
}

int stream_component_open(VideoState* is, int stream_index) {
    int64_t in_channel_layout, out_channel_layout;
    AVFormatContext* pFormatCtx = is->pFormatCtx;
    AVCodecContext* codecCtx = NULL;
    AVCodec* codec = NULL;
    SDL_AudioSpec new_spec, old_spec;

    codec = avcodec_find_decoder(pFormatCtx->streams[stream_index]->codec->codec_id);
    if (!codec) {
        printf("UnSupport codec!\n");
        return -1;
    }

    codecCtx = avcodec_alloc_context3(codec);
    if (!codecCtx) {
        printf("Failed to alloc codec context\n");
        return -1;
    }

    if (avcodec_copy_context(codecCtx, pFormatCtx->streams[stream_index]->codec) < 0) {
        printf("Failed to copy codec context\n");
        return -1;
    }

    if (codecCtx->codec_type == AVMEDIA_TYPE_AUDIO) {
        new_spec.freq = codecCtx->sample_rate;
        new_spec.format = AUDIO_S16SYS;
        new_spec.channels = codecCtx->channels;
        new_spec.silence = 0;
        new_spec.samples = SDL_AUDIO_BUFFER_SIZE;
        new_spec.callback = audio_callback;
        new_spec.userdata = is;

        if (SDL_OpenAudio(&new_spec, &old_spec) < 0) {
            printf("SDL_OpenAudio: %s\n", SDL_GetError());
            return -1;
        }
    }

    if (avcodec_open2(codecCtx, codec, NULL) < 0) {
        printf("Failed to open codec\n");
        return -1;
    }

    switch (codecCtx->codec_type) {
    case AVMEDIA_TYPE_AUDIO:
        is->audioStream = stream_index;
        is->audio_st = pFormatCtx->streams[stream_index];
        is->audio_ctx = codecCtx;
        is->audio_buf_size = 0;
        is->audio_buf_index = 0;

        memset(&is->audio_pkt, 0, sizeof(is->audio_pkt));
        packet_queue_init(&is->audioq);

        SDL_PauseAudio(0);

        in_channel_layout = av_get_default_channel_layout(is->audio_ctx->channels);
        out_channel_layout = in_channel_layout;

        is->audio_swr_cxt = swr_alloc();
        swr_alloc_set_opts(is->audio_swr_cxt,
            out_channel_layout,
            AV_SAMPLE_FMT_S16,
            is->audio_ctx->sample_rate,
            in_channel_layout,
            is->audio_ctx->sample_fmt,
            is->audio_ctx->sample_rate,
            0,
            NULL);

        swr_init(is->audio_swr_cxt);
        break;
    case AVMEDIA_TYPE_VIDEO:
        is->videoStream = stream_index;
        is->video_st = pFormatCtx->streams[stream_index];
        is->video_ctx = codecCtx;

        is->frame_timer = (double)av_gettime() / 1000000.0;
        is->frame_last_delay = 40e-3;

        packet_queue_init(&is->videoq);
        is->sws_ctx = sws_getContext(is->video_ctx->width,
            is->video_ctx->height,
            is->video_ctx->pix_fmt,
            is->video_ctx->width,
            is->video_ctx->height,
            AV_PIX_FMT_YUV420P,
            SWS_BILINEAR,
            NULL, NULL, NULL);
        is->video_tid = SDL_CreateThread(video_thread, "video_thread", is);
        break;
    default:
        break;
    }
    return 0;
}

int decode_thread(void* arg) {
    VideoState* is = (VideoState*)arg;
    AVFormatContext* pFormatCtx = NULL;
    AVPacket packet, * ptk = &packet;
    SDL_Event event;

    int i, ret = 0;
    int video_index = -1;
    int audio_index = -1;

    is->videoStream = -1;
    is->audioStream = -1;

    global_video_state = is;

    if (avformat_open_input(&pFormatCtx, is->filename, NULL, NULL) < 0) {
        printf("Failed to open file[%s] context\n", is->filename);
        return -1;
    }

    is->pFormatCtx = pFormatCtx;

    if (avformat_find_stream_info(pFormatCtx, NULL) < 0) {
        printf("Failed to get detail stream infomation\n");
        return -1;
    }

    for (i = 0; i < pFormatCtx->nb_streams; i++) {
        if (pFormatCtx->streams[i]->codec->codec_type == AVMEDIA_TYPE_VIDEO && video_index < 0)
            video_index = i;
        if (pFormatCtx->streams[i]->codec->codec_type == AVMEDIA_TYPE_AUDIO && audio_index < 0)
            audio_index = i;
    }

    if (video_index < 0 || audio_index < 0) {
        printf("Failed to find stream index for audio/video\n");
        return -1;
    }

    av_dump_format(pFormatCtx, audio_index, is->filename, 0);
    av_dump_format(pFormatCtx, video_index, is->filename, 0);

    ret = stream_component_open(is, audio_index);
    if (ret < 0) {
        printf("Failed to initialize audio data\n");
        goto fail;
    }
    ret = stream_component_open(is, video_index);
    if (ret < 0) {
        printf("Failed to initialize video data\n");
        goto fail;
    }

    win = SDL_CreateWindow("Media Player",
        SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED,
        is->video_ctx->width, is->video_ctx->height,
        SDL_WINDOW_OPENGL | SDL_WINDOW_RESIZABLE
    );

    renderer = SDL_CreateRenderer(win, -1, 0);

    texture = SDL_CreateTexture(renderer,
        SDL_PIXELFORMAT_IYUV,
        SDL_TEXTUREACCESS_STREAMING,
        is->video_ctx->width,
        is->video_ctx->height);

    for (;;) {
        if (is->quit) { 
            SDL_CondSignal(is->videoq.cond);
            SDL_CondSignal(is->audioq.cond);
            break;
        }

        if (is->audioq.size > MAX_AUDIOQ_SIZE ||
            is->videoq.size > MAX_VEDIOQ_SIZE) {
            SDL_Delay(10);
            continue;
        }

        if (av_read_frame(is->pFormatCtx, ptk) < 0) {
            if (is->pFormatCtx->pb->error == 0) {
                SDL_Delay(100);
                continue;
            }
            else {
                break;
            }
        }
        if (ptk->stream_index == is->videoStream) {
            packet_queue_put(&is->videoq, ptk);
            printf("put video queue, size:%d\n", is->videoq.nb_packets);
        }
        else if (ptk->stream_index == is->audioStream) {
            packet_queue_put(&is->audioq, ptk);
            printf("put audio queue, size:%d\n", is->audioq.nb_packets);
        }
        else {
            av_free_packet(ptk);
        }
    }

    while (!is->quit) {
        SDL_Delay(100);
    }

fail:
    event.type = FF_QUIT_EVENT;
    event.user.data1 = is;
    SDL_PushEvent(&event);

    return 0;
}

int main(int argc, char* argv[]) {
    int ret = -1;

    SDL_Event event;
    VideoState* is;

    if (argc < 2) {
        fprintf(stderr, "Usage: test <file>\n");
        return ret;
    }

    is = av_malloc(sizeof(VideoState));

    av_register_all();
    if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_AUDIO | SDL_INIT_TIMER)) {
        printf("Failed to initialize SDL - %s\n", SDL_GetError());
        return ret;
    }
    texture_mutex = SDL_CreateMutex();

    av_strlcpy(is->filename, argv[1], sizeof(is->filename));

    is->pictq_mutex = SDL_CreateMutex();
    is->pictq_cond = SDL_CreateCond();

    schedule_refresh(is, 40);    
    is->parse_tid = SDL_CreateThread(decode_thread, "decode_thread", is);
    if (!is->parse_tid) {
        av_free(is);
        goto __FAIL;
    }

    for (;;) {
        SDL_WaitEvent(&event);
        switch (event.type) {
        case FF_QUIT_EVENT:
        case SDL_QUIT:
            printf("receive a QUIT event:%d\n", event.type);
            is->quit = 1;
            goto __QUIT;
            break;
        case FF_REFRESH_EVENT:
            video_refresh_timer(event.user.data1);
            break;
        default:
            break;
        }
    }

__QUIT:
    ret = 0;

__FAIL:
    SDL_Quit();
    return ret;
}



[此贴子已经被作者于2023-4-22 01:15编辑过]

搜索更多相关主题的帖子: return ret printf double int 
2023-04-22 01:14
forever74
Rank: 20Rank: 20Rank: 20Rank: 20Rank: 20
来 自:CC
等 级:版主
威 望:58
帖 子:1705
专家分:4345
注 册:2007-12-27
收藏
得分:4 
这个问题是因为你的源文件扩展名是.cpp
如果是.c就不会出这个问题了
收到的鲜花
  • rjsp2023-04-22 10:00 送鲜花  10朵  

对宇宙最严谨的描述应该就是宇宙其实是不严谨的
2023-04-22 08:51
forever74
Rank: 20Rank: 20Rank: 20Rank: 20Rank: 20
来 自:CC
等 级:版主
威 望:58
帖 子:1705
专家分:4345
注 册:2007-12-27
收藏
得分:4 
这是C和C++的语法差异。

对宇宙最严谨的描述应该就是宇宙其实是不严谨的
2023-04-22 08:53
forever74
Rank: 20Rank: 20Rank: 20Rank: 20Rank: 20
来 自:CC
等 级:版主
威 望:58
帖 子:1705
专家分:4345
注 册:2007-12-27
收藏
得分:4 
不想改文件名的话,这俩地方强制转换一下就好,没啥后遗症。

对宇宙最严谨的描述应该就是宇宙其实是不严谨的
2023-04-22 08:55
apull
Rank: 20Rank: 20Rank: 20Rank: 20Rank: 20
来 自:三体星系
等 级:版主
威 望:216
帖 子:1508
专家分:9241
注 册:2010-3-16
收藏
得分:4 
malloc前加强制类型转换
2023-04-22 09:47
东海ECS
Rank: 16Rank: 16Rank: 16Rank: 16
来 自:Python
等 级:版主
威 望:32
帖 子:412
专家分:1646
注 册:2023-1-24
收藏
得分:4 
这是因为 "void *" 类型的指针可以指向任何类型的数据,但是在赋值时需要将其转换为正确的实体类型。

可能需要使用强制类型转换来将 "void *" 类型的值分配到 "AVPacketList *" 类型的实体,例如:

AVPacketList pktList = (AVPacketList) packet;


在此例中,假设 "packet" 变量是一个 "void *" 类型的指针,需要将其转换为 "AVPacketList *" 类型的指针,并将其分配给 "pktList" 变量。 请注意,在进行强制类型转换时,需要确保转换后的类型与实际的数据类型相匹配。

会当凌绝顶,一览众山小.
2023-04-22 10:54
追梦人zmrghy
Rank: 3Rank: 3
等 级:论坛游侠
帖 子:406
专家分:190
注 册:2021-4-9
收藏
得分:0 
回复 5楼 apull
图片附件: 游客没有浏览图片的权限,请 登录注册

图片附件: 游客没有浏览图片的权限,请 登录注册


语法,可以了没有错误。。。。

LNK2019

1>FFmpegSDLPlayer.obj : error LNK2019: 无法解析的外部符号 "void * __cdecl av_malloc(unsigned __int64)" (?av_malloc@@YAPEAX_K@Z),函数 "int __cdecl packet_queue_put(struct PacketQueue *,struct AVPacket *)" (?packet_queue_put@@YAHPEAUPacketQueue@@PEAUAVPacket@@@Z) 中引用了该符号
1>FFmpegSDLPlayer.obj : error LNK2019: 无法解析的外部符号 "void __cdecl av_free(void *)" (?av_free@@YAXPEAX@Z),函数 "int __cdecl packet_queue_get(struct PacketQueue *,struct AVPacket *,int)" (?packet_queue_get@@YAHPEAUPacketQueue@@PEAUAVPacket@@H@Z) 中引用了该符号
1>FFmpegSDLPlayer.obj : error LNK2019: 无法解析的外部符号 "__int64 __cdecl av_gettime(void)" (?av_gettime@@YA_JXZ),函数 "int __cdecl stream_component_open(struct VideoState *,int)" (?stream_component_open@@YAHPEAUVideoState@@H@Z) 中引用了该符号
1>FFmpegSDLPlayer.obj : error LNK2019: 无法解析的外部符号 "unsigned __int64 __cdecl av_strlcpy(char *,char const *,unsigned __int64)" (?av_strlcpy@@YA_KPEADPEBD_K@Z),函数 SDL_main 中引用了该符号
1>FFmpegSDLPlayer.obj : error LNK2019: 无法解析的外部符号 "__int64 __cdecl av_get_default_channel_layout(int)" (?av_get_default_channel_layout@@YA_JH@Z),函数 "int __cdecl stream_component_open(struct VideoState *,int)" (?stream_component_open@@YAHPEAUVideoState@@H@Z) 中引用了该符号
1>FFmpegSDLPlayer.obj : error LNK2019: 无法解析的外部符号 "__int64 __cdecl av_frame_get_best_effort_timestamp(struct AVFrame const *)" (?av_frame_get_best_effort_timestamp@@YA_JPEBUAVFrame@@@Z),函数 "int __cdecl video_thread(void *)" (?video_thread@@YAHPEAX@Z) 中引用了该符号
1>FFmpegSDLPlayer.obj : error LNK2019: 无法解析的外部符号 "struct AVFrame * __cdecl av_frame_alloc(void)" (?av_frame_alloc@@YAPEAUAVFrame@@XZ),函数 "int __cdecl video_thread(void *)" (?video_thread@@YAHPEAX@Z) 中引用了该符号
1>FFmpegSDLPlayer.obj : error LNK2019: 无法解析的外部符号 "void __cdecl av_frame_free(struct AVFrame * *)" (?av_frame_free@@YAXPEAPEAUAVFrame@@@Z),函数 "int __cdecl video_thread(void *)" (?video_thread@@YAHPEAX@Z) 中引用了该符号
1>FFmpegSDLPlayer.obj : error LNK2019: 无法解析的外部符号 "int __cdecl av_dup_packet(struct AVPacket *)" (?av_dup_packet@@YAHPEAUAVPacket@@@Z),函数 "int __cdecl packet_queue_put(struct PacketQueue *,struct AVPacket *)" (?packet_queue_put@@YAHPEAUPacketQueue@@PEAUAVPacket@@@Z) 中引用了该符号
1>FFmpegSDLPlayer.obj : error LNK2019: 无法解析的外部符号 "void __cdecl av_free_packet(struct AVPacket *)" (?av_free_packet@@YAXPEAUAVPacket@@@Z),函数 "int __cdecl audio_decode_frame(struct VideoState *,unsigned char *,int,double *)" (?audio_decode_frame@@YAHPEAUVideoState@@PEAEHPEAN@Z) 中引用了该符号
1>FFmpegSDLPlayer.obj : error LNK2019: 无法解析的外部符号 "struct AVCodec * __cdecl avcodec_find_decoder(enum AVCodecID)" (?avcodec_find_decoder@@YAPEAUAVCodec@@W4AVCodecID@@@Z),函数 "int __cdecl stream_component_open(struct VideoState *,int)" (?stream_component_open@@YAHPEAUVideoState@@H@Z) 中引用了该符号
1>FFmpegSDLPlayer.obj : error LNK2019: 无法解析的外部符号 "struct AVCodecContext * __cdecl avcodec_alloc_context3(struct AVCodec const *)" (?avcodec_alloc_context3@@YAPEAUAVCodecContext@@PEBUAVCodec@@@Z),函数 "int __cdecl stream_component_open(struct VideoState *,int)" (?stream_component_open@@YAHPEAUVideoState@@H@Z) 中引用了该符号
1>FFmpegSDLPlayer.obj : error LNK2019: 无法解析的外部符号 "int __cdecl avcodec_copy_context(struct AVCodecContext *,struct AVCodecContext const *)" (?avcodec_copy_context@@YAHPEAUAVCodecContext@@PEBU1@@Z),函数 "int __cdecl stream_component_open(struct VideoState *,int)" (?stream_component_open@@YAHPEAUVideoState@@H@Z) 中引用了该符号
1>FFmpegSDLPlayer.obj : error LNK2019: 无法解析的外部符号 "int __cdecl avcodec_open2(struct AVCodecContext *,struct AVCodec const *,struct AVDictionary * *)" (?avcodec_open2@@YAHPEAUAVCodecContext@@PEBUAVCodec@@PEAPEAUAVDictionary@@@Z),函数 "int __cdecl stream_component_open(struct VideoState *,int)" (?stream_component_open@@YAHPEAUVideoState@@H@Z) 中引用了该符号
1>FFmpegSDLPlayer.obj : error LNK2019: 无法解析的外部符号 "int __cdecl avcodec_decode_audio4(struct AVCodecContext *,struct AVFrame *,int *,struct AVPacket const *)" (?avcodec_decode_audio4@@YAHPEAUAVCodecContext@@PEAUAVFrame@@PEAHPEBUAVPacket@@@Z),函数 "int __cdecl audio_decode_frame(struct VideoState *,unsigned char *,int,double *)" (?audio_decode_frame@@YAHPEAUVideoState@@PEAEHPEAN@Z) 中引用了该符号
1>FFmpegSDLPlayer.obj : error LNK2019: 无法解析的外部符号 "int __cdecl avcodec_decode_video2(struct AVCodecContext *,struct AVFrame *,int *,struct AVPacket const *)" (?avcodec_decode_video2@@YAHPEAUAVCodecContext@@PEAUAVFrame@@PEAHPEBUAVPacket@@@Z),函数 "int __cdecl video_thread(void *)" (?video_thread@@YAHPEAX@Z) 中引用了该符号
1>FFmpegSDLPlayer.obj : error LNK2019: 无法解析的外部符号 "int __cdecl avpicture_alloc(struct AVPicture *,enum AVPixelFormat,int,int)" (?avpicture_alloc@@YAHPEAUAVPicture@@W4AVPixelFormat@@HH@Z),函数 "void __cdecl alloc_picture(void *)" (?alloc_picture@@YAXPEAX@Z) 中引用了该符号
1>FFmpegSDLPlayer.obj : error LNK2019: 无法解析的外部符号 "void __cdecl avpicture_free(struct AVPicture *)" (?avpicture_free@@YAXPEAUAVPicture@@@Z),函数 "void __cdecl alloc_picture(void *)" (?alloc_picture@@YAXPEAX@Z) 中引用了该符号
1>FFmpegSDLPlayer.obj : error LNK2019: 无法解析的外部符号 "void __cdecl av_register_all(void)" (?av_register_all@@YAXXZ),函数 SDL_main 中引用了该符号
1>FFmpegSDLPlayer.obj : error LNK2019: 无法解析的外部符号 "int __cdecl avformat_open_input(struct AVFormatContext * *,char const *,struct AVInputFormat *,struct AVDictionary * *)" (?avformat_open_input@@YAHPEAPEAUAVFormatContext@@PEBDPEAUAVInputFormat@@PEAPEAUAVDictionary@@@Z),函数 "int __cdecl decode_thread(void *)" (?decode_thread@@YAHPEAX@Z) 中引用了该符号
1>FFmpegSDLPlayer.obj : error LNK2019: 无法解析的外部符号 "int __cdecl avformat_find_stream_info(struct AVFormatContext *,struct AVDictionary * *)" (?avformat_find_stream_info@@YAHPEAUAVFormatContext@@PEAPEAUAVDictionary@@@Z),函数 "int __cdecl decode_thread(void *)" (?decode_thread@@YAHPEAX@Z) 中引用了该符号
1>FFmpegSDLPlayer.obj : error LNK2019: 无法解析的外部符号 "int __cdecl av_read_frame(struct AVFormatContext *,struct AVPacket *)" (?av_read_frame@@YAHPEAUAVFormatContext@@PEAUAVPacket@@@Z),函数 "int __cdecl decode_thread(void *)" (?decode_thread@@YAHPEAX@Z) 中引用了该符号
1>FFmpegSDLPlayer.obj : error LNK2019: 无法解析的外部符号 "void __cdecl av_dump_format(struct AVFormatContext *,int,char const *,int)" (?av_dump_format@@YAXPEAUAVFormatContext@@HPEBDH@Z),函数 "int __cdecl decode_thread(void *)" (?decode_thread@@YAHPEAX@Z) 中引用了该符号
1>FFmpegSDLPlayer.obj : error LNK2019: 无法解析的外部符号 "struct SwsContext * __cdecl sws_getContext(int,int,enum AVPixelFormat,int,int,enum AVPixelFormat,int,struct SwsFilter *,struct SwsFilter *,double const *)" (?sws_getContext@@YAPEAUSwsContext@@HHW4AVPixelFormat@@HH0HPEAUSwsFilter@@1PEBN@Z),函数 "int __cdecl stream_component_open(struct VideoState *,int)" (?stream_component_open@@YAHPEAUVideoState@@H@Z) 中引用了该符号
1>FFmpegSDLPlayer.obj : error LNK2019: 无法解析的外部符号 "int __cdecl sws_scale(struct SwsContext *,unsigned char const * const * const,int const * const,int,int,unsigned char * const * const,int const * const)" (?sws_scale@@YAHPEAUSwsContext@@QEBQEBEQEBHHHQEBQEAE2@Z),函数 "int __cdecl queue_picture(struct VideoState *,struct AVFrame *,double)" (?queue_picture@@YAHPEAUVideoState@@PEAUAVFrame@@N@Z) 中引用了该符号
1>FFmpegSDLPlayer.obj : error LNK2019: 无法解析的外部符号 "struct SwrContext * __cdecl swr_alloc(void)" (?swr_alloc@@YAPEAUSwrContext@@XZ),函数 "int __cdecl stream_component_open(struct VideoState *,int)" (?stream_component_open@@YAHPEAUVideoState@@H@Z) 中引用了该符号
1>FFmpegSDLPlayer.obj : error LNK2019: 无法解析的外部符号 "int __cdecl swr_init(struct SwrContext *)" (?swr_init@@YAHPEAUSwrContext@@@Z),函数 "int __cdecl stream_component_open(struct VideoState *,int)" (?stream_component_open@@YAHPEAUVideoState@@H@Z) 中引用了该符号
1>FFmpegSDLPlayer.obj : error LNK2019: 无法解析的外部符号 "struct SwrContext * __cdecl swr_alloc_set_opts(struct SwrContext *,__int64,enum AVSampleFormat,int,__int64,enum AVSampleFormat,int,int,void *)" (?swr_alloc_set_opts@@YAPEAUSwrContext@@PEAU1@_JW4AVSampleFormat@@H12HHPEAX@Z),函数 "int __cdecl stream_component_open(struct VideoState *,int)" (?stream_component_open@@YAHPEAUVideoState@@H@Z) 中引用了该符号
1>FFmpegSDLPlayer.obj : error LNK2019: 无法解析的外部符号 "int __cdecl swr_convert(struct SwrContext *,unsigned char * *,int,unsigned char const * *,int)" (?swr_convert@@YAHPEAUSwrContext@@PEAPEAEHPEAPEBEH@Z),函数 "int __cdecl audio_decode_frame(struct VideoState *,unsigned char *,int,double *)" (?audio_decode_frame@@YAHPEAUVideoState@@PEAEHPEAN@Z) 中引用了该符号
1>C:\Users\Administrator\source\repos\FFmpegSDLPlayer\x64\Debug\FFmpegSDLPlayer.exe : fatal error LNK1120: 29 个无法解析的外部命令
1>已完成生成项目“FFmpegSDLPlayer.vcxproj”的操作 - 失败。
========== “生成”: 0 成功,1 失败,0 更新,0 已跳过 ==========
2023-04-22 12:11
追梦人zmrghy
Rank: 3Rank: 3
等 级:论坛游侠
帖 子:406
专家分:190
注 册:2021-4-9
收藏
得分:0 
回复 6楼 东海ECS
图片附件: 游客没有浏览图片的权限,请 登录注册

图片附件: 游客没有浏览图片的权限,请 登录注册


语法可以了 没有错误
可是LNK2019

1>FFmpegSDLPlayer.obj : error LNK2019: 无法解析的外部符号 "void * __cdecl av_malloc(unsigned __int64)" (?av_malloc@@YAPEAX_K@Z),函数 "int __cdecl packet_queue_put(struct PacketQueue *,struct AVPacket *)" (?packet_queue_put@@YAHPEAUPacketQueue@@PEAUAVPacket@@@Z) 中引用了该符号
1>FFmpegSDLPlayer.obj : error LNK2019: 无法解析的外部符号 "void __cdecl av_free(void *)" (?av_free@@YAXPEAX@Z),函数 "int __cdecl packet_queue_get(struct PacketQueue *,struct AVPacket *,int)" (?packet_queue_get@@YAHPEAUPacketQueue@@PEAUAVPacket@@H@Z) 中引用了该符号
1>FFmpegSDLPlayer.obj : error LNK2019: 无法解析的外部符号 "__int64 __cdecl av_gettime(void)" (?av_gettime@@YA_JXZ),函数 "int __cdecl stream_component_open(struct VideoState *,int)" (?stream_component_open@@YAHPEAUVideoState@@H@Z) 中引用了该符号
1>FFmpegSDLPlayer.obj : error LNK2019: 无法解析的外部符号 "unsigned __int64 __cdecl av_strlcpy(char *,char const *,unsigned __int64)" (?av_strlcpy@@YA_KPEADPEBD_K@Z),函数 SDL_main 中引用了该符号
1>FFmpegSDLPlayer.obj : error LNK2019: 无法解析的外部符号 "__int64 __cdecl av_get_default_channel_layout(int)" (?av_get_default_channel_layout@@YA_JH@Z),函数 "int __cdecl stream_component_open(struct VideoState *,int)" (?stream_component_open@@YAHPEAUVideoState@@H@Z) 中引用了该符号
1>FFmpegSDLPlayer.obj : error LNK2019: 无法解析的外部符号 "__int64 __cdecl av_frame_get_best_effort_timestamp(struct AVFrame const *)" (?av_frame_get_best_effort_timestamp@@YA_JPEBUAVFrame@@@Z),函数 "int __cdecl video_thread(void *)" (?video_thread@@YAHPEAX@Z) 中引用了该符号
1>FFmpegSDLPlayer.obj : error LNK2019: 无法解析的外部符号 "struct AVFrame * __cdecl av_frame_alloc(void)" (?av_frame_alloc@@YAPEAUAVFrame@@XZ),函数 "int __cdecl video_thread(void *)" (?video_thread@@YAHPEAX@Z) 中引用了该符号
1>FFmpegSDLPlayer.obj : error LNK2019: 无法解析的外部符号 "void __cdecl av_frame_free(struct AVFrame * *)" (?av_frame_free@@YAXPEAPEAUAVFrame@@@Z),函数 "int __cdecl video_thread(void *)" (?video_thread@@YAHPEAX@Z) 中引用了该符号
1>FFmpegSDLPlayer.obj : error LNK2019: 无法解析的外部符号 "int __cdecl av_dup_packet(struct AVPacket *)" (?av_dup_packet@@YAHPEAUAVPacket@@@Z),函数 "int __cdecl packet_queue_put(struct PacketQueue *,struct AVPacket *)" (?packet_queue_put@@YAHPEAUPacketQueue@@PEAUAVPacket@@@Z) 中引用了该符号
1>FFmpegSDLPlayer.obj : error LNK2019: 无法解析的外部符号 "void __cdecl av_free_packet(struct AVPacket *)" (?av_free_packet@@YAXPEAUAVPacket@@@Z),函数 "int __cdecl audio_decode_frame(struct VideoState *,unsigned char *,int,double *)" (?audio_decode_frame@@YAHPEAUVideoState@@PEAEHPEAN@Z) 中引用了该符号
1>FFmpegSDLPlayer.obj : error LNK2019: 无法解析的外部符号 "struct AVCodec * __cdecl avcodec_find_decoder(enum AVCodecID)" (?avcodec_find_decoder@@YAPEAUAVCodec@@W4AVCodecID@@@Z),函数 "int __cdecl stream_component_open(struct VideoState *,int)" (?stream_component_open@@YAHPEAUVideoState@@H@Z) 中引用了该符号
1>FFmpegSDLPlayer.obj : error LNK2019: 无法解析的外部符号 "struct AVCodecContext * __cdecl avcodec_alloc_context3(struct AVCodec const *)" (?avcodec_alloc_context3@@YAPEAUAVCodecContext@@PEBUAVCodec@@@Z),函数 "int __cdecl stream_component_open(struct VideoState *,int)" (?stream_component_open@@YAHPEAUVideoState@@H@Z) 中引用了该符号
1>FFmpegSDLPlayer.obj : error LNK2019: 无法解析的外部符号 "int __cdecl avcodec_copy_context(struct AVCodecContext *,struct AVCodecContext const *)" (?avcodec_copy_context@@YAHPEAUAVCodecContext@@PEBU1@@Z),函数 "int __cdecl stream_component_open(struct VideoState *,int)" (?stream_component_open@@YAHPEAUVideoState@@H@Z) 中引用了该符号
1>FFmpegSDLPlayer.obj : error LNK2019: 无法解析的外部符号 "int __cdecl avcodec_open2(struct AVCodecContext *,struct AVCodec const *,struct AVDictionary * *)" (?avcodec_open2@@YAHPEAUAVCodecContext@@PEBUAVCodec@@PEAPEAUAVDictionary@@@Z),函数 "int __cdecl stream_component_open(struct VideoState *,int)" (?stream_component_open@@YAHPEAUVideoState@@H@Z) 中引用了该符号
1>FFmpegSDLPlayer.obj : error LNK2019: 无法解析的外部符号 "int __cdecl avcodec_decode_audio4(struct AVCodecContext *,struct AVFrame *,int *,struct AVPacket const *)" (?avcodec_decode_audio4@@YAHPEAUAVCodecContext@@PEAUAVFrame@@PEAHPEBUAVPacket@@@Z),函数 "int __cdecl audio_decode_frame(struct VideoState *,unsigned char *,int,double *)" (?audio_decode_frame@@YAHPEAUVideoState@@PEAEHPEAN@Z) 中引用了该符号
1>FFmpegSDLPlayer.obj : error LNK2019: 无法解析的外部符号 "int __cdecl avcodec_decode_video2(struct AVCodecContext *,struct AVFrame *,int *,struct AVPacket const *)" (?avcodec_decode_video2@@YAHPEAUAVCodecContext@@PEAUAVFrame@@PEAHPEBUAVPacket@@@Z),函数 "int __cdecl video_thread(void *)" (?video_thread@@YAHPEAX@Z) 中引用了该符号
1>FFmpegSDLPlayer.obj : error LNK2019: 无法解析的外部符号 "int __cdecl avpicture_alloc(struct AVPicture *,enum AVPixelFormat,int,int)" (?avpicture_alloc@@YAHPEAUAVPicture@@W4AVPixelFormat@@HH@Z),函数 "void __cdecl alloc_picture(void *)" (?alloc_picture@@YAXPEAX@Z) 中引用了该符号
1>FFmpegSDLPlayer.obj : error LNK2019: 无法解析的外部符号 "void __cdecl avpicture_free(struct AVPicture *)" (?avpicture_free@@YAXPEAUAVPicture@@@Z),函数 "void __cdecl alloc_picture(void *)" (?alloc_picture@@YAXPEAX@Z) 中引用了该符号
1>FFmpegSDLPlayer.obj : error LNK2019: 无法解析的外部符号 "void __cdecl av_register_all(void)" (?av_register_all@@YAXXZ),函数 SDL_main 中引用了该符号
1>FFmpegSDLPlayer.obj : error LNK2019: 无法解析的外部符号 "int __cdecl avformat_open_input(struct AVFormatContext * *,char const *,struct AVInputFormat *,struct AVDictionary * *)" (?avformat_open_input@@YAHPEAPEAUAVFormatContext@@PEBDPEAUAVInputFormat@@PEAPEAUAVDictionary@@@Z),函数 "int __cdecl decode_thread(void *)" (?decode_thread@@YAHPEAX@Z) 中引用了该符号
1>FFmpegSDLPlayer.obj : error LNK2019: 无法解析的外部符号 "int __cdecl avformat_find_stream_info(struct AVFormatContext *,struct AVDictionary * *)" (?avformat_find_stream_info@@YAHPEAUAVFormatContext@@PEAPEAUAVDictionary@@@Z),函数 "int __cdecl decode_thread(void *)" (?decode_thread@@YAHPEAX@Z) 中引用了该符号
1>FFmpegSDLPlayer.obj : error LNK2019: 无法解析的外部符号 "int __cdecl av_read_frame(struct AVFormatContext *,struct AVPacket *)" (?av_read_frame@@YAHPEAUAVFormatContext@@PEAUAVPacket@@@Z),函数 "int __cdecl decode_thread(void *)" (?decode_thread@@YAHPEAX@Z) 中引用了该符号
1>FFmpegSDLPlayer.obj : error LNK2019: 无法解析的外部符号 "void __cdecl av_dump_format(struct AVFormatContext *,int,char const *,int)" (?av_dump_format@@YAXPEAUAVFormatContext@@HPEBDH@Z),函数 "int __cdecl decode_thread(void *)" (?decode_thread@@YAHPEAX@Z) 中引用了该符号
1>FFmpegSDLPlayer.obj : error LNK2019: 无法解析的外部符号 "struct SwsContext * __cdecl sws_getContext(int,int,enum AVPixelFormat,int,int,enum AVPixelFormat,int,struct SwsFilter *,struct SwsFilter *,double const *)" (?sws_getContext@@YAPEAUSwsContext@@HHW4AVPixelFormat@@HH0HPEAUSwsFilter@@1PEBN@Z),函数 "int __cdecl stream_component_open(struct VideoState *,int)" (?stream_component_open@@YAHPEAUVideoState@@H@Z) 中引用了该符号
1>FFmpegSDLPlayer.obj : error LNK2019: 无法解析的外部符号 "int __cdecl sws_scale(struct SwsContext *,unsigned char const * const * const,int const * const,int,int,unsigned char * const * const,int const * const)" (?sws_scale@@YAHPEAUSwsContext@@QEBQEBEQEBHHHQEBQEAE2@Z),函数 "int __cdecl queue_picture(struct VideoState *,struct AVFrame *,double)" (?queue_picture@@YAHPEAUVideoState@@PEAUAVFrame@@N@Z) 中引用了该符号
1>FFmpegSDLPlayer.obj : error LNK2019: 无法解析的外部符号 "struct SwrContext * __cdecl swr_alloc(void)" (?swr_alloc@@YAPEAUSwrContext@@XZ),函数 "int __cdecl stream_component_open(struct VideoState *,int)" (?stream_component_open@@YAHPEAUVideoState@@H@Z) 中引用了该符号
1>FFmpegSDLPlayer.obj : error LNK2019: 无法解析的外部符号 "int __cdecl swr_init(struct SwrContext *)" (?swr_init@@YAHPEAUSwrContext@@@Z),函数 "int __cdecl stream_component_open(struct VideoState *,int)" (?stream_component_open@@YAHPEAUVideoState@@H@Z) 中引用了该符号
1>FFmpegSDLPlayer.obj : error LNK2019: 无法解析的外部符号 "struct SwrContext * __cdecl swr_alloc_set_opts(struct SwrContext *,__int64,enum AVSampleFormat,int,__int64,enum AVSampleFormat,int,int,void *)" (?swr_alloc_set_opts@@YAPEAUSwrContext@@PEAU1@_JW4AVSampleFormat@@H12HHPEAX@Z),函数 "int __cdecl stream_component_open(struct VideoState *,int)" (?stream_component_open@@YAHPEAUVideoState@@H@Z) 中引用了该符号
1>FFmpegSDLPlayer.obj : error LNK2019: 无法解析的外部符号 "int __cdecl swr_convert(struct SwrContext *,unsigned char * *,int,unsigned char const * *,int)" (?swr_convert@@YAHPEAUSwrContext@@PEAPEAEHPEAPEBEH@Z),函数 "int __cdecl audio_decode_frame(struct VideoState *,unsigned char *,int,double *)" (?audio_decode_frame@@YAHPEAUVideoState@@PEAEHPEAN@Z) 中引用了该符号
1>C:\Users\Administrator\source\repos\FFmpegSDLPlayer\x64\Debug\FFmpegSDLPlayer.exe : fatal error LNK1120: 29 个无法解析的外部命令
1>已完成生成项目“FFmpegSDLPlayer.vcxproj”的操作 - 失败。
========== “生成”: 0 成功,1 失败,0 更新,0 已跳过 ==========
2023-04-22 12:15
追梦人zmrghy
Rank: 3Rank: 3
等 级:论坛游侠
帖 子:406
专家分:190
注 册:2021-4-9
收藏
得分:0 
回复 4楼 forever74
强制转换出问题了。。。。。

文件改成 .c 可以了。。。
图片附件: 游客没有浏览图片的权限,请 登录注册
2023-04-22 12:28
apull
Rank: 20Rank: 20Rank: 20Rank: 20Rank: 20
来 自:三体星系
等 级:版主
威 望:216
帖 子:1508
专家分:9241
注 册:2010-3-16
收藏
得分:0 
link错误,需要把对应的链接库添加到项目属性里。或者添加#pragma comment(lib,"xxx")宏
2023-04-23 00:44
快速回复:求助 E0513 不能将 "void *" 类型的值分配到 "AVPacketList *" 类型的 ...
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.030283 second(s), 10 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved