How to get a file names recorded on generic event

In Progress

Comments

6 comments

  • Avatar
    Anton Babinov

    Hello Alex,

    sorry for the delayed response. Could you please provide more details about your usage scenario? Are you using generic events with Camera recording action? VMS generates file name as timestamp_duration.mkv, so the only way to associate video file with generic event is to match timestamp from file name with timestamp when generic event was triggered.

    On the other hand, mediaserver has video api, which would allow you to download chunks of recorded video as separate file. For example, if you know when Generic event was triggered, you can download archived video with request like this: 

    /media/<cameraId>.<format>?pos=YYYY-MM-DDTHH:mm:ss.zzz&duration=<seconds>

     

     

     

    0
    Comment actions Permalink
  • Avatar
    alex sarin

    Anton, thanks for the reply! I have an external system (ALPR camera) that is configured to send a generic events to NX server, with the recording video action. Later, from our monitoring system, I would like to send a query that will return a file name for the specific video clip file that was recoded. I can get a list of events , but i can't find a way to get a list of file(s) associated with those generic events. I can use the media server API , but in that case , I assume, i have to use a continuous recording,  that i would like to avoid.  

    0
    Comment actions Permalink
  • Avatar
    Anton Babinov

    It isn't possible to get the list of file names, but you can get the list of recorded intervals with /ec2/recordedTimePeriods API request and then you can request these intervals from server's API.

     

    1. Run /ec2/recordedTimePeriods?cameraId=<ID of your camera>, you'll receive the response like this:

     

    {
        "error":"0",
        "errorString":"",
        "reply":[
            {
                "guid":"{48611fd7-c007-9b38-f733-b43bacf43eba}",
                "periods":[
                    {
                        "durationMs":"97390400",
                        "startTimeMs":"1619454073915"
                    },
                    {
                        "durationMs":"150150910",
                        "startTimeMs":"1619551485241"
                    },
                    {
                        "durationMs":"22243628",
                        "startTimeMs":"1621402631310"
                    }
                ]
            }
        ]
    }

    2. Now you know which interval are recording and you can download videos from server with requests like this:

    /media/<ID of your camera>.mkv?pos=1619454073915&duration=97390

    /media/<ID of your camera>.mkv?pos=1621402631310&duration=22243

     

    0
    Comment actions Permalink
  • Avatar
    Tagir Gadelshin

    alex sarin
    you write that you need a file name

    Later, from our monitoring system, I would like to send a query that will return a file name for the specific video clip file that was recoded.

    Why do you need it? How is it used afterward?

    Usually, the methods provided by Anton should be enough, but it is not clear why would you need names instead of the actual video.

    0
    Comment actions Permalink
  • Avatar
    alex sarin

    I don't want to record the video all the time, i would like to record only a video clip captured  upon a general event that  is sent by our system. If i could get a list of files (video clips with ms as part of the file name) then i would be able to pull out the files and show them. 

    0
    Comment actions Permalink
  • Avatar
    Andrey Terentyev

    Hello Alex,

    I don't want to record the video all the time, i would like to record only a video clip captured upon a general event that is sent by our system

    You don't need to record video all the time.

    What is the good/right way to get the files (list of file names) that where recorded based on a generic event message

    Let me lay out a pipeline of the solution.

    1. You create a rule for a camera:

    Event. When: Generic Event
    Action. Do: Camera recording.
    The "Camera recording" action has several attributes controlling recording duration. That means you know the exact duration of the video chunk to be recorded.

    2. You trigger the Generic Event from your system.

    That means you know the exact time the event is triggered at.

    3. You invoke the /ec2/recordedTimePeriods?cameraId=<ID of your camera> API for getting time periods.

    You iterate through the time periods comparing the startTimeMs parameter to time of the step 2.

    Once the period is found,

    4. You download video from server with API request like this:

    /media/<ID of your camera>.mkv?pos=<startTimeMs value found at the step  3>&duration=<durationMs value of the period found at the step3>

    0
    Comment actions Permalink

Please sign in to leave a comment.