Wowza Community

How to determine if a recording has completed processing with the rest api

Good morning,

I am a developer and part of the website I am working on involves using wowza to record live streams. I have been communicating the basic api requests to start and stop the recordings with the REST API and this part has been going well. Part of the requirement of the website involves moving the files from their location on the disk to another location once the recording is completed. My issue is determining when the processing and writing of the file is completed by wowza. In the first iteration I have written the filesystem is checked for the existence of the file (’.mp4’ instead of the ‘.tmp’ file) and once it is found then it is read and moved to the new location. This usually did not work, and the output files at the end of the process would be corrupt and not playable. As a simple test to see what the problem was, I just had my program wait for a minute after the ‘stopRecording’ message was sent to the API, and then proceed. So far this has passed all tests leading me to believe this is the issue.

So then my question becomes: is there a call on the API which can be performed which queries if the file is finished being written to disk yet? Otherwise I will have to do something more low level to determine this.

Thank you for reading.

Hello there,

There was a similar question answered in this post:

How to get the recording status of a stream when using liveStreamRecord

see if that is what you are looking for.

Kind regards,

Salvadore

I am sorry, I do not have much experience working with this API at the moment.

Have you seen this module, it may have the functionality you are looking for:

How to move recordings from live streams (ModuleMediaWriterFileMover)

And you may have already seen this guide, but just in case:

How to access documentation for Wowza Streaming Engine REST APIs

I will try to forward this question on to someone on the support team and see what they come back with.

Kind regards,

Salvadore

Good Afternoon, salvadore, and thanks for the reply.

I did actually take notice of the thread you pointed out when I first came to this forum looking for an answer. There are however, a few differences.

The main difference is that I can get a confirmation reply that the recording has stopped by using the GET method REST API, but this does not seem to correlate directly with when the file has actually finished being processed.

Secondly, I have been using the URL GET REST API and not the direct Java API, which works best with the current configuration of my servers and setup. I would prefer to have a method which uses only this “WEB” api to accomplish this task.

Thank you.

Well, I am still curious is an official solution is available, but for now, these couple of checks seem to work well and have not failed for my application yet. The code is python but the same type of solution should work for other languages. (wait for tempfile to vanish and then wait for writes to stop on the output file) Feel free to use this code if it helps you.

        filename = os.path.join(path)+'.mp4'
        tmpname = os.path.join(path)+'.mp4.tmp'
        while os.path.isfile(tmpname) == True:
            print 'tmp still exists'
            time.sleep(1)
        waitAfter = datetime.timedelta(seconds=5)
        waitUntil = datetime.datetime.now() + waitAfter
        newtime = None
        while (waitUntil > datetime.datetime.now()):
            prevtime = os.stat(filename).st_mtime 
            time.sleep(1)
            newtime = os.stat(filename).st_mtime
            if newtime != prevtime:
                print "The file is still being written to, waiting..."
                waitUntil = datetime.datetime.now() + waitAfter

Have a good night!