New file |
| | |
| | | #ifndef QFFMPEG_H |
| | | #define QFFMPEG_H |
| | | |
| | | //å¿
é¡»å 以ä¸å
容,å¦åç¼è¯ä¸è½éè¿,为äºå
¼å®¹CåC99æ å |
| | | #ifndef INT64_C |
| | | #define INT64_C |
| | | #define UINT64_C |
| | | #endif |
| | | |
| | | //å¼å
¥ffmpeg头æä»¶ |
| | | extern "C" |
| | | { |
| | | #include <libavcodec/avcodec.h> //å®ç°é³è§é¢çç¼è§£ç åè½ |
| | | #include <libavformat/avformat.h> //å®ç°é³è§é¢æä»¶ç读åååå
¥åè½ï¼æ¯æå¤ç§é³è§é¢æ ¼å¼ |
| | | #include <libavfilter/avfilter.h> |
| | | #include <libswscale/swscale.h> |
| | | #include <libavutil/frame.h> |
| | | #include <libavutil/imgutils.h> |
| | | } |
| | | |
| | | // å¼å
¥SDL2头æä»¶ |
| | | //extern "C" |
| | | //{ |
| | | // #include "SDL.h" |
| | | //} |
| | | |
| | | #include <QObject> |
| | | #include <QMutex> |
| | | #include <QImage> |
| | | |
| | | class QFFmpeg : public QObject |
| | | { |
| | | Q_OBJECT |
| | | public: |
| | | explicit QFFmpeg(QObject *parent = 0); |
| | | ~QFFmpeg(); |
| | | |
| | | bool Init(); // åå§å |
| | | void Play(); // ææ¾ |
| | | |
| | | void SetUrl(QString url){this->url=url;} // 设置è§é¢æº |
| | | |
| | | QString Url()const{return url;} |
| | | int VideoWidth()const{return videoWidth;} |
| | | int VideoHeight()const{return videoHeight;} |
| | | void SetIndex(int x){this->index=x;} |
| | | |
| | | private: |
| | | QMutex mutex; |
| | | AVPicture pAVPicture; |
| | | AVFormatContext *pAVFormatContext; |
| | | AVCodecContext *pAVCodecContext; |
| | | AVFrame *pAVFrame; |
| | | SwsContext * pSwsContext; |
| | | AVPacket pAVPacket; |
| | | |
| | | QString url; |
| | | int videoWidth; |
| | | int videoHeight; |
| | | int videoStreamIndex; |
| | | int index; |
| | | |
| | | // SDLç¸å
³ |
| | | // SDL_Window *sdlWindow; |
| | | // SDL_Renderer *sdlRenderer; |
| | | // SDL_Texture *sdlTexture; |
| | | |
| | | signals: |
| | | void GetImage(const QImage &image,int x); // åéè§£ç åçå¾åä¿¡å· |
| | | |
| | | }; |
| | | |
| | | #endif // QFFMPEG_H |