thrag
thrag

Reputation: 1536

Gstreamer: How to get audio and video to play at the same rate

My pipe line is simply trying to mux an audiotestsrc with a videotestsrc and output to a filesink.

videotestsrc num-buffers=150  ! video/x-raw-yuv,width=1920, height=1080 ! 
   timeoverlay ! videorate ! queue ! xvidenc ! avimux name=mux mux.
      ! filesink sync=true location=new.avi  
audiotestsrc num-buffers=150 ! 
  queue ! audioconvert ! audiorate ! mux.

What am I missing here? I've tried every combination of sync="" properties, etc.

What pipeline would generate a test clip with autotestpattern and videotest pattern muxed together where audio and video are the same duration?

Thanks

Upvotes: 5

Views: 4922

Answers (2)

wimh
wimh

Reputation: 15232

audiotestsrc num-buffers=150

By default each buffer contains 1024 samples: samplesperbuffer Which means you are generating 150*1024=153600 samples. Asuming 44.1kHz, the duration would be 153600/44100=3.48 seconds.

So if you need 5 seconds audio, you need 5*44100=220500 samples. with samplesperbuffer==1024, this means 220500/1024=215.33 buffers. (ie 215 or 216 buffers).

It would be easier if you set samplesperbuffer to 441, then you need exactly 100 buffers for every second audio:

audiotestsrc num-buffers=500 samplesperbuffer=441

Upvotes: 8

ensonic
ensonic

Reputation: 3450

You can make use of the blocksize roperty of audiotesrc to match the duration of a frame. this is in bytes and thus you might want to use a caps filter after audiotestsrc to select a sampling-rate and sample format.

Upvotes: 2

Related Questions