Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Config Support]: How to create clips ? #3258

Closed
RobertusIT opened this issue May 26, 2022 · 10 comments
Closed

[Config Support]: How to create clips ? #3258

RobertusIT opened this issue May 26, 2022 · 10 comments

Comments

@RobertusIT
Copy link

Describe the problem you are having

Hi, in the previous version, there was clips in .mp4 generated by frigate. So was easy to upload them in a cloud, like google drive, with rclone.

Now frigate doesn't do that, so don't create any .mp4 clips files, and i can't understand how to.

Is not safe to store locally .mp4 clips, a thief can destroy them and you can't have any proof, is very strange that no one take care about that!

Please can you explain in details for a noob, how to create clips ?

Would be better if frigate have a feature that upload them in a cloud.... but anyway....

THanks for the support

Version

0.10.1-83481AF

Frigate config file

########################################## MQTT SERVER 
database:
  path: /home/frigate.db
mqtt:
  host: 192.168.178.56
  user: mqtt_user
  password: mqtt_user
  topic_prefix: frigate
  client_id: frigate
########################################## GOOGLE CORAL USB
detectors:
  coral:
    type: edgetpu
    device: usb
########################################## GLOBAL SETTINGS
record:
  enabled: True
  retain_days: 0
  events:
    max_seconds: 300
    pre_capture: 5
    post_capture: 5
    objects:
      - person
    retain:
      default: 10
           
snapshots:
  enabled: True
  timestamp: False
  bounding_box: True
  retain:
    objects:
      person: 10

live:
  height: 1920
  quality: 1
########################################## INGRESSO
cameras:

  ingresso:
    ffmpeg:
      hwaccel_args:
        - -hwaccel
        - vaapi
        - -hwaccel_device
        - /dev/dri/renderD128
        - -hwaccel_output_format
        - yuv420p
 
      input_args:
        - -avoid_negative_ts
        - make_zero
        - -fflags
        - nobuffer+genpts+discardcorrupt
        - -flags
        - low_delay
        - -strict
        - experimental
        - -analyzeduration
        - 1000M
        - -probesize
        - 1000M
        - -rw_timeout
        - "5000000"
      output_args:
#        rtmp: -c copy -f flv
#OLD        record: -f segment -segment_time 60 -segment_format mp4 -reset_timestamps 1 -strftime 1 -c copy
        record: -f segment -segment_time 60 -segment_format mp4 -reset_timestamps 1 -strftime 1 -c:v copy -c:a aac
#        detect: -f rawvideo -pix_fmt yuv420p
      inputs:
        - path: http://192.168.178.35/flv?port=1935&app=bcs&stream=channel0_main.bcs&user=admin&password=mypass
#        - path: rtmp://192.168.178.35/bcs/channel0_main.bcs?channel=0&stream=0&user=admin&password=mypass
          roles:
            - rtmp
            - record
        - path: http://192.168.178.35/flv?port=1935&app=bcs&stream=channel0_ext.bcs&user=admin&password=mypass
#        - path: rtmp://192.168.178.35/bcs/channel0_ext.bcs?channel=0&stream=0&user=admin&password=mypass
          roles:
            - detect

    detect:
      enabled: true
      width: 640
      height: 480
      fps: 7

########################################## BALCONE GRANDE
  balcone_grande:
    ffmpeg:
      hwaccel_args:
        - -hwaccel
        - vaapi
        - -hwaccel_device
        - /dev/dri/renderD128
        - -hwaccel_output_format
        - yuv420p
 
      input_args:
        - -avoid_negative_ts
        - make_zero
        - -fflags
        - nobuffer+genpts+discardcorrupt
        - -flags
        - low_delay
        - -strict
        - experimental
        - -analyzeduration
        - 1000M
        - -probesize
        - 1000M
        - -rw_timeout
        - "5000000"
      output_args:
#        rtmp: -c copy -f flv
#OLD        record: -f segment -segment_time 60 -segment_format mp4 -reset_timestamps 1 -strftime 1 -c copy
        record: -f segment -segment_time 60 -segment_format mp4 -reset_timestamps 1 -strftime 1 -c:v copy -c:a aac
#        detect: -f rawvideo -pix_fmt yuv420p
      inputs:
        - path: http://192.168.178.49/flv?port=1935&app=bcs&stream=channel0_main.bcs&user=admin&password=mypass
#        - path: rtmp://192.168.178.35/bcs/channel0_main.bcs?channel=0&stream=0&user=admin&password=mypass
          roles:
            - rtmp
            - record
        - path: http://192.168.178.49/flv?port=1935&app=bcs&stream=channel0_ext.bcs&user=admin&password=mypass
