Commit a6beda18 authored by Eric Petit's avatar Eric Petit

* added audio bitrate configuration

 * if the frequency isn't set, we keep the current one
parent c517f665
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* raw2ts.cpp: raw -> ES ffmpeg encoder -> TS * raw2ts.cpp: raw -> ES ffmpeg encoder -> TS
*------------------------------------------------------------------------------- *-------------------------------------------------------------------------------
* (c)1999-2001 VideoLAN * (c)1999-2001 VideoLAN
* $Id: raw2ts.cpp,v 1.12 2003/02/24 20:13:31 titer Exp $ * $Id: raw2ts.cpp,v 1.13 2003/02/24 20:59:22 titer Exp $
* *
* Authors: Tristan Leteurtre <tooney@videolan.org> * Authors: Tristan Leteurtre <tooney@videolan.org>
* (inspirated from Fabrice Bellard...) * (inspirated from Fabrice Bellard...)
...@@ -198,8 +198,9 @@ void C_Raw2TsMpegConverter::DoWork() ...@@ -198,8 +198,9 @@ void C_Raw2TsMpegConverter::DoWork()
// launch the sound thread // launch the sound thread
C_AudioThread * pAudioThread = new C_AudioThread( this, m_pReader, C_AudioThread * pAudioThread = new C_AudioThread( this, m_pReader,
m_pTsProvider, m_pTsProvider,
m_pHandler ); m_pHandler,
m_pBroadcast );
pAudioThread->Create(); pAudioThread->Create();
C_PesPacket * PesPacket = new C_PesPacket(); C_PesPacket * PesPacket = new C_PesPacket();
...@@ -355,12 +356,14 @@ u64 C_Raw2TsMpegConverter::GetTime(void) ...@@ -355,12 +356,14 @@ u64 C_Raw2TsMpegConverter::GetTime(void)
C_AudioThread::C_AudioThread( C_Raw2TsMpegConverter *pConverter, C_AudioThread::C_AudioThread( C_Raw2TsMpegConverter *pConverter,
C_MpegReader * pReader, C_MpegReader * pReader,
C_NetList * pTsProvider, C_NetList * pTsProvider,
I_TsPacketHandler * pHandler ) : C_Thread() I_TsPacketHandler * pHandler,
C_Broadcast * pBroadcast ) : C_Thread()
{ {
m_pConverter = pConverter; m_pConverter = pConverter;
m_pReader = pReader; m_pReader = pReader;
m_pTsProvider = pTsProvider; m_pTsProvider = pTsProvider;
m_pHandler = pHandler; m_pHandler = pHandler;
m_pBroadcast = pBroadcast;
} }
void C_AudioThread::InitWork() void C_AudioThread::InitWork()
...@@ -376,13 +379,21 @@ void C_AudioThread::InitWork() ...@@ -376,13 +379,21 @@ void C_AudioThread::InitWork()
throw E_Exception(GEN_ERR, "Cannot find encoder MP2 Audio"); throw E_Exception(GEN_ERR, "Cannot find encoder MP2 Audio");
} }
// set parameters // set ffmpeg parameters
m_AudioCodecContext = avcodec_alloc_context(); m_AudioCodecContext = avcodec_alloc_context();
m_AudioCodecContext->bit_rate = 64000;
m_AudioCodecContext->sample_rate = 44100; m_AudioCodecContext->sample_rate = 44100;
m_AudioCodecContext->channels = 2; m_AudioCodecContext->channels = 2;
m_AudioCodecContext->bit_rate =
m_pBroadcast->GetOption("v4l_audiobitrate").ToInt() * 1000;
if( m_AudioCodecContext->bit_rate < 32 )
{
// ffmpeg does not like bitrate under 32000, back to default
m_AudioCodecContext->bit_rate = 64;
}
// open it // open it
fprintf( stderr, "bitrate: %d\n", m_AudioCodecContext->bit_rate );
if( avcodec_open( m_AudioCodecContext, m_AudioCodec ) < 0 ) if( avcodec_open( m_AudioCodecContext, m_AudioCodec ) < 0 )
{ {
throw E_Exception(GEN_ERR, "Cannot init audio encoder"); throw E_Exception(GEN_ERR, "Cannot init audio encoder");
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* raw2ts.h: raw -> ES ffmpeg encoder -> TS * raw2ts.h: raw -> ES ffmpeg encoder -> TS
*------------------------------------------------------------------------------- *-------------------------------------------------------------------------------
* (c)1999-2001 VideoLAN * (c)1999-2001 VideoLAN
* $Id: raw2ts.h,v 1.6 2003/02/22 02:38:56 tooney Exp $ * $Id: raw2ts.h,v 1.7 2003/02/24 20:59:22 titer Exp $
* *
* Authors: Tristan Leteurtre <tooney@videolan.org> * Authors: Tristan Leteurtre <tooney@videolan.org>
* *
...@@ -83,7 +83,8 @@ class C_AudioThread : public C_Thread ...@@ -83,7 +83,8 @@ class C_AudioThread : public C_Thread
public: public:
C_AudioThread( C_Raw2TsMpegConverter * pConverter, C_AudioThread( C_Raw2TsMpegConverter * pConverter,
C_MpegReader * pReader, C_NetList * pTsProvider, C_MpegReader * pReader, C_NetList * pTsProvider,
I_TsPacketHandler * pHandler ); I_TsPacketHandler * pHandler,
C_Broadcast * m_pBroadcast );
protected: protected:
virtual void InitWork(); virtual void InitWork();
...@@ -97,6 +98,7 @@ class C_AudioThread : public C_Thread ...@@ -97,6 +98,7 @@ class C_AudioThread : public C_Thread
C_MpegReader * m_pReader; C_MpegReader * m_pReader;
C_NetList * m_pTsProvider; C_NetList * m_pTsProvider;
I_TsPacketHandler * m_pHandler; I_TsPacketHandler * m_pHandler;
C_Broadcast * m_pBroadcast;
bool m_bStop; bool m_bStop;
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* v4linput.cpp: Veading from a v4l device (WebCam, tv tuner) * v4linput.cpp: Veading from a v4l device (WebCam, tv tuner)
*------------------------------------------------------------------------------- *-------------------------------------------------------------------------------
* (c)1999-2001 VideoLAN * (c)1999-2001 VideoLAN
* $Id: v4linput.cpp,v 1.8 2003/02/24 20:13:31 titer Exp $ * $Id: v4linput.cpp,v 1.9 2003/02/24 20:59:22 titer Exp $
* *
* Authors: Tristan Leteurtre <tooney@videolan.org> * Authors: Tristan Leteurtre <tooney@videolan.org>
* *
...@@ -164,11 +164,15 @@ void C_v4lInput::OnStartStreaming(C_Broadcast* pBroadcast) ...@@ -164,11 +164,15 @@ void C_v4lInput::OnStartStreaming(C_Broadcast* pBroadcast)
C_String strV4LSize = pApp->GetSetting(GetName()+".Size", ""); C_String strV4LSize = pApp->GetSetting(GetName()+".Size", "");
pBroadcast->SetOption("v4l_size", strV4LSize); pBroadcast->SetOption("v4l_size", strV4LSize);
C_String strV4LNorm = pApp->GetSetting(GetName()+".Norm", "0");
pBroadcast->SetOption("v4l_norm", strV4LNorm);
C_String strV4LBitrate = pApp->GetSetting(GetName()+".Bitrate", "1000"); C_String strV4LBitrate = pApp->GetSetting(GetName()+".Bitrate", "1000");
pBroadcast->SetOption("v4l_bitrate", strV4LBitrate); pBroadcast->SetOption("v4l_bitrate", strV4LBitrate);
C_String strV4LNorm = pApp->GetSetting(GetName()+".Norm", "0"); C_String strV4LAudioBitrate =
pBroadcast->SetOption("v4l_norm", strV4LNorm); pApp->GetSetting(GetName()+".AudioBitrate", "64");
pBroadcast->SetOption("v4l_audiobitrate", strV4LAudioBitrate);
C_String strV4LFrequency = pApp->GetSetting(GetName()+".Frequency", "-1"); C_String strV4LFrequency = pApp->GetSetting(GetName()+".Frequency", "-1");
pBroadcast->SetOption("v4l_frequency", strV4LFrequency); pBroadcast->SetOption("v4l_frequency", strV4LFrequency);
......
...@@ -110,8 +110,9 @@ END ...@@ -110,8 +110,9 @@ END
# Video For Linux (V4L) configuration # Video For Linux (V4L) configuration
BEGIN "webcam" BEGIN "webcam"
# --- Example: # --- Example:
Device = "/dev/video" # Video4linux device (default is /dev/video) Device = "/dev/video" # Video4linux device (default is /dev/video)
AudioDevice = "/dev/dsp" # Sound device (try /dev/dsp<X> or /dev/audio<X>) AudioDevice = "/dev/dsp" # Sound device (try /dev/dsp<X>
# or /dev/audio<X>)
Channel = "0" # Channel Source: Webcam often 0 Channel = "0" # Channel Source: Webcam often 0
# For TV Card, may be Tuner(0), Composite(1), # For TV Card, may be Tuner(0), Composite(1),
...@@ -127,6 +128,7 @@ Size = "" # Size possibilities ...@@ -127,6 +128,7 @@ Size = "" # Size possibilities
#Size = "sif" #Size = "sif"
Bitrate = "500" # Bitrate (approx.) in kbps Bitrate = "500" # Bitrate (approx.) in kbps
AudioBitrate = "64" # Audio bitrate in kbps
END END
...@@ -134,13 +136,14 @@ END ...@@ -134,13 +136,14 @@ END
BEGIN "tuner" BEGIN "tuner"
# --- Example: # --- Example:
Device = "/dev/video" # Video4linux device (default is /dev/video) Device = "/dev/video" # Video4linux device (default is /dev/video)
AudioDevice = "/dev/dsp" # Sound device (try /dev/dsp<X> or /dev/audio<X>) AudioDevice = "/dev/dsp" # Sound device (try /dev/dsp<X>
# or /dev/audio<X>)
Channel = "0" # Channel Source: Webcam often 0 Channel = "0" # Channel Source: Webcam often 0
# For TV Card, may be Tuner(0), Composite(1), # For TV Card, may be Tuner(0), Composite(1),
# Svideo(2) # Svideo(2)
Norm = "0" # PAL=0, NTSC=1, SECAM=2 Norm = "0" # PAL=0, NTSC=1, SECAM=2
Frequency = "7668" # Frequency * 16 # Frequency = "7668" # Frequency (Mhz) * 16
Size = "subQCIF" # Size possibilities Size = "subQCIF" # Size possibilities
# - empty string : default size # - empty string : default size
...@@ -150,6 +153,7 @@ Size = "subQCIF" # Size possibilities ...@@ -150,6 +153,7 @@ Size = "subQCIF" # Size possibilities
#Size = "320x200" #Size = "320x200"
Bitrate = "500" # Bitrate (approx.) in kbps Bitrate = "500" # Bitrate (approx.) in kbps
AudioBitrate = "64" # Audio bitrate in kbps
END END
# Channel (outputs) declaration # Channel (outputs) declaration
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment