gst-launch-0.10 no syncronized audio with alsa and hdmi

565 Views Asked by At

I'm working on a imx 6DualLite.

I can't add or edit system libraries.

I have to play an audio file from hdmi and speakers.

This is the pipeline I am using:

gst-launch-0.10 filesrc location=/home/root/beep.wav ! wavparse ! audioconvert ! audioresample ! tee name=t ! queue ! alsasink t. ! queue ! volume volume=1 ! alsasink device=sysdefault:CARD=imxhdmisoc

The problem is that the audio of the speakers is not synchronized with the audio of the hdmi

I've already tried to add

... alsasink device=sysdefault:CARD=imxhdmisoc sync=TRUE
2

There are 2 best solutions below

0
On BEST ANSWER

I found a solution (in my case it worked) by linking the two cards that are displayed with the command:

~ $ cat / proc / asound / cards
  0 [DWHDMI]: dw-hdmi-ahb-aud - DW-HDMI
                       DW-HDMI rev 0x0a, irq 22
  1 [sgtl5000audio]: sgtl5000-audio - sgtl5000-audio
                       sgtl5000-audio
  2 [tda1997xaudio]: tda1997x-audio - tda1997x-audio
                       tda1997x-audio

By following this guide: https://www.alsa-project.org/wiki/Asoundrc#Virtual_multi_channel_devices

I edited the file /etc/asound.conf. I do not quote the whole file (it is very long) but only the last part that I modified:

...

pcm.!default{
type plug
route_policy "average"
slave.pcm "asymed"
}

ctl.!default{
type hw
card 0
}

ctl.mixer0{
type hw
card 0
}

became

...

pcm.!default{
type plug
route_policy "average"
slave.pcm "asymed"
}

ctl.mixer0{
type hw
card 0
}

pcm.primary{
        type hw
        card 0
        device 0
}

ctl.primary {
  type hw
  card 0
}

pcm.secondary{
        type hw
        card 1
        device 0
}

ctl.secondary {
  type hw
  card 1
}

pcm.multi {
  type multi
  slaves.a.pcm "primary"
  slaves.a.channels 2
  slaves.b.pcm "secondary"
  slaves.b.channels 2
  bindings.0.slave a
  bindings.0.channel 0
  bindings.1.slave a
  bindings.1.channel 1
  bindings.2.slave b
  bindings.2.channel 0
  bindings.3.slave b
  bindings.3.channel 1
}
0
On

As Florian mentioned, I'm not sure you'll realistically be able to expect the outputs to be synchronized automatically.

But if you don't mind some user intervention and/or hard-coding, you could experiment with the render-delay property of each alsasink. Set the value in nanoseconds. (e.g. one second is 1000000000 nanos).

Here's a sample with video:

gst-launch-1.0 videotestsrc pattern=ball ! videoconvert ! tee name=t ! queue ! ximagesink t. ! queue ! ximagesink render-delay=1000000000