dinhminhquoi / webm

Automatically exported from code.google.com/p/webm
0 stars 0 forks source link

Cannot encode VP8 in VLC if machine uptime is too high #701

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
Hi,

The summary is not a joke. :-) Allow me to explain:

VLC uses the value of CLOCK_MONOTONIC in microseconds as pts value, and sends 
this to avcodec, which sends it to libvpx. This yields, for my server, which 
has about 40 days of uptime, a pts of something like 3,689,348,876,525 (real 
example value from my testing), which needs 42 bits to store.

Now, vp8/vp8_cx_iface.c has the following code:

        dst_time_stamp    = pts * 10000000 * ctx->cfg.g_timebase.num / ctx->cfg.g_timebase.den;
        dst_end_time_stamp = (pts + duration) * 10000000 * ctx->cfg.g_timebase.num / ctx->cfg.g_timebase.den;

pts here is an int64. At the first multiplication with 10000000 (fits in 24 
bits), the value becomes 66 bits, and wraps around to something negative. Since 
there's no wrap-back later, libvpx ends up returning a negative pts to VLC, 
which gets endlessly confused, and fails to mux the video correctly with the 
audio.

Of course, if I happened to use Windows, I'd probably boot long before 40 days 
and never see this bug, but such is not life. :-)

I don't know what the right fix is; assuming you don't want to simulate int128, 
it would depend on the exact semantics needed by the rest of the code. But it 
really should be fixed, as allowing an int64 as pts really means you should 
handle the full int64 range.

Original issue reported on code.google.com by sgunder...@bigfoot.com on 31 Jan 2014 at 12:17

GoogleCodeExporter commented 9 years ago
I tried this on Windows 8 (my machine had 39 days and 16 hours of uptime) and 
indeed something strange happens.

VLC converts the video without complaining, but the resulting Webm file became 
1 hour 45min long when it was originally 1 minute long. The audio stream is 
present but no sound came from the speakers and the player cannot seek any 
position in the video.

Original comment by jbv...@gmail.com on 4 Feb 2014 at 11:08

GoogleCodeExporter commented 9 years ago

Original comment by ya...@google.com on 6 Feb 2014 at 11:21