[JAVA-1166] Unable to read portion or time frame of video file from GridFS Created: 14/Apr/14 Updated: 11/Sep/19 Resolved: 16/Apr/14 |
|
| Status: | Closed |
| Project: | Java Driver |
| Component/s: | API |
| Affects Version/s: | 2.4 |
| Fix Version/s: | None |
| Type: | Task | Priority: | Major - P3 |
| Reporter: | Mahesh Ramichetty | Assignee: | Unassigned |
| Resolution: | Done | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Environment: |
OS: Windows 7 |
||
| Description |
|
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. 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.
|
| Comments |
| Comment by Mahesh Ramichetty [ 16/Apr/14 ] | |||||||||||||||||||||||||||||
|
Thanks Stephen and Jeff for the clarifications, we have also decided the approach that you have mentioned.but we are facing the issue in the retrieving of the video ,based on the approach this will be correct way to come up with the solution or not. Will post the same question in Stack overflow and other forums. | |||||||||||||||||||||||||||||
| Comment by Stennie Steneker (Inactive) [ 16/Apr/14 ] | |||||||||||||||||||||||||||||
|
Hi Mahesh, To be clear, reading and writing the contents of a video file format (eg. MP4) requires knowledge of the format and is outside the scope of the MongoDB Java driver. In order to start video playback at a specific time offset, you need to first work out how you would do that with a video file on your local file system. I expect that would involve a library that understands the video file format, as there normally isn't a direct correlation between time and bytes. Once you determine the file offset, you should then be start retrieving chunks from GridFS at the specified offset using the InputStream.skip() method that Jeff mentioned. This is definitely a more appropriate question for a programming forum like StackOverflow or perhaps even one of communities more specifically dedicated to working with video codecs. Thanks, | |||||||||||||||||||||||||||||
| Comment by Mahesh Ramichetty [ 15/Apr/14 ] | |||||||||||||||||||||||||||||
|
Hi Jeff, We are not using RandomAccessFile. below is the code which we have used to save and retrieve the video file from MongoDB gridFS. Could you please suggest how to retrieve the particular time frame of the video using GridFs.
| |||||||||||||||||||||||||||||
| Comment by Mahesh Ramichetty [ 15/Apr/14 ] | |||||||||||||||||||||||||||||
|
Will be providing the code right away............. | |||||||||||||||||||||||||||||
| Comment by Jeffrey Yemin [ 14/Apr/14 ] | |||||||||||||||||||||||||||||
|
Mahesh, You misunderstood what I asked for. I'd like to see working code using FileInputStream or RandomAccessFile. Then we can figure out how to translate that code to GridFS. | |||||||||||||||||||||||||||||
| Comment by Mahesh Ramichetty [ 14/Apr/14 ] | |||||||||||||||||||||||||||||
|
Thanks Jeff for responding back, The code for accessing the video is given above when we have raised this as a Question. Pls let us know if any other details are required. | |||||||||||||||||||||||||||||
| Comment by Jeffrey Yemin [ 14/Apr/14 ] | |||||||||||||||||||||||||||||
|
Hi Mahesh, It sounds like you are asking us to figure out how to translate a moment of time in the video file to a byte offset in that file. I don't see how we can do that without knowing the particulars of that video format. Perhaps you can help by sharing some code of how you would accomplish this task for a video file that was sitting on a hard drive, i.e by using either java.io.FileInputStream or java.io.RandomAccessFile. If you can do that, I'm sure we can figure out how to accomplish the same with GridFS. I'd also like to point out that, since this is not really an issue with the Java driver itself, but rather with your application, a better forum would be either StackOverflow (tag the question with mongodb-java) or on the mongodb-user Google group. If we can determine that the Java driver has a bug or requires a new feature to accomplish your goal, then an issue can be opened here to track it. Regards, | |||||||||||||||||||||||||||||
| Comment by Mahesh Ramichetty [ 14/Apr/14 ] | |||||||||||||||||||||||||||||
|
Jeff, We had looked at the code that is in the Git hub, but that is not the code that retrofits the solution that we are looking for. Let me explain what we are looking for. 1: Need to retrieve the video Footage (Portion) that is saved in to Mongo DB using GridFS based on the time frame. 2: we cannot determine the number of chunks that needs to be skipped to retrieve the correct footage.( Because the retrival is purely based on the time) 3: Pls provide a solution for the above scenario. | |||||||||||||||||||||||||||||
| Comment by Mahesh Ramichetty [ 14/Apr/14 ] | |||||||||||||||||||||||||||||
|
Thanks for quick turn around Jeff, will keep you posted on the same once we test the code in the git hub link that is provided,basically we are trying to retrieve the video footage based on the time in that case how to determine that these many number chunks has to be skipped. The Skipping part plays a critical role in getting and displaying the right footage. Give us some time we will revert back on this. | |||||||||||||||||||||||||||||
| Comment by Jeffrey Yemin [ 14/Apr/14 ] | |||||||||||||||||||||||||||||
|
Hi Mahesh, How does your application determine what byte range of the file is needed? Does it use some information encoded at the beginning of the file? That said, the driver does have support for the standard InputStream.skip(int bytesToSkip) method, which you can see usage of in this test: https://github.com/mongodb/mongo-java-driver/blob/master/src/test/com/mongodb/gridfs/GridFSTest.java#L185 Can you take a look at it and let us know if it meets your needs? | |||||||||||||||||||||||||||||
| Comment by Mahesh Ramichetty [ 14/Apr/14 ] | |||||||||||||||||||||||||||||
|
Pls read the |