“level” Plugin Producing level value outside of Stated Range
Describe your issue
(I was told this may be a bug and asked to report it here, but if I've done something incorrect, please let me know.)
With what should be a muted/silent .wav file, if I run it through a pipeline that sends downstream audio level metadata (from the "level" plugin, in this case) and try to output the level
value from that structure downstream from some custom plugin, at each interval, the value in question is always 187.
https://gstreamer.freedesktop.org/documentation/audio/gstaudiometa.html?gi-language=c#GstAudioLevelMeta
states that the range of the value should be 0 to 127, with 127 being silence (since the unit is dBov).
Expected Behavior
The level
value should be 127.
Observed Behavior
The level
values is 187.
Setup
- Operating System: Ubuntu 22.04
- Device: Computer (running GStreamer in an NVIDIA DeepStream 7.1 Docker container)
- GStreamer Version: 1.20.3
- Command line: Please see the steps to reproduce below.
Steps to reproduce the bug
- Create a muted/silent .wav file by using a custom plugin to zero-out buffer data. I did this by using one of DeepStream's audio plugins (
gst-nvdsaudiotemplate
), which relays data to a user-defined class. I modified that user-defined class to work with the in-buffer like so:
int UserDefined::doWork(GstBuffer *inbuf) {
// ...
GstMapInfo in_map_info = {0};
memset(&in_map_info, 0, sizeof(in_map_info));
gst_buffer_map(inbuf, &in_map_info, GST_MAP_READ);
GstAudioLevelMeta *level_meta = gst_buffer_get_audio_level_meta(inbuf);
if (level_meta) {
std::cout << "Level: " << unsigned(level_meta->level) << std::endl;
}
guint8 *data = (guint8 *)in_map_info.data;
unsigned int i = 0;
for (i = 0; i < in_map_info.size; i++) {
// data[i] = data[i] + 0; // ****** THIS IS UNCOMMENTED AFTER THE MUTED FILE HAS BEEN GENERATED
data[i] = 0; // ******* THIS IS COMMENTED OUT AFTER THE MUTED FILE HAS BEEN GENERATED
}
// ...
}
(In the actual plugin code in DeepStream, the above actually adds some noise to the buffer, but that isn't relevant here.)
The following pipeline can be used to generate the muted/silenced file:
gst-launch-1.0 filesrc location= ./some_sounds.wav ! wavparse ! \
identity silent=0 ! nvdsaudiotemplate customlib-props="noise-factor:50" customlib-name="./libcustom_audioimpl.so" \
! wavenc ! filesink location=muted.wav
-
Optional: Update the plugin by commenting/uncommenting the appropriate lines above and recompiling.
-
Run the following pipeline and observe the "Level" outputs:
gst-launch-1.0 filesrc location= ./muted.wav ! wavparse ! \
identity silent=0 ! level post-messages=FALSE interval=500 audio-level-meta=TRUE ! nvdsaudiotemplate customlib-props="noise-factor:50" customlib-name="./libcustom_audioimpl.so"\
! wavenc ! filesink location= ignore.wav
How reproducible is the bug?
Always