Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
V
video_recording_api
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
CI / CD Analytics
Repository Analytics
Value Stream Analytics
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
sikhin.vc
video_recording_api
Commits
0fc5705a
Commit
0fc5705a
authored
Jan 23, 2023
by
Sikhin VC
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
initial commit
parent
618fbea6
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
11 deletions
+13
-11
main.py
main.py
+13
-11
No files found.
main.py
View file @
0fc5705a
...
...
@@ -8,6 +8,7 @@ import time
import
subprocess
import
threading
class
Item
(
BaseModel
):
rtsp
:
str
name
:
str
...
...
@@ -15,22 +16,25 @@ class Item(BaseModel):
# price: float
# tax: Union[float, None] = None
def
background
(
f
):
'''
a threading decorator
use @background above the function you want to run in the background
'''
def
backgrnd_func
(
*
a
,
**
kw
):
threading
.
Thread
(
target
=
f
,
args
=
a
,
kwargs
=
kw
)
.
start
()
return
backgrnd_func
@
background
def
video_rec
(
item
):
# size = (640, 480)
working_dir
=
"videos"
file_name
=
item
[
"name"
]
+
".mp4"
working_dir
=
"/home/administrator/aarti_violation_videos"
file_name
=
item
[
"name"
]
+
".webm"
file_name
=
os
.
path
.
join
(
working_dir
,
file_name
)
print
(
file_name
)
# Below VideoWriter object will create
...
...
@@ -50,7 +54,7 @@ def video_rec(item):
size
=
(
frame_width
,
frame_height
)
result
=
cv2
.
VideoWriter
(
file_name
,
cv2
.
VideoWriter_fourcc
(
*
'avc1
'
),
cv2
.
VideoWriter_fourcc
(
'V'
,
'P'
,
'8'
,
'0
'
),
10
,
size
)
# cap = cv2.VideoCapture(item["rtsp"])
t1
=
time
.
time
()
...
...
@@ -71,22 +75,20 @@ def video_rec(item):
video
.
release
()
app
=
FastAPI
()
@
app
.
post
(
"/items/"
)
async
def
create_item
(
item
:
Item
):
# def video_write(self, frame, unique_id):
# frame_width = int(frame.shape[1])
# frame_height = int(frame.shape[0])
# def video_write(self, frame, unique_id):
# frame_width = int(frame.shape[1])
# frame_height = int(frame.shape[0])
item
=
item
.
dict
()
video_rec
(
item
)
if
__name__
==
"__main__"
:
from
uvicorn
import
run
run
(
app
,
host
=
"0.0.0.0"
,
port
=
2328
)
\ No newline at end of file
run
(
app
,
host
=
"192.168.3.181"
,
port
=
2328
)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment