There is a bug in the video upload module when using ffmpeg. If you edit a video node with an uploaded video that was converted, the video_render.php module does not delete the previously converted file once it sets the serialized data for the new file after it renders the new file out. To fix this, I made the changes indicated below:
function _video_render_set_video_encoded_fid($nid, $vid, $encoded_fid) {
db_lock_table('video');
$node = db_fetch_object(db_query("SELECT serialized_data FROM {video} WHERE nid = %d AND vid = %d", $nid, $vid));
$node->serial_data = unserialize($node->serialized_data);
//GMM: save fid of previously encoded file
$old_fid = $node->serial_data['video_encoded_fid'];
$node->serial_data['video_encoded_fid'] = $encoded_fid;
$node->serialized_data = serialize($node->serial_data);
db_query("UPDATE {video} SET serialized_data = '%s' WHERE nid = %d AND vid = %d", $node->serialized_data, $nid, $vid);
db_unlock_tables();
// GMM: update status on previously encoded fid to 0 so drupal will delete
if($old_fid > 0)
db_query("UPDATE {files} SET status = %d WHERE fid = %d", 0, $old_fid);
// GMM:
}
In this way, the status of the previously uploaded video is set to 0 so the Drupal cron will eventually delete it.
Enjoy
--glen
Comments
Comment #1
glen201 commentedOK for the above to work for you, you must have the patch installed from the end of this thread http://drupal.org/node/221209 and the second half of the patch to the video_update function must be changed to the following:
// GMM: make sure to save the encoded_fid
if (!isset($node->serial_data['video_encoded_fid']) && $node->video_encoded_fid) {
$node->serial_data['video_encoded_fid'] = $node->video_encoded_fid;
}
Now, editing a node containing an already uploaded/converted video, and replacing the video with a new one to render and update will clean out the old converted video file by setting its status to 0 in the files table.
-- glen
Comment #2
hypertext200commited changes to CVS, thanks for your kind efforts.