Skip to content

Commit

Permalink
Added a GOP setting to the MP4 output stream
Browse files Browse the repository at this point in the history
  • Loading branch information
wberube committed Sep 11, 2024
1 parent 865afdf commit 267b1ba
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 1 deletion.
1 change: 1 addition & 0 deletions divinus.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ mp4:
width: 3840
height: 2160
fps: 20
gop: 40
bitrate: 1024
profile: 2

Expand Down
3 changes: 3 additions & 0 deletions src/app_config.c
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ int save_app_config(void) {
fprintf(file, " width: %d\n", app_config.mp4_width);
fprintf(file, " height: %d\n", app_config.mp4_height);
fprintf(file, " fps: %d\n", app_config.mp4_fps);
fprintf(file, " gop: %f\n", app_config.mp4_gop);
fprintf(file, " profile: %d\n", app_config.mp4_profile);
fprintf(file, " bitrate: %d\n", app_config.mp4_bitrate);

Expand Down Expand Up @@ -293,6 +294,8 @@ enum ConfigError parse_app_config(void) {
err = parse_int(&ini, "mp4", "fps", 1, INT_MAX, &app_config.mp4_fps);
if (err != CONFIG_OK)
goto RET_ERR;
app_config.mp4_gop = app_config.mp4_fps;
parse_int(&ini, "mp4", "gop", 1, INT_MAX, &app_config.mp4_gop);
{
const char *possible_values[] = {"BP", "MP", "HP"};
const int count = sizeof(possible_values) / sizeof(const char *);
Expand Down
1 change: 1 addition & 0 deletions src/app_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ struct AppConfig {
bool mp4_codecH265;
unsigned int mp4_mode;
unsigned int mp4_fps;
unsigned int mp4_gop;
unsigned int mp4_width;
unsigned int mp4_height;
unsigned int mp4_profile;
Expand Down
2 changes: 1 addition & 1 deletion src/media.c
Original file line number Diff line number Diff line change
Expand Up @@ -492,7 +492,7 @@ int enable_mp4(void) {
HAL_VIDCODEC_H265 : HAL_VIDCODEC_H264;
config.mode = app_config.mp4_mode;
config.profile = app_config.mp4_profile;
config.gop = app_config.mp4_fps * 2;
config.gop = app_config.mp4_gop;
config.framerate = app_config.mp4_fps;
config.bitrate = app_config.mp4_bitrate;
config.maxBitrate = app_config.mp4_bitrate * 5 / 4;
Expand Down

0 comments on commit 267b1ba

Please sign in to comment.