Skip to content

Commit 654592d

Browse files
Feat/add hevc encoder (#19)
* Add Opus audio encoder as an option * add hevc encoder * Rewrite the codecs and bump libmoq. --------- Co-authored-by: Luke Curley <kixelated@gmail.com>
1 parent ac4a711 commit 654592d

3 files changed

Lines changed: 18 additions & 8 deletions

File tree

CMakePresets.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
"ENABLE_FRONTEND_API": false,
1414
"ENABLE_QT": false,
1515
"CMAKE_EXPORT_COMPILE_COMMANDS": true,
16-
"MOQ_VERSION": "0.2.0",
16+
"MOQ_VERSION": "0.2.4",
1717
"MOQ_ARCHIVE": "tar.gz"
1818
}
1919
},

src/moq-output.cpp

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,18 @@ void MoQOutput::VideoInit()
220220

221221
const char *codec = obs_encoder_get_codec(encoder);
222222

223-
video = moq_publish_media_ordered(broadcast, codec, strlen(codec), extra_data, extra_size);
223+
// Transform codec string for MoQ
224+
const char *moq_codec = codec;
225+
if (strcmp(codec, "h264") == 0) {
226+
// H.264 with inline SPS/PPS
227+
moq_codec = "avc3";
228+
} else if (strcmp(codec, "hevc") == 0) {
229+
// H.265 with inline VPS/SPS/PPS
230+
moq_codec = "hev1";
231+
}
232+
233+
// Intialize the media import module with the codec and initialization data.
234+
video = moq_publish_media_ordered(broadcast, moq_codec, strlen(moq_codec), extra_data, extra_size);
224235
if (video < 0) {
225236
LOG_ERROR("Failed to initialize video track: %d", video);
226237
return;
@@ -272,10 +283,9 @@ void register_moq_output()
272283
{
273284
const uint32_t base_flags = OBS_OUTPUT_ENCODED | OBS_OUTPUT_SERVICE;
274285

275-
// TODO: Add support for other codecs.
276-
const char *audio_codecs = "aac";
277-
// TODO: Add support for other codecs.
278-
const char *video_codecs = "h264";
286+
const char *audio_codecs = "aac;opus";
287+
// TODO: Add support for AV1, VP9.
288+
const char *video_codecs = "h264;hevc";
279289

280290
struct obs_output_info info = {};
281291
info.id = "moq_output";

src/moq-service.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
#include "moq-service.h"
22

33
// TODO: Define supported codecs.
4-
const char *audio_codecs[] = {"aac", nullptr};
5-
const char *video_codecs[] = {"h264", nullptr};
4+
const char *audio_codecs[] = {"aac", "opus", nullptr};
5+
const char *video_codecs[] = {"h264", "hevc", nullptr};
66

77
MoQService::MoQService(obs_data_t *settings, obs_service_t *) : server(), path()
88
{

0 commit comments

Comments
 (0)