Miam-Player  0.8.0
A nice music player
AVTranscoder.h
Go to the documentation of this file.
1 /******************************************************************************
2  QtAV: Multimedia framework based on Qt and FFmpeg
3  Copyright (C) (2012-2016) Wang Bin <wbsecg1@gmail.com>
4 
5 * This file is part of QtAV (from 2015)
6 
7  This library is free software; you can redistribute it and/or
8  modify it under the terms of the GNU Lesser General Public
9  License as published by the Free Software Foundation; either
10  version 2.1 of the License, or (at your option) any later version.
11 
12  This library is distributed in the hope that it will be useful,
13  but WITHOUT ANY WARRANTY; without even the implied warranty of
14  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15  Lesser General Public License for more details.
16 
17  You should have received a copy of the GNU Lesser General Public
18  License along with this library; if not, write to the Free Software
19  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20 ******************************************************************************/
21 
22 #ifndef QTAV_AVTRANSCODE_H
23 #define QTAV_AVTRANSCODE_H
24 
25 #include <QtAV/MediaIO.h>
26 #include <QtAV/AudioEncoder.h>
27 #include <QtAV/VideoEncoder.h>
28 
29 namespace QtAV {
30 
31 class AVPlayer;
32 class Q_AV_EXPORT AVTranscoder : public QObject
33 {
34  Q_OBJECT
35 public:
36  AVTranscoder(QObject* parent = 0);
37  ~AVTranscoder();
38 
39  // TODO: other source (more operations needed, e.g. seek)?
40  void setMediaSource(AVPlayer* player);
41  AVPlayer* sourcePlayer() const;
42 
43  QString outputFile() const;
44  QIODevice* outputDevice() const;
45  MediaIO* outputMediaIO() const;
49  void setOutputMedia(const QString& fileName);
50  void setOutputMedia(QIODevice* dev);
51  void setOutputMedia(MediaIO* io);
56  void setOutputFormat(const QString& fmt);
57  QString outputFormatForced() const;
58 
59  void setOutputOptions(const QVariantHash &dict);
60  QVariantHash outputOptions() const;
61 
66  void setAsync(bool value = true);
67  bool isAsync() const;
74  bool createVideoEncoder(const QString& name = QLatin1String("FFmpeg"));
82  VideoEncoder* videoEncoder() const;
89  bool createAudioEncoder(const QString& name = QLatin1String("FFmpeg"));
96  AudioEncoder* audioEncoder() const;
101  bool isRunning() const;
102  bool isPaused() const;
103  qint64 encodedSize() const;
104  qreal startTimestamp() const;
105  qreal encodedDuration() const;
106 
111  qint64 startTime() const;
112  void setStartTime(qint64 ms);
113 
114 Q_SIGNALS:
115  void videoFrameEncoded(qreal timestamp);
116  void audioFrameEncoded(qreal timestamp);
117  void started();
118  void stopped();
119  void paused(bool value);
120  void startTimeChanged(qint64 ms);
121  void asyncChanged();
122 
123 public Q_SLOTS:
124  void start();
130  void stop();
136  void pause(bool value);
137 
138 private Q_SLOTS:
139  void onSourceStarted();
140  void prepareMuxer();
141  void writeAudio(const QtAV::Packet& packet);
142  void writeVideo(const QtAV::Packet& packet);
143  void tryFinish();
144 
145 private:
146  void stopInternal();
147  class Private;
148  QScopedPointer<Private> d;
149 };
150 } //namespace QtAV
151 #endif // QTAV_AVTRANSCODE_H
152 
#define Q_AV_EXPORT
Definition: QtAV_Global.h:40
Definition: AudioEncoder.h:32
Definition: MediaIO.h:43
Definition: Packet.h:33
Definition: AVTranscoder.h:32
The AVPlayer class Preload:
Definition: AVPlayer.h:62
AudioOutput ao; ao.setAudioFormat(fmt); ao.open(); while (has_data) { data = read_data(ao->bufferSize...
Definition: AudioDecoder.h:31
Definition: VideoEncoder.h:32