diff options
author | dec05eba <dec05eba@protonmail.com> | 2022-02-19 00:28:50 +0100 |
---|---|---|
committer | dec05eba <dec05eba@protonmail.com> | 2022-02-19 00:28:50 +0100 |
commit | 7885bec3b304f79b1933156b624a293df64f7aa3 (patch) | |
tree | b04d7e07a49ae62edaf1726e812670c0fd37fbea /video_player | |
parent | 802ea9af30e00881ab505e22a5451f46f8df6f0b (diff) |
Attempt to fix video/audio desync on youtube (load audio at same time as video)
Diffstat (limited to 'video_player')
-rw-r--r-- | video_player/src/main.cpp | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/video_player/src/main.cpp b/video_player/src/main.cpp index 7489873..03acd93 100644 --- a/video_player/src/main.cpp +++ b/video_player/src/main.cpp @@ -255,12 +255,21 @@ static void mpv_set_before_init_options(mpv_handle *mpv_ctx, const Args &args) { else check_error(mpv_set_option_string(mpv_ctx, property.key.c_str(), property.value.c_str()), property.key.c_str()); } -} -static void mpv_set_after_load_options(mpv_handle *mpv_ctx, const Args &args) { if(args.audio_file) { - const char* cmd_args[] = { "audio-add", args.audio_file, "select", "Default track", nullptr }; - check_error(mpv_command_async(mpv_ctx, 0, cmd_args), "audio-add"); + mpv_node first_element; + first_element.format = MPV_FORMAT_STRING; + first_element.u.string = (char*)args.audio_file; + + mpv_node_list list; + list.num = 1; + list.keys = NULL; + list.values = &first_element; + + mpv_node node; + node.format = MPV_FORMAT_NODE_ARRAY; + node.u.list = &list; + check_error(mpv_set_option(mpv_ctx, "audio-files", MPV_FORMAT_NODE, &node), "audio-files"); } } @@ -313,7 +322,6 @@ int main(int argc, char **argv) { if(event->event_id == MPV_EVENT_START_FILE && !file_started) { file_started = true; - mpv_set_after_load_options(mpv_ctx, args); } else if(event->event_id == MPV_EVENT_SHUTDOWN) { running = false; break; |