-
Type:
Task
-
Resolution: Done
-
Priority:
Major - P3
-
None
-
Affects Version/s: 2.4
-
Component/s: API
-
None
-
Environment:OS: Windows 7
I7 processor 64bit
16GB ram
500GB harddisk
-
None
-
None
-
None
-
None
-
None
-
None
-
None
We are able to save video file into GridFS and able to read complete video file from GridFS. But our requirement is to get certain time frame of the video file. Which we are unable to do it with existing mongoDB java Api.
Please let use know how to get the certain slice of the video from the GridFS. This requirement is for one of the government project in which we have to capture the video from footage's and save it to mongoDB. and retrieve the certain time-frame of the video on required basis, the footage that needs to be saved will come from 500+ digital cameras. this data has to be archived for 5 years(We have arrived at design from archiving stand point). This is marked as a blocker as we are not able to proceed with our POC.
Below is the code we have written to get video file from GridFS. Please share us with example of how to get certain time frame of video from GridFS using Java Api.
OutputStream out = new FileOutputStream( new File("C:\\Users\\Administrator\\Pictures\\walkMongo.mp4") ); Mongo mongo = new MongoClient("localhost", 27017); DB db = mongo.getDB("test"); String newFileName = "walk"; GridFS gfsPhoto = new GridFS(db,"video"); GridFSDBFile imageForOutput = gfsPhoto.findOne(newFileName); DBCollection chunks = db.getCollection("video.chunks"); BasicDBObject query = new BasicDBObject(); //DBCursor cur = chunks.find(query.append("files_id", imageForOutput.getId()).append("n", new BasicDBObject("$lt",10))); DBCursor cur = chunks.find(query.append("files_id", imageForOutput.getId())); System.out.println(cur.size()); for (DBObject dbObject : cur) { out.write((byte[])dbObject.get("data")); } imageForOutput.writeTo(out);