Closed (fixed)
Project:
Media Mover
Version:
6.x-1.x-dev
Component:
Code
Priority:
Normal
Category:
Support request
Assigned:
Unassigned
Reporter:
Created:
30 Nov 2009 at 21:32 UTC
Updated:
18 Mar 2010 at 22:40 UTC
I'm using a media mover to convert video files via the ffmpeg_wrapper. I am writing a mm_process_hook to start the encode on a remote server. During subsequent runs I'd like the hook to check if the file is done and if so complete. This way the cron job does timeout trying to encode a two hour long video.
So, my current idea is on the first run of the process I fire off the encode job and return NULL. Then on the following runs I would keep checking if the job is done. If so I'll return the mm_file array. Which feels like a bad hack.
Is their a better way to keep track of process execution? Basically, I'm keeping the file in a error state until my process function returns it.
Comments
Comment #1
arthurf commentedI think there is a modification that we can make to media mover api to make this work better which is to add a "in process" state to files which can be returned from the media_mover_api($verb) function. Basically, right now you can return true, false, or the new filepath. We can add a third option which might be MMA_FILE_STATUS_PROCESSING. By default, if this is set, I will try to catch the module, verb, and action id that is currently fired and store this so the file can be "awoken".
On your end, you should setup a notification URL which is hit by your transcoding server when the job is done. You should be able to just reference the $file['mmfid'] and do any file moving that you need to (hint, php's ssh library can make file moving for this kind of stuff really easy). I will need to make an API call that you can use with the $file['mmfid'] which will push the file into the correct state for media mover.
Let's call this function: media_mover_api_file_processing_status($mmfid, $status = true) where $mmfid is an int and $status is boolean: either error condition or complete.
Do you think that's enough to handle this?
Comment #2
darrick commentedThanks Arthur
This sounds good. I was hoping to avoid a callback url. I have found changing the file status from error to harvest will cause the file to run through the process function. So as a temporary hack I could change all the mm_files associated with my config from error to harvest in the cron run. It would be ideal if both files with status MMA_FILE_STATUS_HARVESTED and MMA_FILE_STATUS_PROCESSING were sent to the process function.
Comment #3
arthurf commentedOk, so the way I see this is the following:
* File is harvested via some mechanism
* File goes to be processed.
* You notify your transcoding server to process the file
* You return MMA_FILE_STATUS_PROCESSING in your process function
* MM leaves your file in the processing state
* your transcoding server completes its job and pings a url or fires media_mover_api_file_processing_status()
* MM unlocks your file and pushes it to the next state.
Does that work for you?
Comment #4
darrick commentedBelow would help me avoid the callback. But, I could understand if that is to much of a change in program flow. So, your way will work fine too.
* MM sends file to be processed again.
* My process function checks to see if the file is done processing.
* I return MMA_FILE_STATUS_PROCESSING if file is still processing.
* I clear the status if file is done processing and file is stored via some mechanism
* your transcoding server completes its job and pings a url or fires media_mover_api_file_processing_status()* MM unlocks your file and pushes it to the next state.Comment #5
arthurf commentedWell the issue is the following- media mover has four defined steps, three of which files can be either in ready or running. While media mover 2 has more flexibility here, it's not going to be ready any time soon. Why this is important is the way that media mover selects files for operations is based on the file status. For example, when your configuration runs, media mover runs your harvest configuration. New files are placed into the db set to MMA_FILE_STATUS_HARVESTED. Media mover then runs the process verb, selecting all the files from the db which match MMA_FILE_STATUS_HARVESTED and your configuration ID. This happens for status = MMA_FILE_STATUS_PROCESS_COMPLETE, MMA_FILE_STATUS_STORAGE_COMPLETE as each verb is run separately.
The reason why this is important is that the only time that the process verb will select your file for processing is when it is status = MMA_FILE_STATUS_HARVESTED. While it could be altered to include additional statuses, I would need to seriously think through some of the assumptions that the API makes to see if this would even be possible.
I guess I'm unclear on why you need media mover to be checking the status of your transcoding? Why not just use hook_cron if you can't create a callback url?
Comment #6
darrick commentedI did end up writing the callback function. In the callback I updated the mm file as follows and everything got back on track. Thanks for your help.
Comment #7
arthurf commentedHere is the modification needed for the 1.x branch to handle alternate statuses. This will allow a different module to pull the file out of the DB and manipulate it. You would just get your files with: media_mover_get_files($status)
Comment #8
arthurf commentedThe status fix was committed, closing this issue