-added aud_codec to the conf file so audio codec is now a
 configurable option.

-renamed stream_codec to vid_codec on the conf file to contrast
 aud_codec.

-rtsp streams now use udp instead of tcp.

-updated README with conf file changes.
This commit is contained in:
zii 2024-04-03 17:28:53 -04:00
parent 330393667e
commit c5393484c2
4 changed files with 41 additions and 32 deletions

View File

@ -78,14 +78,20 @@ img_comp_out = stderr
# use to output the comparison score. this can only be stderr or stdout, # use to output the comparison score. this can only be stderr or stdout,
# any other stream name is considered invalid. # any other stream name is considered invalid.
# #
stream_codec = copy vid_codec = copy
# this is the encoding codec to use when recording footage from the camera. # this is the encoding codec to use when recording footage from the camera.
# the list of supported codecs entirely depend on the hosts' ffmpeg # the list of supported codecs entirely depend on the hosts' ffmpeg
# installation. run 'ffmpeg -codecs' to determine this list. if not # installation. run 'ffmpeg -codecs' to determine this list. if not
# defined, 'copy' will be used as in it will just copy the codec format # defined, 'copy' will be used as in it will just copy the codec format
# from camera itself. # from the camera itself.
# #
stream_ext = .avi aud_codec = copy
# this is the audio encoding codec to use when recording from the camera.
# the list of supported audio codes can be determined by running 'ffmpeg
# -codecs' on the host machine. if not defined, 'copy' will be used as in
# it will directly copy the audio stream from the camera if present.
#
stream_ext = .mkv
# this is the file extension that will be used to when recording footage # this is the file extension that will be used to when recording footage
# from the camera in buffer_path. ffmpeg will also use this to determine # from the camera in buffer_path. ffmpeg will also use this to determine
# what format container to use for the video clips. # what format container to use for the video clips.
@ -94,7 +100,7 @@ thumbnail_ext = .jpg
# this the image format that will be used when creating the thumbnails # this the image format that will be used when creating the thumbnails
# for the videos clips recorded to rec_path. # for the videos clips recorded to rec_path.
# #
rec_ext = .avi rec_ext = .mkv
# this the the file extension that will be used when storing motion footage # this the the file extension that will be used when storing motion footage
# to rec_path. ffmpeg will also use this to determine what format container # to rec_path. ffmpeg will also use this to determine what format container
# to use for the video clips. # to use for the video clips.
@ -121,13 +127,12 @@ post_cmd = move_the_ptz_camera.py
# #
rec_fps = 30 rec_fps = 30
# this sets the recording frames per second for the footage recorded # this sets the recording frames per second for the footage recorded
# from the camera. this has no affect if using 'copy' as the # from the camera. this has no affect if using 'copy' as the vid_codec.
# stream_codec.
# #
rec_scale = 1280:720 rec_scale = 1280:720
# this sets the pixel scale of the recorded footage from the camera. it # this sets the pixel scale of the recorded footage from the camera. it
# uses width, height numeric strings seperated by a colon, eg W:H. this # uses width, height numeric strings seperated by a colon, eg W:H. this
# has no affect of using 'copy' as the stream_codec. # has no affect of using 'copy' as the vid_codec.
# #
img_scale = 320:240 img_scale = 320:240
# this sets the pixel size of the thumbnails for recorded stored in # this sets the pixel size of the thumbnails for recorded stored in

View File

