Audio sync can backtrack in time #44195

Closed
opened 2015-03-30 18:48:12 +02:00 by Antonis Ryakiotakis · 6 comments

System Information
Ubuntu 14.10 64bit
Memory 7,8 GiB
Intel Xeon(R) CPU E31280 @ 3.50GHz × 4
NVIDIA Quadro 2000/PCIe/SSE2

Blender Version
Broken: 590efaa

Short description of error
Audio sync can backtrack in time when playing an animation.

Exact steps for others to reproduce the error

  • Compile blender after uncommenting definition of PROFILE_AUDIO_SYNCH in screen_ops.c
  • Default scene, enable audio sync
  • Let animation play for some time and check at the output of blender in the command line

You should notice forward jumps and back jump detections at some point.
Forward jumps are normal (can happen when blender processing lags audio processing)
but back jumps are not - suggests an error in the code that calculates the audio offset.

**System Information** Ubuntu 14.10 64bit Memory 7,8 GiB Intel Xeon(R) CPU E31280 @ 3.50GHz × 4 NVIDIA Quadro 2000/PCIe/SSE2 **Blender Version** Broken: 590efaa **Short description of error** Audio sync can backtrack in time when playing an animation. **Exact steps for others to reproduce the error** * Compile blender after uncommenting definition of PROFILE_AUDIO_SYNCH in screen_ops.c * Default scene, enable audio sync * Let animation play for some time and check at the output of blender in the command line You should notice forward jumps and back jump detections at some point. Forward jumps are normal (can happen when blender processing lags audio processing) but back jumps are not - suggests an error in the code that calculates the audio offset.
Author
Member

Changed status to: 'Open'

Changed status to: 'Open'
Joerg Mueller was assigned by Antonis Ryakiotakis 2015-03-30 18:48:12 +02:00
Author
Member

Added subscriber: @Psy-Fi

Added subscriber: @Psy-Fi

Added subscriber: @mont29

Added subscriber: @mont29
Member

Hi,

at first I couldn't reproduce the problem at all, but with the default suspects I quickly found that with pulseaudio running this problem appears. After looking a bit into details, I found that the reason for this problem is the buffer size used somewhere in this system, as your hint regarding the big chunks of second offsets suggested.

All your suggested solutions (frame tolerance, wait functions, semaphores) only try to work around the actual problem and have little chance of success in any case, you have to tackle the actual problem... Please revert the frame tolerance commit as it makes AV-sync less precise in any case, even when playback appears more smooth with it!

To get the buffer size down, I first tried to configure pulseaudio with the default-fragments and default-fragment-size-msec settings, but that didn't help.

Talking to Chris Robinson, the OpenAL soft developer, he told me that these values can be configured in the OpenAL configuration as well and also suggested an OpenAL soft extension for AV sync.

The configuration solves the problem for me and you should try it, just put this configuration into the ~/.alsoftrc file:

[general]
drivers = pulse
period_size = 128
periods = 2

This resolved the problem for me and I don't get any jumps anymore neither with nor without the tolerance code you added.

Regarding better AV sync, I wrote the openal_latency_patch.diff patch. The patch alone doesn't resolve the problem completely, just makes it a bit better. Also this only works with OpenAL soft, so compilation without it (on Mac and Windows) will fail and the code changes also interfere with audio in the game engine, so please do not commit this patch to master in any case! I added a define to switch the functionality off and on quickly. You might want to try it out with artists to check if they notice any difference when lip-syncing.

The ultimate solution I have for this and other problems is to write a direct pulseaudio backend for audaspace, but this requires way more time and I'd also do this with the C++11 version of audaspace, which has more improvements already.

I'll close the task for now. If the configuration file doesn't fix the problem for you, feel free to reopen the task.

Cheers

