Skip to content

Commit

Permalink
Merge 2cd81e4 into 71da9ed
Browse files Browse the repository at this point in the history
  • Loading branch information
stephendade committed Sep 26, 2020
2 parents 71da9ed + 2cd81e4 commit 45a34eb
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 3 deletions.
14 changes: 12 additions & 2 deletions python/gstcaps.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,13 @@
device_provider = Gst.DeviceProviderFactory.get_by_name("v4l2deviceprovider")
devices = device_provider.get_devices()

# Get list of vals in cap
def getcapval(caps):
allval = []
for cap in caps:
allval.append(cap['value'])
return allval

retDevices = []

for device in devices:
Expand Down Expand Up @@ -48,10 +55,13 @@
# enumerate available resolutions
for i in range(capsGST.get_size()):
structure = capsGST.get_structure(i)
if structure.get_name() in ['video/x-raw', 'video/x-h264'] :
if structure.get_name() in ['video/x-raw', 'video/x-h264', 'image/jpeg'] :
width = structure.get_int('width').value
height = structure.get_int('height').value
caps.append({'value': "{0}x{1}".format(width, height), 'label': "{0}x{1}".format(width, height), 'height': int(height), 'width': int(width), 'format': structure.get_name()})
#Only append if it's a unique value
if "{0}x{1}".format(width, height) not in getcapval(caps):
form = structure.get_name().split('/')[1]
caps.append({'value': "{0}x{1}".format(width, height), 'label': "{0}x{1} ({2})".format(width, height, form), 'height': int(height), 'width': int(width), 'format': structure.get_name()})

retDevices.append({'value': path, 'label': name, 'caps': caps})

Expand Down
4 changes: 4 additions & 0 deletions python/rtsp-server.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,10 @@ def do_create_element(self, url):
elif self.format == "video/x-h264":
s_src = "v4l2src device={0} ! {3},width={1},height={2}".format(self.device, self.width, self.height, self.format)
pipeline_str = "( {s_src} ! queue max-size-buffers=1 name=q_enc ! h264parse ! rtph264pay name=pay0 pt=96 )".format(**locals())
elif self.format == "image/jpeg":
s_src = "v4l2src device={0} ! {3},width={1},height={2} ! jpegdec ! {4}".format(self.device, self.width, self.height, self.format, self.rotation)
s_h264 = "x264enc tune=zerolatency bitrate={0} speed-preset=superfast".format(self.bitrate)
pipeline_str = "( {s_src} ! queue max-size-buffers=1 name=q_enc ! {s_h264} ! rtph264pay name=pay0 pt=96 )".format(**locals())
print(pipeline_str)
return Gst.parse_launch(pipeline_str)

Expand Down
2 changes: 1 addition & 1 deletion server/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -362,7 +362,7 @@ app.post('/api/startstopvideo', [check('active').isBoolean(),
check('height').isInt({min: 1}),
check('width').isInt({min: 1}),
check('bitrate').isInt({min: 100, max: 10000}),
check('format').isIn(['video/x-raw', 'video/x-h264']),
check('format').isIn(['video/x-raw', 'video/x-h264', 'image/jpeg']),
check('rotation').isInt().isIn([0, 90, 180, 270])], (req, res) => {
const errors = validationResult(req);
if (!errors.isEmpty()) {
Expand Down

0 comments on commit 45a34eb

Please sign in to comment.