#        - path: rtmp://192.168.178.35/bcs/channel0_ext.bcs?channel=0&stream=0&user=admin&password=mypass
          roles:
            - detect

    detect:
      enabled: true
      width: 640
      height: 480
      fps: 7
    motion:
      mask:
        - 492,281,531,212,542,166,561,148,557,119,552,100,576,81,576,0,493,0,316,0,96,0,0,0,0,130,0,480,369,480

########################################## VERANDA
  veranda:
    ffmpeg:
      hwaccel_args:
        - -hwaccel
        - vaapi
        - -hwaccel_device
        - /dev/dri/renderD128
        - -hwaccel_output_format
        - yuv420p
 
      input_args:
        - -avoid_negative_ts
        - make_zero
        - -fflags
        - nobuffer+genpts+discardcorrupt
        - -flags
        - low_delay
        - -strict
        - experimental
        - -analyzeduration
        - 1000M
        - -probesize
        - 1000M
        - -rw_timeout
        - "5000000"
      output_args:
#        rtmp: -c copy -f flv
#OLD        record: -f segment -segment_time 60 -segment_format mp4 -reset_timestamps 1 -strftime 1 -c copy
        record: -f segment -segment_time 60 -segment_format mp4 -reset_timestamps 1 -strftime 1 -c:v copy -c:a aac
#        detect: -f rawvideo -pix_fmt yuv420p
      inputs:
        - path: http://192.168.178.33/flv?port=1935&app=bcs&stream=channel0_main.bcs&user=admin&password=mypass
#        - path: rtmp://192.168.178.35/bcs/channel0_main.bcs?channel=0&stream=0&user=admin&password=mypass
          roles:
            - rtmp
            - record
        - path: http://192.168.178.33/flv?port=1935&app=bcs&stream=channel0_ext.bcs&user=admin&password=mypass
#        - path: rtmp://192.168.178.35/bcs/channel0_ext.bcs?channel=0&stream=0&user=admin&password=mypass
          roles:
            - detect

    detect:
      enabled: true
      width: 640
      height: 480
      fps: 7
########################################## STUDIO
  studio:
    ffmpeg:
      hwaccel_args:
        - -hwaccel
        - vaapi
        - -hwaccel_device
        - /dev/dri/renderD128
        - -hwaccel_output_format
        - yuv420p
 
      input_args:
        - -avoid_negative_ts
        - make_zero
        - -fflags
        - nobuffer+genpts+discardcorrupt
        - -flags
        - low_delay
        - -strict
        - experimental
        - -analyzeduration
        - 1000M
        - -probesize
        - 1000M
        - -rw_timeout
        - "5000000"
      output_args:
#        rtmp: -c copy -f flv
#OLD        record: -f segment -segment_time 60 -segment_format mp4 -reset_timestamps 1 -strftime 1 -c copy
        record: -f segment -segment_time 60 -segment_format mp4 -reset_timestamps 1 -strftime 1 -c:v copy -c:a aac
#        detect: -f rawvideo -pix_fmt yuv420p
      inputs:
        - path: http://192.168.178.50/flv?port=1935&app=bcs&stream=channel0_main.bcs&user=admin&password=mypass
#        - path: rtmp://192.168.178.35/bcs/channel0_main.bcs?channel=0&stream=0&user=admin&password=mypass
          roles:
            - rtmp
            - record
        - path: http://192.168.178.50/flv?port=1935&app=bcs&stream=channel0_ext.bcs&user=admin&password=mypass
#        - path: rtmp://192.168.178.35/bcs/channel0_ext.bcs?channel=0&stream=0&user=admin&password=mypass
          roles:
            - detect

    detect:
      enabled: true
      width: 640
      height: 480
      fps: 7

    motion:
      mask:
        - 411,393,380,228,271,224,224,223,205,223,250,227,194,221,176,220,153,259,133,43,97,240,91,480,0,480,0,0,226,0,640,0,640,163,640,480,431,480
        - 640,480
########################################## CAMERA DA LETTO
  camera_da_letto:
    ffmpeg:
      hwaccel_args:
        - -hwaccel
        - vaapi
        - -hwaccel_device
        - /dev/dri/renderD128
        - -hwaccel_output_format
        - yuv420p
 
      input_args:
        - -avoid_negative_ts
        - make_zero
        - -fflags
        - nobuffer+genpts+discardcorrupt
        - -flags
        - low_delay
        - -strict
        - experimental
        - -analyzeduration
        - 1000M
        - -probesize
        - 1000M
        - -rw_timeout
        - "5000000"
      output_args:
#        rtmp: -c copy -f flv
#OLD        record: -f segment -segment_time 60 -segment_format mp4 -reset_timestamps 1 -strftime 1 -c copy
        record: -f segment -segment_time 60 -segment_format mp4 -reset_timestamps 1 -strftime 1 -c:v copy -c:a aac
