Skip to content

Commit

Permalink
重构transcode-3;
Browse files Browse the repository at this point in the history
  • Loading branch information
RealChuan committed Feb 29, 2024
1 parent 85c622b commit b1dc519
Show file tree
Hide file tree
Showing 23 changed files with 759 additions and 308 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
- [简体中文](README.md)
- [English](README.en.md)

## QFfmpegPlayer
## Player

<div align=center><img src="doc/player.jpeg"></div>

Expand Down Expand Up @@ -56,7 +56,7 @@ Dialogue: 0,0:01:06.77,0:01:08.00,en,,0000,0000,0000,,Peek-a-boo!\r\n
subtitles=filename='%1':original_size=%2x%3
```

## QFfmpegTranscoder
## Transcoder

如何设置编码参数以获得更小的文件和更好的视频质量?

Expand Down
13 changes: 6 additions & 7 deletions examples/player/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,13 @@ set(PROJECT_SOURCES
titlewidget.cc
titlewidget.hpp)

qt_add_executable(QFfmpegPlayer MANUAL_FINALIZATION ${PROJECT_SOURCES})
target_link_libraries(
QFfmpegPlayer PRIVATE ffmpeg thirdparty utils Qt6::Widgets Qt6::Multimedia
Qt6::OpenGLWidgets)
target_link_libraries(QFfmpegPlayer PRIVATE PkgConfig::ffmpeg)
qt_add_executable(Player MANUAL_FINALIZATION ${PROJECT_SOURCES})
target_link_libraries(Player PRIVATE ffmpeg thirdparty utils Qt6::Widgets
Qt6::Multimedia Qt6::OpenGLWidgets)
target_link_libraries(Player PRIVATE PkgConfig::ffmpeg)
if(CMAKE_HOST_APPLE)
target_link_libraries(
QFfmpegPlayer
Player
PRIVATE ${Foundation_LIBRARY}
${CoreAudio_LIBRARY}
${AVFoundation_LIBRARY}
Expand All @@ -46,4 +45,4 @@ if(CMAKE_HOST_APPLE)
${CoreVideo_LIBRARY}
${CoreServices_LIBRARY})
endif()
qt_finalize_executable(QFfmpegPlayer)
qt_finalize_executable(Player)
2 changes: 1 addition & 1 deletion examples/player/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
#include <QNetworkProxyFactory>
#include <QStyle>

#define AppName "QFfmpegPlayer"
#define AppName "Player"

void setAppInfo()
{
Expand Down
2 changes: 1 addition & 1 deletion examples/player/player.pro
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ QT += core gui widgets network multimedia openglwidgets core5compat

TEMPLATE = app

TARGET = QFfmpegPlayer
TARGET = Player

LIBS += \
-L$$APP_OUTPUT_PATH/../libs \
Expand Down
23 changes: 15 additions & 8 deletions examples/transcoder/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,21 +1,28 @@
set(PROJECT_SOURCES
audioencoderwidget.cc
audioencoderwidget.hpp
main.cc
mainwindow.cc
mainwindow.hpp
outputwidget.cc
outputwidget.hpp
previewwidget.cc
previewwidget.hpp
sourcewidget.cc
sourcewidget.hpp)
sourcewidget.hpp
stautuswidget.cc
stautuswidget.hpp
videoencoderwidget.cc
videoencoderwidget.hpp)

qt_add_executable(QFfmpegTranscoder MANUAL_FINALIZATION ${PROJECT_SOURCES})
target_link_libraries(
QFfmpegTranscoder PRIVATE ffmpeg thirdparty utils Qt6::Widgets
Qt6::Multimedia Qt6::OpenGLWidgets)
target_link_libraries(QFfmpegTranscoder PRIVATE PkgConfig::ffmpeg)
qt_add_executable(Transcoder MANUAL_FINALIZATION ${PROJECT_SOURCES})
target_link_libraries(Transcoder PRIVATE ffmpeg thirdparty utils Qt6::Widgets
Qt6::Multimedia Qt6::OpenGLWidgets)
target_link_libraries(Transcoder PRIVATE PkgConfig::ffmpeg)

if(CMAKE_HOST_APPLE)
target_link_libraries(
QFfmpegTranscoder
Transcoder
PRIVATE ${Foundation_LIBRARY}
${CoreAudio_LIBRARY}
${AVFoundation_LIBRARY}
Expand All @@ -33,4 +40,4 @@ if(CMAKE_HOST_APPLE)
${CoreServices_LIBRARY})
endif()

qt_finalize_executable(QFfmpegTranscoder)
qt_finalize_executable(Transcoder)
64 changes: 64 additions & 0 deletions examples/transcoder/audioencoderwidget.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
#include "audioencoderwidget.hpp"

#include <ffmpeg/ffmpegutils.hpp>

#include <QtWidgets>

class AudioEncoderWidget::AudioEncoderWidgetPrivate
{
public:
explicit AudioEncoderWidgetPrivate(AudioEncoderWidget *q)
: q_ptr(q)
{
audioEncoderCbx = new QComboBox(q_ptr);
audioEncoderCbx->setView(new QListView(audioEncoderCbx));
audioEncoderCbx->setMaxVisibleItems(10);
audioEncoderCbx->setStyleSheet("QComboBox {combobox-popup:0;}");

auto audioEncodercs = Ffmpeg::getCurrentSupportCodecs(AVMEDIA_TYPE_AUDIO, true);
for (auto iter = audioEncodercs.cbegin(); iter != audioEncodercs.cend(); ++iter) {
audioEncoderCbx->addItem(iter.value(), iter.key());
}
audioEncoderCbx->setCurrentIndex(audioEncoderCbx->findData(AV_CODEC_ID_AAC));
audioEncoderCbx->model()->sort(0);
}

AudioEncoderWidget *q_ptr;

QComboBox *audioEncoderCbx;
};

AudioEncoderWidget::AudioEncoderWidget(QWidget *parent)
: QWidget{parent}
, d_ptr(new AudioEncoderWidgetPrivate(this))
{
setupUI();
buildConnect();
}

AudioEncoderWidget::~AudioEncoderWidget() = default;

auto AudioEncoderWidget::setEncoder(AVCodecID codecId) -> bool
{
auto index = d_ptr->audioEncoderCbx->findData(codecId);
auto finded = (index >= 0);
if (finded) {
d_ptr->audioEncoderCbx->setCurrentIndex(index);
}
return finded;
}

auto AudioEncoderWidget::encoder() const -> QString
{
return d_ptr->audioEncoderCbx->currentText();
}

void AudioEncoderWidget::setupUI()
{
auto *layout = new QHBoxLayout(this);
layout->addWidget(new QLabel(tr("Encoder:")));
layout->addWidget(d_ptr->audioEncoderCbx);
layout->addStretch();
}

void AudioEncoderWidget::buildConnect() {}
28 changes: 28 additions & 0 deletions examples/transcoder/audioencoderwidget.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#ifndef AUDIOENCODERWIDGET_HPP
#define AUDIOENCODERWIDGET_HPP

#include <QWidget>

extern "C" {
#include <libavcodec/codec_id.h>
}

class AudioEncoderWidget : public QWidget
{
Q_OBJECT
public:
explicit AudioEncoderWidget(QWidget *parent = nullptr);
~AudioEncoderWidget() override;

auto setEncoder(AVCodecID codecId) -> bool;
[[nodiscard]] auto encoder() const -> QString;

private:
void setupUI();
void buildConnect();

class AudioEncoderWidgetPrivate;
QScopedPointer<AudioEncoderWidgetPrivate> d_ptr;
};

#endif // AUDIOENCODERWIDGET_HPP
2 changes: 1 addition & 1 deletion examples/transcoder/main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#include <QNetworkProxyFactory>
#include <QStyle>

#define AppnName "QFfmpegTranscoder"
#define AppnName "Transcoder"

void setAppInfo()
{
Expand Down
Loading

0 comments on commit b1dc519

Please sign in to comment.