ffmepg开发rtsp播放器(1)

FFMPEG开发rtsp播放器

公司做桌面共享的时候,抓屏使用的是EasyScreenLive,流媒体服务器EasyDarwin,客户端播放器使用的是vlc,在网络不好的情况下经常会出现卡顿、黑屏,后来使用EasyPlayer-RTSP播放效果不错,但是EasyPlayer不是开源的可控性也不强,也不能添加日志,所以萌生自己开发一个rtsp播放器的想法。
下图是经过俩天测试后的效果,左侧是easyplayer的效果,右侧是自己写的demo。
在这里插入图片描述

demo是模仿ffplayer源码开发的所以我们就通过分析ffplayer来进行吧,demo只保留了视频信号,没有处理音频和字幕。

1.ffplayer read_thread 分析
2.ffplayer packet_queue 分析
3.ffplayer decoder_thread 分析
4.ffplayer frame_queue分析

首先介绍贯穿整个项目的一个结构体

typedef struct VideoState {

    AVFormatContext *ic;
    AVStream *video_st;
    SwsContext *swsContext;
    AVFrame *avFrameRGB;
    int force_refresh;
    
    const char *urlname;
    uint8_t *imageBuffer;

    FrameQueue pictq;
    PacketQueue videoq;
    Decoder viddec;
    pthread_cond_t continue_read_thread;
    ZST_ReadThread *readThread = nullptr;
    int last_video_stream,video_stream_index;
    int eof;
    int abort_request;
    int frame_drops_late;
    int av_sync_type;
    int codec_width;
    int codec_height;
    int realtime;

    double frame_timer;
    double max_frame_duration;      // 

} VideoState;

存在问题

  • avformat_find_stream_info 和avcodec_send_packet程序异常崩溃,解决好长时间都没有解决,然后用命令行测试ffplayer.exe播放视频也会崩溃,然后在windows用不同版本ffmpeg进行编译都会出现这个随机崩溃得问题,然后就在ubuntu下编译ffmepg,成功解决。
    ubuntu下ffmepg编译
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值