mirror of
https://github.com/mpromonet/v4l2rtspserver
synced 2024-11-11 19:10:40 +00:00
allow to give a list of format to try
This commit is contained in:
parent
1abf8b31a3
commit
164c888feb
14
src/main.cpp
14
src/main.cpp
@ -371,7 +371,7 @@ int main(int argc, char** argv)
|
|||||||
{
|
{
|
||||||
// default parameters
|
// default parameters
|
||||||
const char *dev_name = "/dev/video0";
|
const char *dev_name = "/dev/video0";
|
||||||
int format = V4L2_PIX_FMT_H264;
|
std::list<unsigned int> formatList;
|
||||||
int width = 640;
|
int width = 640;
|
||||||
int height = 480;
|
int height = 480;
|
||||||
int queueSize = 10;
|
int queueSize = 10;
|
||||||
@ -396,6 +396,7 @@ int main(int argc, char** argv)
|
|||||||
std::list<std::string> userPasswordList;
|
std::list<std::string> userPasswordList;
|
||||||
int audioFreq = 44100;
|
int audioFreq = 44100;
|
||||||
int audioNbChannels = 2;
|
int audioNbChannels = 2;
|
||||||
|
unsigned int format = ~0;
|
||||||
#ifdef HAVE_ALSA
|
#ifdef HAVE_ALSA
|
||||||
snd_pcm_format_t audioFmt = SND_PCM_FORMAT_S16_BE;
|
snd_pcm_format_t audioFmt = SND_PCM_FORMAT_S16_BE;
|
||||||
#endif
|
#endif
|
||||||
@ -434,7 +435,7 @@ int main(int argc, char** argv)
|
|||||||
case 'r': ioTypeIn = V4l2Access::IOTYPE_READWRITE; break;
|
case 'r': ioTypeIn = V4l2Access::IOTYPE_READWRITE; break;
|
||||||
case 'w': ioTypeOut = V4l2Access::IOTYPE_READWRITE; break;
|
case 'w': ioTypeOut = V4l2Access::IOTYPE_READWRITE; break;
|
||||||
case 's': useThread = false; break;
|
case 's': useThread = false; break;
|
||||||
case 'f': format = decodeVideoFormat(optarg); break;
|
case 'f': format = decodeVideoFormat(optarg); if (format) {formatList.push_back(format);}; break;
|
||||||
case 'F': fps = atoi(optarg); break;
|
case 'F': fps = atoi(optarg); break;
|
||||||
case 'W': width = atoi(optarg); break;
|
case 'W': width = atoi(optarg); break;
|
||||||
case 'H': height = atoi(optarg); break;
|
case 'H': height = atoi(optarg); break;
|
||||||
@ -510,6 +511,13 @@ int main(int argc, char** argv)
|
|||||||
devList.push_back(dev_name);
|
devList.push_back(dev_name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// default format tries
|
||||||
|
if ((formatList.empty()) && (format!=0)) {
|
||||||
|
std::cout << "use default format H264/MJPEG" << std::endl;
|
||||||
|
formatList.push_back(V4L2_PIX_FMT_H264);
|
||||||
|
formatList.push_back(V4L2_PIX_FMT_MJPEG);
|
||||||
|
}
|
||||||
|
|
||||||
// init logger
|
// init logger
|
||||||
initLogger(verbose);
|
initLogger(verbose);
|
||||||
|
|
||||||
@ -562,7 +570,7 @@ int main(int argc, char** argv)
|
|||||||
// Init video capture
|
// Init video capture
|
||||||
LOG(NOTICE) << "Create V4L2 Source..." << videoDev;
|
LOG(NOTICE) << "Create V4L2 Source..." << videoDev;
|
||||||
|
|
||||||
V4L2DeviceParameters param(videoDev.c_str(), format, width, height, fps, verbose);
|
V4L2DeviceParameters param(videoDev.c_str(), formatList, width, height, fps, verbose);
|
||||||
V4l2Capture* videoCapture = V4l2Capture::create(param, ioTypeIn);
|
V4l2Capture* videoCapture = V4l2Capture::create(param, ioTypeIn);
|
||||||
if (videoCapture)
|
if (videoCapture)
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user