@ -225,9 +225,10 @@ bool rdConf(const QString &filePath, shared_t *share)
share->conf = filePath; share->conf = filePath;
share->outputType = "stderr"; share->outputType = "stderr";
share->compCmd = "magick compare -metric FUZZ " + QString(PREV_IMG) + " " + QString(NEXT_IMG) + " /dev/null"; share->compCmd = "magick compare -metric FUZZ " + QString(PREV_IMG) + " " + QString(NEXT_IMG) + " /dev/null";
share->streamCodec = "copy"; share->vidCodec = "copy";
share->streamExt = ".avi"; share->audCodec = "copy";
share->recExt = ".avi"; share->streamExt = ".mkv";
share->recExt = ".mkv";
share->thumbExt = ".jpg"; share->thumbExt = ".jpg";
share->recFps = 30; share->recFps = 30;
share->liveSecs = 80; share->liveSecs = 80;
@ -254,7 +255,8 @@ bool rdConf(const QString &filePath, shared_t *share)
rdLine("max_events = ", line, &share->maxEvents); rdLine("max_events = ", line, &share->maxEvents);
rdLine("img_comp_out = ", line, &share->outputType); rdLine("img_comp_out = ", line, &share->outputType);
rdLine("img_comp_cmd = ", line, &share->compCmd); rdLine("img_comp_cmd = ", line, &share->compCmd);
rdLine("stream_codec = ", line, &share->streamCodec); rdLine("vid_codec = ", line, &share->vidCodec);
rdLine("aud_codec = ", line, &share->audCodec);
rdLine("stream_ext = ", line, &share->streamExt); rdLine("stream_ext = ", line, &share->streamExt);
rdLine("rec_ext = ", line, &share->recExt); rdLine("rec_ext = ", line, &share->recExt);
rdLine("thumbnail_ext = ", line, &share->thumbExt); rdLine("thumbnail_ext = ", line, &share->thumbExt);

View File

@ -30,7 +30,7 @@
using namespace std; using namespace std;
#define APP_VER "3.4.t2" #define APP_VER "3.4.t3"
#define APP_NAME "Motion Watch" #define APP_NAME "Motion Watch"
#define APP_BIN "mow" #define APP_BIN "mow"
#define DATETIME_FMT "yyyyMMddhhmmss" #define DATETIME_FMT "yyyyMMddhhmmss"
@ -65,7 +65,8 @@ struct shared_t
QString recPath; QString recPath;
QString outputType; QString outputType;
QString compCmd; QString compCmd;
QString streamCodec; QString vidCodec;
QString audCodec;
QString streamExt; QString streamExt;
QString recExt; QString recExt;
QString thumbExt; QString thumbExt;

View File

@ -46,7 +46,7 @@ int loadService(const QString &desc, const QString &user, const QString &servNam
if (servName.contains("vid_loop")) if (servName.contains("vid_loop"))
{ {
file.write("RuntimeMaxSec=62\n"); file.write("RuntimeMaxSec=61\n");
} }
file.write("ExecStart=/usr/bin/env " + servName.toUtf8() + "\n\n"); file.write("ExecStart=/usr/bin/env " + servName.toUtf8() + "\n\n");
@ -116,15 +116,16 @@ QString camCmdFromConf(shared_t *conf, CmdExeType type)
if (conf->recordUri.contains("rtsp")) if (conf->recordUri.contains("rtsp"))
{ {
ret += "-rtsp_transport tcp "; ret += "-rtsp_transport udp ";
} }
if (conf->streamCodec != "copy") if (conf->vidCodec != "copy")
{ {
ret += "-vf fps=" + QString::number(conf->recFps) + ",scale=" + conf->recScale + " "; ret += "-vf fps=" + QString::number(conf->recFps) + ",scale=" + conf->recScale + " ";
} }
ret += "-vcodec " + conf->streamCodec + " "; ret += "-vcodec " + conf->vidCodec + " ";
ret += "-acodec " + conf->audCodec + " ";
ret += "-reset_timestamps 1 -sc_threshold 0 -g 2 -force_key_frames \"expr:gte(t, n_forced * 2)\" -t 60 -segment_time 2 -f segment "; ret += "-reset_timestamps 1 -sc_threshold 0 -g 2 -force_key_frames \"expr:gte(t, n_forced * 2)\" -t 60 -segment_time 2 -f segment ";
ret += conf->buffPath + "/live/" + QString(STRFTIME_FMT) + conf->streamExt; ret += conf->buffPath + "/live/" + QString(STRFTIME_FMT) + conf->streamExt;
} }