mirror of
https://github.com/obsproject/obs-studio.git
synced 2024-07-19 17:49:14 +00:00
Do test recording to a specified file
It will now output to a a filename that you specify when you click the record button. This is just for testing.
This commit is contained in:
parent
590a486343
commit
1b8bd57dac
|
@ -126,6 +126,15 @@ void obs_output_update(obs_output_t output, obs_data_t settings)
|
|||
output->callbacks.update(output->data, output->settings);
|
||||
}
|
||||
|
||||
obs_data_t obs_output_get_settings(obs_output_t output)
|
||||
{
|
||||
if (!output)
|
||||
return NULL;
|
||||
|
||||
obs_data_addref(output->settings);
|
||||
return output->settings;
|
||||
}
|
||||
|
||||
bool obs_output_canpause(obs_output_t output)
|
||||
{
|
||||
return output->callbacks.pause != NULL;
|
||||
|
|
|
@ -45,8 +45,8 @@
|
|||
<widget class="OBSQTDisplay" name="preview" native="true">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>50</x>
|
||||
<y>30</y>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>32</width>
|
||||
<height>32</height>
|
||||
</rect>
|
||||
|
@ -340,6 +340,9 @@
|
|||
</property>
|
||||
<item>
|
||||
<widget class="QPushButton" name="streamButton">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Start Streaming</string>
|
||||
</property>
|
||||
|
@ -436,6 +439,9 @@
|
|||
</property>
|
||||
</action>
|
||||
<action name="actionSceneProperties">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="obs.qrc">
|
||||
<normaloff>:/res/images/properties.ico</normaloff>:/res/images/properties.ico</iconset>
|
||||
|
@ -445,6 +451,9 @@
|
|||
</property>
|
||||
</action>
|
||||
<action name="actionSourceProperties">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="obs.qrc">
|
||||
<normaloff>:/res/images/properties.ico</normaloff>:/res/images/properties.ico</iconset>
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
#include <obs.hpp>
|
||||
#include <QMessageBox>
|
||||
#include <QShowEvent>
|
||||
#include <QFileDialog>
|
||||
|
||||
#include "obs-app.hpp"
|
||||
#include "window-basic-settings.hpp"
|
||||
|
@ -35,7 +36,8 @@ Q_DECLARE_METATYPE(OBSSceneItem);
|
|||
|
||||
OBSBasic::OBSBasic(QWidget *parent)
|
||||
: OBSMainWindow (parent),
|
||||
ui (new Ui::OBSBasic)
|
||||
ui (new Ui::OBSBasic),
|
||||
outputTest (NULL)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
}
|
||||
|
@ -64,10 +66,6 @@ void OBSBasic::OBSInit()
|
|||
obs_load_module("test-input");
|
||||
obs_load_module("obs-ffmpeg");
|
||||
|
||||
/*obs_output_t output = obs_output_create("ffmpeg_output", "test",
|
||||
NULL);
|
||||
obs_output_start(output);*/
|
||||
|
||||
/* HACK: fixes a qt bug with native widgets with native repaint */
|
||||
ui->previewContainer->repaint();
|
||||
}
|
||||
|
@ -540,6 +538,36 @@ void OBSBasic::on_actionSourceDown_triggered()
|
|||
{
|
||||
}
|
||||
|
||||
void OBSBasic::on_recordButton_clicked()
|
||||
{
|
||||
if (outputTest) {
|
||||
obs_output_destroy(outputTest);
|
||||
outputTest = NULL;
|
||||
ui->recordButton->setText("Start Recording");
|
||||
} else {
|
||||
QString path = QFileDialog::getSaveFileName(this,
|
||||
"Please enter a file name", QString(),
|
||||
"Video Files (*.mp4)");
|
||||
|
||||
if (path.isNull() || path.isEmpty())
|
||||
return;
|
||||
|
||||
obs_data_t data = obs_data_create();
|
||||
obs_data_setstring(data, "filename", QT_TO_UTF8(path));
|
||||
|
||||
outputTest = obs_output_create("ffmpeg_output", "test", data);
|
||||
obs_data_release(data);
|
||||
|
||||
if (!obs_output_start(outputTest)) {
|
||||
obs_output_destroy(outputTest);
|
||||
outputTest = NULL;
|
||||
return;
|
||||
}
|
||||
|
||||
ui->recordButton->setText("Stop Recording");
|
||||
}
|
||||
}
|
||||
|
||||
void OBSBasic::on_settingsButton_clicked()
|
||||
{
|
||||
OBSBasicSettings settings(this);
|
||||
|
|
|
@ -31,6 +31,7 @@ class OBSBasic : public OBSMainWindow {
|
|||
|
||||
private:
|
||||
std::unordered_map<obs_source_t, int> sourceSceneRefs;
|
||||
obs_output_t outputTest;
|
||||
|
||||
OBSScene GetCurrentScene();
|
||||
OBSSceneItem GetCurrentSceneItem();
|
||||
|
@ -87,6 +88,7 @@ private slots:
|
|||
void on_actionSourceProperties_triggered();
|
||||
void on_actionSourceUp_triggered();
|
||||
void on_actionSourceDown_triggered();
|
||||
void on_recordButton_clicked();
|
||||
void on_settingsButton_clicked();
|
||||
|
||||
public:
|
||||
|
|
|
@ -19,7 +19,6 @@
|
|||
#include "obs-ffmpeg-output.h"
|
||||
|
||||
/* TODO: remove these later */
|
||||
#define FILENAME_TODO "D:\\test.avi"
|
||||
#define SPS_TODO 44100
|
||||
|
||||
/* NOTE: much of this stuff is test stuff that was more or less copied from
|
||||
|
@ -233,11 +232,11 @@ static inline bool open_output_file(struct ffmpeg_data *data)
|
|||
int ret;
|
||||
|
||||
if ((format->flags & AVFMT_NOFILE) == 0) {
|
||||
ret = avio_open(&data->output->pb, FILENAME_TODO,
|
||||
ret = avio_open(&data->output->pb, data->filename_test,
|
||||
AVIO_FLAG_WRITE);
|
||||
if (ret < 0) {
|
||||
blog(LOG_ERROR, "Couldn't open file '%s', %s",
|
||||
FILENAME_TODO, av_err2str(ret));
|
||||
data->filename_test, av_err2str(ret));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -245,7 +244,7 @@ static inline bool open_output_file(struct ffmpeg_data *data)
|
|||
ret = avformat_write_header(data->output, NULL);
|
||||
if (ret < 0) {
|
||||
blog(LOG_ERROR, "Error opening file '%s': %s",
|
||||
FILENAME_TODO, av_err2str(ret));
|
||||
data->filename_test, av_err2str(ret));
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -286,15 +285,19 @@ static void ffmpeg_data_free(struct ffmpeg_data *data)
|
|||
memset(data, 0, sizeof(struct ffmpeg_data));
|
||||
}
|
||||
|
||||
static bool ffmpeg_data_init(struct ffmpeg_data *data)
|
||||
static bool ffmpeg_data_init(struct ffmpeg_data *data, const char *filename)
|
||||
{
|
||||
memset(data, 0, sizeof(struct ffmpeg_data));
|
||||
data->filename_test = filename;
|
||||
|
||||
if (!filename || !*filename)
|
||||
return false;
|
||||
|
||||
av_register_all();
|
||||
|
||||
/* TODO: settings */
|
||||
avformat_alloc_output_context2(&data->output, NULL, NULL,
|
||||
FILENAME_TODO);
|
||||
data->filename_test);
|
||||
if (!data->output) {
|
||||
blog(LOG_ERROR, "Couldn't create avformat context");
|
||||
goto fail;
|
||||
|
@ -327,7 +330,7 @@ void test_callback(void *param, int bla, const char *format, va_list args)
|
|||
blogva(LOG_INFO, format, args);
|
||||
}
|
||||
|
||||
struct ffmpeg_output *ffmpeg_output_create(const char *settings,
|
||||
struct ffmpeg_output *ffmpeg_output_create(obs_data_t settings,
|
||||
obs_output_t output)
|
||||
{
|
||||
struct ffmpeg_output *data = bzalloc(sizeof(struct ffmpeg_output));
|
||||
|
@ -347,7 +350,7 @@ void ffmpeg_output_destroy(struct ffmpeg_output *data)
|
|||
}
|
||||
}
|
||||
|
||||
void ffmpeg_output_update(struct ffmpeg_output *data, const char *settings)
|
||||
void ffmpeg_output_update(struct ffmpeg_output *data, obs_data_t settings)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -521,7 +524,15 @@ bool ffmpeg_output_start(struct ffmpeg_output *data)
|
|||
return false;
|
||||
}
|
||||
|
||||
if (!ffmpeg_data_init(&data->ff_data))
|
||||
const char *filename_test;
|
||||
obs_data_t settings = obs_output_get_settings(data->output);
|
||||
filename_test = obs_data_getstring(settings, "filename");
|
||||
obs_data_release(settings);
|
||||
|
||||
if (!filename_test || !*filename_test)
|
||||
return false;
|
||||
|
||||
if (!ffmpeg_data_init(&data->ff_data, filename_test))
|
||||
return false;
|
||||
|
||||
struct audio_convert_info aci;
|
||||
|
|
|
@ -43,6 +43,8 @@ struct ffmpeg_data {
|
|||
AVFrame *aframe;
|
||||
int total_samples;
|
||||
|
||||
const char *filename_test;
|
||||
|
||||
bool initialized;
|
||||
};
|
||||
|
||||
|
@ -54,12 +56,12 @@ struct ffmpeg_output {
|
|||
|
||||
EXPORT const char *ffmpeg_output_getname(const char *locale);
|
||||
|
||||
EXPORT struct ffmpeg_output *ffmpeg_output_create(const char *settings,
|
||||
EXPORT struct ffmpeg_output *ffmpeg_output_create(obs_data_t settings,
|
||||
obs_output_t output);
|
||||
EXPORT void ffmpeg_output_destroy(struct ffmpeg_output *data);
|
||||
|
||||
EXPORT void ffmpeg_output_update(struct ffmpeg_output *data,
|
||||
const char *settings);
|
||||
obs_data_t settings);
|
||||
|
||||
EXPORT bool ffmpeg_output_start(struct ffmpeg_output *data);
|
||||
EXPORT void ffmpeg_output_stop(struct ffmpeg_output *data);
|
||||
|
|
Loading…
Reference in a new issue