Hi, at first I couldn't reproduce the problem at all, but with the default suspects I quickly found that with pulseaudio running this problem appears. After looking a bit into details, I found that the reason for this problem is the buffer size used somewhere in this system, as your hint regarding the big chunks of second offsets suggested. All your suggested solutions (frame tolerance, wait functions, semaphores) only try to work around the actual problem and have little chance of success in any case, you have to tackle the actual problem... Please revert the frame tolerance commit as it makes AV-sync less precise in any case, even when playback appears more smooth with it! To get the buffer size down, I first tried to configure pulseaudio with the default-fragments and default-fragment-size-msec settings, but that didn't help. Talking to Chris Robinson, the OpenAL soft developer, he told me that these values can be configured in the OpenAL configuration as well and also suggested an OpenAL soft extension for AV sync. The configuration solves the problem for me and you should try it, just put this configuration into the `~/.alsoftrc` file: ``` [general] drivers = pulse period_size = 128 periods = 2 ``` This resolved the problem for me and I don't get any jumps anymore neither with nor without the tolerance code you added. Regarding better AV sync, I wrote the [openal_latency_patch.diff](https://archive.blender.org/developer/F164975/openal_latency_patch.diff) patch. The patch alone doesn't resolve the problem completely, just makes it a bit better. Also this only works with OpenAL soft, so compilation without it (on Mac and Windows) will fail and the code changes also interfere with audio in the game engine, so please do not commit this patch to master in any case! I added a define to switch the functionality off and on quickly. You might want to try it out with artists to check if they notice any difference when lip-syncing. The ultimate solution I have for this and other problems is to write a direct pulseaudio backend for audaspace, but this requires way more time and I'd also do this with the C++11 version of audaspace, which has more improvements already. I'll close the task for now. If the configuration file doesn't fix the problem for you, feel free to reopen the task. Cheers
Member

Changed status from 'Open' to: 'Resolved'

Changed status from 'Open' to: 'Resolved'
Author
Member

Frame tolerance is not a good solution indeed, ideally this code would just sleep for a small time and re-query the sound library until frame changes. I tried this too a few weeks back without success. Maybe with the new configuration this might be more of a plausible and correct solution though. Anyway, thanks for the heads up, I will check it out.

Frame tolerance is not a good solution indeed, ideally this code would just sleep for a small time and re-query the sound library until frame changes. I tried this too a few weeks back without success. Maybe with the new configuration this might be more of a plausible and correct solution though. Anyway, thanks for the heads up, I will check it out.
Sign in to join this conversation.
No Label
Interest
Alembic
Interest
Animation & Rigging
Interest
Asset Browser
Interest
Asset Browser Project Overview
Interest
Audio
Interest
Automated Testing
Interest
Blender Asset Bundle
Interest
BlendFile
Interest
Collada
Interest
Compatibility
Interest
Compositing
Interest
Core
Interest
Cycles
Interest
Dependency Graph
Interest
Development Management
Interest
EEVEE
Interest
EEVEE & Viewport
Interest
Freestyle
Interest
Geometry Nodes
Interest
Grease Pencil
Interest
ID Management
Interest
Images & Movies
Interest
Import Export
Interest
Line Art
Interest
Masking
Interest
Metal
Interest
Modeling
Interest
Modifiers
Interest
Motion Tracking
Interest
Nodes & Physics
Interest
OpenGL
Interest
Overlay
Interest
Overrides
Interest
Performance
Interest
Physics
Interest
Pipeline, Assets & IO
Interest
Platforms, Builds & Tests
Interest
Python API
Interest
Render & Cycles
Interest
Render Pipeline
Interest
Sculpt, Paint & Texture
Interest
Text Editor
Interest
Translations
Interest
Triaging
Interest
Undo
Interest
USD
Interest
User Interface
Interest
UV Editing
Interest
VFX & Video
Interest
Video Sequencer
Interest
Virtual Reality
Interest
Vulkan
Interest
Wayland
Interest
Workbench
Interest: X11
Legacy
Blender 2.8 Project
Legacy
Milestone 1: Basic, Local Asset Browser
Legacy
OpenGL Error
Meta
Good First Issue
Meta
Papercut
Meta
Retrospective
Meta
Security
Module
Animation & Rigging
Module
Core
Module
Development Management
Module
EEVEE & Viewport
Module
Grease Pencil
Module
Modeling
Module
Nodes & Physics
Module
Pipeline, Assets & IO
Module
Platforms, Builds & Tests
Module
Python API
Module
Render & Cycles
Module
Sculpt, Paint & Texture
Module
Triaging
Module
User Interface
Module
VFX & Video
Platform
FreeBSD
Platform
Linux
Platform
macOS
Platform
Windows
Priority
High
Priority
Low
Priority
Normal
Priority
Unbreak Now!
Status
Archived
Status
Confirmed
Status
Duplicate
Status
Needs Info from Developers
Status
Needs Information from User
Status
Needs Triage
Status
Resolved
Type
Bug
Type
Design
Type
Known Issue
Type
Patch
Type
Report
Type
To Do
No Milestone
No project
No Assignees
3 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: blender/blender#44195
No description provided.