Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

adding a delay on the audio recording with gst-launch

Tags:

gstreamer

I have this existing program that uses gst-plugin-1.0 and it passes this:

-e udpsrc port=3003 buffer-size=200000 ! h264parse ! queue ! http://mux.video_0 alsasrc device=plughw:1,0 ! "audio/x-raw,channels=1,depth=16,width=16,rate=44100" ! voaacenc bitrate=128000 ! aacparse ! queue ! http://mux.audio_0 qtmux name=mux ! filesink location="$RECPATH/record-`date +%Y%m%d%-H%M%S`.mp4" sync=true

This takes the video from an udp source which is in x264 and the audio directly from the microphone. It works but since it doesn't encode the video and the audio at the same time I have a bit of delay on the audio when the video stream has latency (due to higher quality settings).

So as a quick-fix I was thinking about adding a delay on the audio recording to compensate. I would calculate that delay by hand depending on the video quality.

Constraint: gst-launch-1.0 version 1.10.4 (on a raspberry pi, debian stretch), use-driver-timestamps doesn't seem to be accessible, I get the error 'WARNING: erroneous pipeline: no property "use-driver-timestamps" in element "alsasrc0"'.

So my question is: is there an easy way to add delay to the audio?

like image 655
Yozhgoor Avatar asked Nov 03 '20 11:11

Yozhgoor


People also ask

What is latency in gstreamer?

For example, if a video system was described as having a latency of 1 second, that would mean that it takes 1 second for the video to get from the capture (or reading a file) side to the actual display. This section will attempt to describe some real world latencies that we have seen using gstreamer and our product.

Can I build applications on top of GST-launch?

Please note that gst-launch-1.0 is primarily a debugging tool. You should not build applications on top of it. For applications, use the gst_parse_launch () function of the GStreamer API as an easy way to construct pipelines from pipeline descriptions. gst-launch-1.0 accepts the following options:

What is sound delay audio effect?

What is the Sound Delay Audio Effect? Delay is a time-based audio effect that is the main building block of most every other time and phase-based effect. Delay itself is exactly that, a lag that postpones the audio signal from playing for a number of milliseconds based on the tempo of the song.

What is delay in guitar?

Delay is an audio effect often called an echo and sometimes confused with reverb. All three are actually distinct effects than can all be understood through grasping the intricacy of the common sound delay. Everyone loves delay. One of the first effects pedals a guitarist goes after is a delay.

What options does GGST-launch-1 support?

gst-launch-1.0 also accepts the following options that are common to all GStreamer applications: A pipeline consists of elements and links. Elements can be put into bins of different sorts. Elements, links, and bins can be specified in a pipeline description in any order.


Video Answer


2 Answers

the queue element had the min-threshold-time property, which lets you hold on to data for n amount of time.

https://gstreamer.freedesktop.org/documentation/coreelements/queue.html?gi-language=c#queue:min-threshold-time

Alternatively I found this too, might be useful for your case pipeline Gstremer video streaming with delay

like image 181
Diego Rodriguez Avatar answered Nov 15 '22 10:11

Diego Rodriguez


Try ! autoaudiosink ts-offset=100000000

ts-offset is documented here.

You can also experiment pipelines with latency compensation;

https://gstreamer.freedesktop.org/documentation/additional/design/latency.html#latency-compensation

like image 35
tozlu Avatar answered Nov 15 '22 10:11

tozlu