After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 511489 - avimux muxed audio and video out of sync
avimux muxed audio and video out of sync
Status: RESOLVED FIXED
Product: GStreamer
Classification: Platform
Component: gst-plugins-good
0.10.6
Other All
: Normal normal
: 0.10.9
Assigned To: GStreamer Maintainers
GStreamer Maintainers
Depends on:
Blocks:
 
 
Reported: 2008-01-23 09:56 UTC by Ruud Schramp
Modified: 2008-05-21 15:26 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Patch to fix (pcm) audio stream header (876 bytes, patch)
2008-03-03 17:01 UTC, Mark Nauwelaerts
none Details | Review
Patch to fix (pcm) audio stream header (1.80 KB, patch)
2008-05-18 19:31 UTC, Mark Nauwelaerts
committed Details | Review
avimuxer combination test python script (1.15 KB, text/plain)
2008-05-21 13:15 UTC, Stefan Sauer (gstreamer, gtkdoc dev)
  Details

Description Ruud Schramp 2008-01-23 09:56:44 UTC
Please describe the problem:
avimux doesn;t correctly mux audio and video

Steps to reproduce:
ggst-launch-0.10 videotestsrc num-buffers=250 ! 'video/x-raw-yuv,format=(fourcc)I420,width=320,height=240,framerate=(fraction)30/1' ! timeoverlay ! queue ! mux. audiotestsrc num-buffers=440 ! audioconvert ! 'audio/x-raw-int,rate=44100,channels=2' ! queue ! mux. avimux name=mux ! filesink location=test.avi

ffplay test.avi



Actual results:
Shows that the video is played at half its rate and the audio start cracking (buffer underruns?). Windows media player the audio is good but drifts apart from video at a factor 2 (only visible with real content).

Expected results:
Video should display in image timestamps that folow the normal second clock

Does this happen every time?
yes

Other information:
When ONLY video is muxed it is ok.

When playing the file with gstreamer it is ok.
Comment 1 Ruud Schramp 2008-01-29 10:28:27 UTC
Retested with HEAD of CVS. Still has the same problem
Comment 2 Mark Nauwelaerts 2008-03-03 17:01:04 UTC
Created attachment 106492 [details] [review]
Patch to fix (pcm) audio stream header

* Fix audio stream header rate field in case of raw audio.

With this patch, the result of the pipeline given above plays well on gstreamer, ffplay, mplayer, xine (and I'll just assume WMP, which I can't test ;) )
Comment 3 Ruud Schramp 2008-03-04 12:39:20 UTC
Works relatively well. 

Audio and video are now in sync but after several seconds audio still start giving ticks on my system. On Media Player stream works fine.

This patch is definitely an improvement over the previous situation.

I would like to get this patch into the main code, but keep the bug open for further improvement.

Comment 4 Mark Nauwelaerts 2008-05-13 21:14:21 UTC
(In reply to comment #3)

I have had another look at this:
- according to MS AVI specs (which are pretty clear for PCM at least), all stream header fields etc are as they should be (when patched at least).
And it would seem that WMP concurs (mentioned above).
- still plays OK for me in various cases as indicated above, except that in some cases only ffplay is indeed a bit ticky (which I pretty much attribute to ffplay)

So, is there still a problem ? with sync in particular ? for what players ?
Is only ffplay generating ticks ? for an avimux generated AVI ? 
(as opposed to other files) ?
Comment 5 Ruud Schramp 2008-05-14 06:55:06 UTC
Hi Mark,

If you say that the headers are according to standard, then I am happy to close the bug.... but the ticking still bothers me a bit.

As I am not really an avimux expert... could it have something to do with interleaving of audio and video?? Just guessing here. I noticed (remembering by heart) that the ticking only starts after a few 10's of seconds which may be symptomatic for a skew in both streams that increases over time and only becomes a problem when it has built over a certain buffer size.

Something like this wouldn't show up in the headers would it?

Best  regards,

Ruud
Comment 6 Mark Nauwelaerts 2008-05-16 20:25:24 UTC
A player could get into (undefined) trouble if video and audio data would be badly interleaved, which is evidently not defined or determined by the header itself.  However, interleaving is also just fine in avimux output.

More testing (including longer samples) shows only ffplay sometimes glitches (ticks) minutely on the (not-so-realistic) audiotestsrc generated audio.

As such, unless other (overwhelming) input/results, I'll be closing this soon.
Comment 7 Ruud Schramp 2008-05-16 21:21:42 UTC
OK, thanks for the feedback
Comment 8 Mark Nauwelaerts 2008-05-18 19:31:37 UTC
Created attachment 111113 [details] [review]
Patch to fix (pcm) audio stream header

2008-05-18  Mark Nauwelaerts  <mnauw@users.sf.net>

	* gst/avi/gstavimux.c: (gst_avi_mux_audsink_set_caps):
	Set proper rate in avi stream header for PCM audio, and also do some
	more sanity checks on caps in this case.  Fixes #511489.
Comment 9 Stefan Sauer (gstreamer, gtkdoc dev) 2008-05-21 13:15:12 UTC
Created attachment 111278 [details]
avimuxer combination test python script

small testscript to try various combinations. Useful when enabling more.
On the audio side alaw/mulaw could be added to avimux.
Comment 10 Stefan Sauer (gstreamer, gtkdoc dev) 2008-05-21 15:26:01 UTC
Just added alaw/mulaw too, so ignore it