#        detect: -f rawvideo -pix_fmt yuv420p
      inputs:
        - path: http://192.168.178.53/flv?port=1935&app=bcs&stream=channel0_main.bcs&user=admin&password=mypass
#        - path: rtmp://192.168.178.35/bcs/channel0_main.bcs?channel=0&stream=0&user=admin&password=mypass
          roles:
            - rtmp
            - record
        - path: http://192.168.178.53/flv?port=1935&app=bcs&stream=channel0_ext.bcs&user=admin&password=mypass
#        - path: rtmp://192.168.178.35/bcs/channel0_ext.bcs?channel=0&stream=0&user=admin&password=mypass
          roles:
            - detect

    detect:
      enabled: true
      width: 640
      height: 480
      fps: 7
  
    motion:
      mask:
        - 0,480,0,0,77,0,184,0,640,0,640,480,348,480,294,84,309,0,217,0,215,0,196,24,194,59,176,55,167,85,148,103,133,221,119,390,130,480           
########################################## CAMPANELLO
#  campanello:
#    ffmpeg:
#      hwaccel_args:
#        - -hwaccel
#        - vaapi
#        - -hwaccel_device
#        - /dev/dri/renderD128
#        - -hwaccel_output_format
#        - yuv420p
#        
#      input_args: 
#        -avoid_negative_ts make_zero 
#        -fflags +genpts+discardcorrupt 
#        -rtsp_transport tcp 
#        -stimeout 5000000 
#        -use_wallclock_as_timestamps 1 
#
#
#      output_args:
#        detect: -f rawvideo -pix_fmt yuv420p
#        record: -f segment -segment_time 60 -segment_format mp4 -reset_timestamps 1 -strftime 1 -c:v copy -c:a aac
#        rtmp: -c copy -f flv   
#        
#      inputs:
#        - path: rtsp://admin:mypass@192.168.178.46:554/cam/realmonitor?channel=1&subtype=0
#          roles:
#            - detect
#            - record
#            - rtmp
#    detect:
#      enabled: true
#      width: 2560
#      height: 1920
#      fps: 5

Relevant log output

[2022-05-26 21:20:13] frigate.app                    INFO    : Starting Frigate (0.10.1-83481af)
[2022-05-26 21:20:13] frigate.config                 WARNING : The 'retain_days' config option has been DEPRECATED and will be removed in a future version. Please use the 'days' setting under 'retain'
[2022-05-26 21:20:13] frigate.config                 WARNING : The 'retain_days' config option has been DEPRECATED and will be removed in a future version. Please use the 'days' setting under 'retain'
Starting migrations
[2022-05-26 21:20:13] peewee_migrate                 INFO    : Starting migrations
There is nothing to migrate
[2022-05-26 21:20:13] peewee_migrate                 INFO    : There is nothing to migrate
[2022-05-26 21:20:13] frigate.app                    INFO    : Output process started: 219
[2022-05-26 21:20:13] ws4py                          INFO    : Using epoll
[2022-05-26 21:20:13] frigate.app                    INFO    : Camera processor started for ingresso: 223
[2022-05-26 21:20:13] frigate.app                    INFO    : Camera processor started for campanello: 224
[2022-05-26 21:20:13] frigate.app                    INFO    : Capture process started for ingresso: 225
[2022-05-26 21:20:13] detector.coral                 INFO    : Starting detection process: 217
[2022-05-26 21:20:13] frigate.edgetpu                INFO    : Attempting to load TPU as usb
[2022-05-26 21:20:13] frigate.app                    INFO    : Capture process started for campanello: 226
[2022-05-26 21:20:13] ws4py                          INFO    : Using epoll
[2022-05-26 21:20:16] frigate.edgetpu                INFO    : TPU found

Frigate stats

No response

Operating system

Proxmox

Install method

Docker Compose

Coral version

USB

Any other information that may be helpful

No response

@NickM-27
Copy link
Collaborator

Clip mp4s themselves are not saved per-event as this was redundant and space inefficient (as well as added to a lot more SSD wear which is another threat to security).

Some other context for this is provided here: #2176

But in general, you can use the http clips endpoint for getting the mp4 to upload for any event, and the http recording endpoint to get a stream that can be translated to an mp4 for any specific time range.

@RobertusIT
Copy link
Author

Clip mp4s themselves are not saved per-event as this was redundant and space inefficient (as well as added to a lot more SSD wear which is another threat to security).

Some other context for this is provided here: #2176

But in general, you can use the http clips endpoint for getting the mp4 to upload for any event, and the http recording endpoint to get a stream that can be translated to an mp4 for any specific time range.

isn't clear for me, please can you explain how to do that ?

where can i use these commands, and how ?

@NickM-27
Copy link
Collaborator

where can i use these commands, and how ?

