Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #ifndef CONVERTER_H_
- #define CONVERTER_H_
- #include <QString>
- #include <QObject>
- #include <QQueue>
- #include <FileFormats.h>
- extern "C" {
- #include <libavcodec/avcodec.h>
- #include <libavformat/avformat.h>
- #include <libswscale/swscale.h>
- #include <libavresample/avresample.h>
- #include <libavutil/opt.h>
- }
- class InternetVideo;
- class Converter : public QObject
- {
- Q_OBJECT
- public:
- Converter();
- void AddToQueue(InternetVideo* v);
- void StartConverting();
- void SetFormatSettings(FileFormat format, int audioQuality, int videoQuality);
- void SetTargetPath(QString target) { m_TargetPath = target; }
- protected slots:
- void onConvertingFinished(InternetVideo *v);
- signals:
- void QueueFinished();
- void ConvertingFinished(InternetVideo *v);
- private:
- bool OpenInput(const char* path);
- bool OpenOutput(QString targetFilename);
- void Convert(InternetVideo *v);
- AVStream * add_audio_stream(AVFormatContext * m_OutputFormatCtx, AVCodec ** m_AudioCodec, enum AVCodecID audio_codec);
- AVStream * add_video_stream(AVFormatContext * m_OutputFormatCtx, AVCodec ** m_AudioCodec, enum AVCodecID audio_codec);
- int open_audio(AVFormatContext * m_OutputFormatCtx, AVCodec * m_AudioCodec, AVStream * audio_st);
- int open_video(AVFormatContext * m_OutputFormatCtx, AVCodec * m_VideoCodec, AVStream * video_st);
- int decode_frame(AVPacket* packet, AVFrame* outputFrame);
- int decode_packet(AVPacket* packet, AVFrame* outputFrame);
- void write_audio_frame(AVFrame *frame, uint8_t** audio_dst_data, int audio_dst_bufsize);
- void write_delayed_frames(AVFormatContext * m_OutputFormatCtx, AVStream * audio_st);
- QQueue<InternetVideo*> m_Queue;
- bool m_Converting;
- bool m_audioOnly;
- QString m_TargetPath;
- FileFormat m_Format;
- AudioQuality m_AudioQuality;
- VideoQuality m_VideoQuality;
- QString m_FileEnding;
- //libav stuff
- AVFormatContext *m_FormatCtx;
- AVFormatContext *m_OutputFormatCtx;
- AVCodecContext *m_VideoCodecCtx;
- AVCodecContext *m_AudioCodecCtx;
- AVCodec *m_VideoCodec;
- AVCodec *m_AudioCodec;
- AVCodec *m_OutputAudioCodec;
- AVCodec *m_OutputVideoCodec;
- AVAudioResampleContext *m_avresampleCtx;
- int m_VideoStreamIndex;
- int m_AudioStreamIndex;
- int m_Audio_channels;
- int audio_input_frame_size;
- int got_frame;
- int audiobufsize = 0;
- AVFrame* m_DecodedAudioFrame;
- AVFrame* m_DecodedVideoFrame;
- uint8_t** audio_dst_data;
- uint8_t* video_dst_data;
- AVStream * audio_st;
- AVStream * video_st;
- int audio_dst_linesize;
- int audio_dst_bufsize;
- };
- #endif
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement