Skip to content

Commit

Permalink
FFmpegEncoder/Feat: Respect sync mode option
Browse files Browse the repository at this point in the history
Can now sync in various ways, including not at all, as dictated by synchronization_mode.

The sync modes don't function the same way internally as in VFW, but audio sync remains more reliable.
  • Loading branch information
Aurumaker72 committed Dec 19, 2024
1 parent 794a71a commit 645fbae
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions view/capture/encoders/FFmpegEncoder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -163,10 +163,19 @@ bool FFmpegEncoder::append_audio_impl(uint8_t* audio, size_t length)

bool FFmpegEncoder::append_video(uint8_t* image)
{
if (lag_count > 2)
if (g_config.synchronization_mode == 1)
{
const auto samples_per_frame = static_cast<double>(m_params.arate) / m_params.fps;
append_audio_impl(m_silence_buffer, static_cast<size_t>(round(samples_per_frame)));
if (m_last_write_was_video)
{
return true;
}
} else if (g_config.synchronization_mode == 2)
{
if (lag_count > 2)
{
const auto samples_per_frame = static_cast<double>(m_params.arate) / m_params.fps;
append_audio_impl(m_silence_buffer, static_cast<size_t>(round(samples_per_frame)));
}
}

m_last_write_was_video = true;
Expand Down

0 comments on commit 645fbae

Please sign in to comment.