All of the commands are listed in the docs. They are simple http commands that are called, can be called in the browser as well.

isn't clear for me, please can you explain how to do that ?

it depends how your current backup system works, but in general it will just be a script that calls the http api for event ids to download clips for them and then backs it up to the cloud server.

@RobertusIT
Copy link
Author

where can i use these commands, and how ?

All of the commands are listed in the docs. They are simple http commands that are called, can be called in the browser as well.

isn't clear for me, please can you explain how to do that ?

it depends how your current backup system works, but in general it will just be a script that calls the http api for event ids to download clips for them and then backs it up to the cloud server.

I don't understand how to write this script
Where can i get ID event
How can run this script, so with a crontab ? I hope no...

I'm looking for a simple way to have these .mp4 about every events, and upload them in my google drive, only this....

@NickM-27
Copy link
Collaborator

How can run this script, so with a crontab ? I hope no...

If you aren't currently using a cronjob then it wouldn't be required, however you are doing it now just needs to be adjust some to download the mp4s

I'm looking for a simple way to have these .mp4 about every events, and upload them in my google drive, only this....

it could be as simple as (psuedocode)

events = get http://frigate_ip:5000/api/events?limit=10 // get last 10 events

for event in events
    get http://frigate_ip:5000/api/{event["id"]}/clip.mpg // download clips to current folder
    rsync download.mp4 to_google_drive

delete mp4s

You haven't given much detail on how your setup is run currently, but it can be as extensible as it needs to be and shouldn't be too difficult. The rsync part is more complicated than downloading the events / clips.

@RobertusIT
Copy link
Author

My config is:

Proxmox - HASSos - Frigate in LXC with USB google coral - an usb where is store frigate files.

So i need a way, when an events, ended, automatically, create .mp4 file and upload in a cloud.

Upload in a cloud isn't a problem, because with rclone i can do that.
rclone sync /mnt/frigate/clips MYDRIVE:/clips

But i need to know how to have this automation when there is an event, ended event, so create automatically mp4 and script execute rclone sync command

@NickM-27
Copy link
Collaborator

Upload in a cloud isn't a problem, because with rclone i can do that.
rclone sync /mnt/frigate/clips MYDRIVE:/clips

How often is your rclone command run currently?

But i need to know how to have this automation when there is an event, ended event, so create automatically mp4 and script execute rclone sync command

This can be done a number of ways:

  1. Listening to MQTT you could watch for frigate/events with type=end which includes the event id in the payload and then download that clip to /mnt/frigate/event-clips (or whatever), then run a similar rclone
  2. Could have a cronjob that runs at the end of everyday pulling the event ids for that day, downloading the clips to /mnt/frigate/event-clips, then run similar rclone
  3. Probably some other solutions that people have figured out ([Feature Request] Custom storage provider for media files (S3-like or WebDAV) #2964 for example)

@RobertusIT
Copy link
Author

Upload in a cloud isn't a problem, because with rclone i can do that.
rclone sync /mnt/frigate/clips MYDRIVE:/clips

How often is your rclone command run currently?

But i need to know how to have this automation when there is an event, ended event, so create automatically mp4 and script execute rclone sync command

This can be done a number of ways:

  1. Listening to MQTT you could watch for frigate/events with type=end which includes the event id in the payload and then download that clip to /mnt/frigate/event-clips (or whatever), then run a similar rclone
  2. Could have a cronjob that runs at the end of everyday pulling the event ids for that day, downloading the clips to /mnt/frigate/event-clips, then run similar rclone
  3. Probably some other solutions that people have figured out ([Feature Request] Custom storage provider for media files (S3-like or WebDAV) #2964 for example)

For now rclone command doesn't run, because i need to set up to works automatically, not with crontab , but when there is a frigate event. Frigate Event > record .mp4 > upload it in cloud with rclone command. Done

About point 1 i didn't understand how to listen. I have mqtt in HassOS but how i can do that ?

About point 2 isn't automatically, because when there is an event, isn't uploaded in real time into the cloud.

@NickM-27
Copy link
Collaborator

About point 1 i didn't understand how to listen. I have mqtt in HassOS but how i can do that ?

This can be done with nodered.

Could also likely use the rclone hassos addon
https://github.com/alex3305/home-assistant-addons/tree/master/rclone

This discussion shows how to use home assistant to catch mqtt automations in general, would need to be slightly tweaked to fit your use case: #2898

Just being honest, I don't have time to write out a full step by step guide, but those are resources that should be able to help get this going. Could also post on reddit or other forums and someone with more time may be able to help. This may be made easier by future improvements with Frigate, but right now I think what I have outline are the easiest ways to accomplish this.

@stale
Copy link

stale bot commented Jun 27, 2022

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale label Jun 27, 2022
@stale stale bot closed this as completed Jul 1, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants