summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorfred <fred@home.lan>2011-06-15 20:35:19 (GMT)
committer fred <fred@home.lan>2011-06-16 10:30:43 (GMT)
commitc5f0bd9cd308c78d856ea46648f5fea1bede5e53 (patch)
tree0fa77561f45134b5a912afb7c0cc4fcb65d1aa8f
parentadd8360d9e3846110cfa7ecab34426b4efaef223 (diff)
a Vorbis Theora sync bug fixed when dumping in a file
- in theorautils add_fishead_packet, added time and modified the skeleton version from 3.0 to 4.0 ..... still in progress. In oggmux_flish(), only calculate the ratio for audio re-sampling if the videotime as changed .... avoids a sync bug
-rw-r--r--src/include/theorautils.h2
-rw-r--r--src/theorautils.cpp23
2 files changed, 18 insertions, 7 deletions
diff --git a/src/include/theorautils.h b/src/include/theorautils.h
index 4cc1a65..b2dd0aa 100644
--- a/src/include/theorautils.h
+++ b/src/include/theorautils.h
@@ -38,7 +38,7 @@
-#define SKELETON_VERSION_MAJOR 3
+#define SKELETON_VERSION_MAJOR 4
#define SKELETON_VERSION_MINOR 0
#define FISHEAD_IDENTIFIER "fishead\0"
#define FISBONE_IDENTIFIER "fisbone\0"
diff --git a/src/theorautils.cpp b/src/theorautils.cpp
index c3dc743..bde935d 100644
--- a/src/theorautils.cpp
+++ b/src/theorautils.cpp
@@ -164,12 +164,21 @@ void add_fishead_packet (oggmux_info *info) {
write16le(op.packet+8, SKELETON_VERSION_MAJOR); /* version major */
write16le(op.packet+10, SKELETON_VERSION_MINOR); /* version minor */
write64le(op.packet+12, (ogg_int64_t)0); /* presentationtime numerator */
- write64le(op.packet+20, (ogg_int64_t)1000); /* presentationtime denominator */
+ write64le(op.packet+20, (ogg_int64_t)1000); /* presentationtime denominator (means ms)*/
write64le(op.packet+28, (ogg_int64_t)0); /* basetime numerator */
- write64le(op.packet+36, (ogg_int64_t)1000); /* basetime denominator */
+ write64le(op.packet+36, (ogg_int64_t)1000); /* basetime denominator (means ms)*/
/* both the numerator are zero hence handled by the memset */
- write32le(op.packet+44, 0); /* UTC time, set to zero for now */
+// write32le(op.packet+44, 0); /* UTC time, set to zero for now */
+ char timeStart[21];
+ time_t result;
+ struct tm *tim;
+ result = time(NULL);
+ tim = localtime(&result);
+
+ sprintf ((char *)op.packet+44, "%04d%02d%02dT%02d%02d%02d", tim->tm_year + 1900, tim->tm_mon + 1, tim->tm_mday \
+ , tim->tm_hour, tim->tm_min, tim->tm_sec);
+
op.b_o_s = 1; /* its the first packet of the stream */
op.e_o_s = 0; /* its not the last packet of the stream */
op.bytes = 64; /* length of the packet in bytes */
@@ -194,7 +203,7 @@ void add_fisbone_packet (oggmux_info *info) {
memcpy (op.packet, FISBONE_IDENTIFIER, 8); /* identifier */
write32le(op.packet+8, FISBONE_MESSAGE_HEADER_OFFSET); /* offset of the message header fields */
write32le(op.packet+12, info->to.serialno); /* serialno of the theora stream */
- write32le(op.packet+16, 3); /* number of header packets */
+ write32le(op.packet+16, 3); /* number of header packets */ //if theora + vorbis ?
/* granulerate, temporal resolution of the bitstream in samples/microsecond */
write64le(op.packet+20, info->ti.fps_numerator); /* granulrate numerator */
write64le(op.packet+28, info->ti.fps_denominator); /* granulrate denominator */
@@ -282,7 +291,7 @@ void *timer_start(void)
int sampleError;
SRC_STATE *src_state;
SRC_DATA *src_data;
-double ratio, averageR;
+double ratio, averageR, oldVideoTime;
double *sampleOut, samplesA;
void oggmux_init (oggmux_info *info){
@@ -295,6 +304,7 @@ void oggmux_init (oggmux_info *info){
averageR = 1.0;
samplesA = 1.0;
sampleOut = NULL;
+ oldVideoTime = 0.0;
/* yayness. Set up Ogg output stream */
srand (time (NULL));
@@ -1011,8 +1021,9 @@ void oggmux_flush (oggmux_info *info, int e_o_s)
ogg_page_granulepos(&og));
if (info->audiotime == -1)
std::cerr << "the given vorbis granulepos is invalid" << std::endl << std::flush;
- else {
+ else if (info->videotime > oldVideoTime){
samplesA++;
+ oldVideoTime = info->videotime;
ratio = ((info->videotime - info->audiotime) / 60.0 )+ averageR;
averageR = (ratio + (averageR * (samplesA - 1))) / samplesA;
// std::cerr << "ratio :" << ratio << " averageR :" << averageR;