godotengine / godot

Godot Engine – Multi-platform 2D and 3D game engine
https://godotengine.org
MIT License
90.09k stars 21.14k forks source link

Localization remap doesn't work for Ogg Vorbis sounds, when language is changed at run-time #42847

Open Vinsinho opened 3 years ago

Vinsinho commented 3 years ago

Godot version: v3.2.3

OS/device including version: Windows 10

Issue description:

Steps to reproduce: Test 1:

  1. Open the test project.
  2. Open VOTEst.tscn
  3. Run the scene
  4. Placeholder voiceover will be looping (golden ball is in the game). Default language is english.
  5. Use keys 1-3 to dynamically change the locale (1 = french, 2 = deutch, 3 = english)
  6. As soon as language is changed, there will be a silence instead of voiceover in different language
  7. Notice that the golden letter switches correctly, meaning remap works fine for textures.

Test 2:

  1. Change the default language in Project setting/General/Locale to "de" or "fr"
  2. Run the scene
  3. Appropriate sounds are playing

Expected results : Based on the locale, sounds should be remaped to appropriate ogg, even realtime

Minimal reproduction project: TestVO.zip

Valeryn4 commented 2 years ago

problem is real! There was a problem during localization. 50MB of voice acting in wav weighs too much. Sometimes a detected problem leads to a crash or random sound. (My project has ~60 sound files in each language) What exactly is the problem with switching? I would edit the source myself.

Calinou commented 2 years ago

Can you test this with MP3 sounds instead of Ogg Vorbis?

Valeryn4 commented 2 years ago

Can you test this with MP3 sounds instead of Ogg Vorbis?

yes I checked. Mp3 doesn't work either. Mp3 sometimes distorts the original file after changing the localization.

rsubtil commented 2 years ago

I remember having a look at this at the time, and I think it had something to do with files having different bitrates (some were 44.1 KHz and others 48KHz), and Godot not updating that information and playing files at a wrong bitrate.

@Valeryn4 can you check if your audio files are all at the same bitrate? And check if there's no issues when switching from files at the same bitrates?

You can use file to quickly check:


$ file **/*.mp3
assets/file_example_MP3_1MG.mp3: Audio file with ID3 version...320 kbps, 44.1 kHz, Stereo
                                                                         ^^^^^^^^
...
Valeryn4 commented 2 years ago

for i in *.wav; do ffmpeg -i "$i" -vn -ar 44100 -ac 2 -b:a 192k "${i%.*}.mp3"; done

$ file ./*.mp3
./donuts.mp3:  Audio file with ID3 version 2.4.0, contains:MPEG ADTS, layer III, v1, 192 kbps, 44.1 kHz, Stereo
./eight.mp3:   Audio file with ID3 version 2.4.0, contains:MPEG ADTS, layer III, v1, 192 kbps, 44.1 kHz, Stereo
./fishes.mp3:  Audio file with ID3 version 2.4.0, contains:MPEG ADTS, layer III, v1, 192 kbps, 44.1 kHz, Stereo
./five.mp3:    Audio file with ID3 version 2.4.0, contains:MPEG ADTS, layer III, v1, 192 kbps, 44.1 kHz, Stereo
./flowers.mp3: Audio file with ID3 version 2.4.0, contains:MPEG ADTS, layer III, v1, 192 kbps, 44.1 kHz, Stereo
./four.mp3:    Audio file with ID3 version 2.4.0, contains:MPEG ADTS, layer III, v1, 192 kbps, 44.1 kHz, Stereo

image

In this test set, it works correctly. But later one of the localizations will stop working. test_AUDIO.zip

Just press various buttons and press the play button. mp3 starts chewing sound.

image

e1e5en-gd commented 2 years ago

Error in editors 3.5, 3.5.1rc2

The editor closes when working with AudioStreamPlayer. If a file with the *.ogg extension of several megabytes in size is specified in the stream field. And then rename this file, then the import operation will occur and the editor will close either when trying to start a melody (set playing to true), or clear the stream field, it may hang.

  1. Create an empty project.
  2. Add a file of several megabytes with the extension *.ogg to the project.
  3. Add the AudioStreamPlayer node.
  4. Save the scene.
  5. Specify in the stream field the file with the extension *.ogg, downloaded earlier.
  6. Rename the file (add, for example, 1).
  7. The editor closes.

Console Output:

EditorSettings: Load OK! Loaded builtin certs EditorSettings: Save OK! Loading resource: res://main_menu_loop_2.ogg Loading resource: res://main.tscn Loading resource: res://main_menu_loop_2.ogg Moving res://main_menu_loop_2.ogg -> res://main_menu_loop_3.ogg Remap: res://main_menu_loop_2.ogg -> res://main_menu_loop_3.ogg Remapping dependencies for: res://main.tscn Loading resource: res://main.tscn Loading resource: res://main_menu_loop_3.ogg FileSystem: calling rescan. FileSystem: saving moved scenes. Loading resource: res://main_menu_loop_3.ogg