From bfca90554d5bc27c56a9d410120adaad45ccbb1b Mon Sep 17 00:00:00 2001 From: fred Date: Mon, 28 Mar 2011 11:38:27 +0200 Subject: [PATCH] Modified encoder sample rate to sync sound with video - in QJackClient, modified sample rate parameter when creating the AudioCollector object. This modify the vorbis speed when streaming. Commented out ::chgSampleRate() since it is not used - in init_info(), use again the skeleton. - VideoEncoder::thread_loop(), shaws the shout delay for testing. --- qt/TODO | 11 +++++------ qt/qJackClient.cpp | 18 ++++++++++-------- qt/qJackClient.h | 2 +- src/theorautils.cpp | 3 +-- src/video_encoder.cpp | 3 +++ 5 files changed, 20 insertions(+), 17 deletions(-) diff --git a/qt/TODO b/qt/TODO index d2053678..ecdc4547 100644 --- a/qt/TODO +++ b/qt/TODO @@ -7,15 +7,14 @@ //add a x:x ratio button, resizing to the closest width and lenght to obtain this ratio //create a console for messages comming from func() warning() notice() act(). see Logger class //see to integrate ogg skeleton config on the graphic interface -//there is the amount of delay between audio and video if you open a video before creating +//there is a delay between audio and video if you open a video before creating the QJackClient of the time you waited to open the QJackClient .... see if a fix possible or needed. //Jack server sample rate and buffer size is hard coded for the moment, provide a way to put it manualy //try to fix sound problem issue when opening several VideoLayer with audio -//add the capability to have a config file..... important :) -//if resizing the wiewport when the layer is bigger, you need to just touch the layer size to display it correctly +//add the capability to keep the actual config in a file..... important :) +//if resizing the wiewport when the layer is bigger, you just need to touch the layer size to display it correctly //why qfreej doesn't install with the AUR packages //see if possible to manage an audio layer //be able to change v4l2 resolution from the graphic interface -//see why sound delay increases on video during streaming -//see why sound stops after a whyle when streaming .... have to deconnect jack ports and connect back -//need do adjust stream bitrate value. +//see why sound delay increases on video during streaming (sound slower than video ... or video too fast) +//see why sound coming from the jack input stops after a whyle when streaming .... have to deconnect jack ports and reconnect diff --git a/qt/qJackClient.cpp b/qt/qJackClient.cpp index 7078e6ef..6a2f9a30 100644 --- a/qt/qJackClient.cpp +++ b/qt/qJackClient.cpp @@ -49,7 +49,8 @@ bool QJackClient::init() return (false); } - m_audio = new AudioCollector(1024, 48000, m_Jack); + m_audio = new AudioCollector(1024, 48192, m_Jack); //48240 seems to be a good value in my config +// m_audio = new AudioCollector(1024, 48000, m_Jack); m_Jack->isEncoded(false); m_Enc = m_Qfreej->getEnc(); @@ -71,14 +72,15 @@ bool QJackClient::init() m_Coef->setEnabled(false); layoutG->addWidget(m_Coef, 2, 0, 1, 2); m_Coef->setToolTip("sets the Mix coefficient between Jack Input and Video Layer output"); - + + //not used m_SampleRate = new QLineEdit; - connect (m_SampleRate, SIGNAL(returnPressed()), this, SLOT(chgSampleRate())); +// connect (m_SampleRate, SIGNAL(returnPressed()), this, SLOT(chgSampleRate())); m_SampleRate->setValidator(new QIntValidator(m_SampleRate)); m_SampleRate->setText("48000"); //default Jackd sample rate m_SampleRate->setEnabled(false); // m_Jack->m_SampleRate = 48000; //not necessary as it is donne in AudioCollector constructor - + // QLabel *vSampleRate = new QLabel("J SampleRate :"); layoutG->addWidget(vSampleRate, 3, 0); layoutG->addWidget(m_SampleRate, 3, 1); @@ -166,10 +168,10 @@ void QJackClient::addInput() } } -void QJackClient::chgSampleRate() -{ - m_Jack->m_SampleRate = m_SampleRate->text().toInt(); -} +// void QJackClient::chgSampleRate() +// { +// m_Jack->m_SampleRate = m_SampleRate->text().toInt(); +// } int QJackClient::getSampleRate() { diff --git a/qt/qJackClient.h b/qt/qJackClient.h index 4f005a24..91804453 100644 --- a/qt/qJackClient.h +++ b/qt/qJackClient.h @@ -25,7 +25,7 @@ public: public slots: void addInput(); void addOutput(); - void chgSampleRate(); +// void chgSampleRate(); void chgSamples(); void changeMixCoef(int); diff --git a/src/theorautils.cpp b/src/theorautils.cpp index dec90773..a27e6c4c 100644 --- a/src/theorautils.cpp +++ b/src/theorautils.cpp @@ -72,7 +72,7 @@ static double rint(double x) void init_info(oggmux_info *info) { info->audio_only = 0; - info->with_skeleton = 0; /* skeleton is enabled by default */ + info->with_skeleton = 1; /* skeleton is enabled by default */ info->frontend = NULL; /*frontend mode*/ info->videotime = 0; info->audiotime = 0; @@ -572,7 +572,6 @@ void oggmux_init (oggmux_info *info){ if (info->with_skeleton) { add_fisbone_packet (info); while (1) { - std::cerr << "------- with_skeleton !!!!" << std::endl; int result = ogg_stream_flush (&info->so, &og); //3 with_skeleton if (result < 0) { /* can't get here */ diff --git a/src/video_encoder.cpp b/src/video_encoder.cpp index 21b5e517..c3ac4329 100644 --- a/src/video_encoder.cpp +++ b/src/video_encoder.cpp @@ -260,6 +260,9 @@ void VideoEncoder::thread_loop() { fwrite(encbuf, 1, encnum, filedump_fd); if(write_to_stream) { + int wait_ms; + wait_ms = shout_delay(ice); + std::cerr << "---- shout delay :" << wait_ms << std::endl; // shout_sync(ice); //no sound when commented out !! if( shout_send(ice, (const unsigned char*)encbuf, encnum) != SHOUTERR_SUCCESS) {