Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding mongodb based video player #75

Closed
wants to merge 4 commits into from

Conversation

cdondrup
Copy link
Member

Inspired by the music player by @nilsbore. Uses the mjpeg server and opencv to play the video.

Issues: no sounds
Tried to look at pygame for this, but could not find anything obvious. Maybe @marc-hanheide has an idea.

This works for now and is used in the walking group entertainment interface.

Uses the mjpeg server and open cv read to play the video.
Issues: no sounds
Tried to look at pygame for this, but could not find anything obvious. Maybe @marc-hanheide has an idea.
This works for now and is used in the walking group entertainment interface.
…ds_ui into video_player

Conflicts:
	strands_ui/package.xml
while self.play and ret and not rospy.is_shutdown():
img = self.bridge.cv2_to_imgmsg(frame, "bgr8")
self.video_pub.publish(img)
self.rate.sleep()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so, this assumes always be 25Hz videos. Quite a bold assumption. Can the rate be read from the video file?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Valid point. I'll have a look but I guess so.
Don't merge yet.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fps = video.get(cv.CV_CAP_PROP_FPS)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Exactly :)

@cdondrup
Copy link
Member Author

Reading fps from video and setting appropriate sleep rate.

@marc-hanheide
Copy link
Member

for the audio: No, I don't have any idea, other than going full-scale with using ffmpeg library etc, But synchronicity will not be possible with the current approach. The alternative would be to not use the mjpeg canvas, but to really integrate an HTML5 player:

<video width="356" height="200" controls poster="full/http/link/to/image/file.png"  >

<source src="full/link/to/http/mp4/video/file.mp4" type="video/mp4" />

<source src="full/link/to/http/ogv/video/file.ogv" type="video/ogg" />

<source src="full/link/to/http/webm/video/file.wbem" type="video/webm" />

<em>Sorry, your browser doesn't support HTML5 video.</em>

</video>

Then we would have to be able to serve the files via HTTP. That actually looks better, I believe...

@cdondrup
Copy link
Member Author

OK, that would be good. My only concern is that I have to hard code the path to the video files if I understand that correctly. I can use the media server to retrieve them but the html has to contain the path where I put them. Can I use absolute paths in there? I don't think so... how would I tell it where to look for the video?

@cdondrup
Copy link
Member Author

So basically, my problem is the same as with the images. The html files are all installed to /opt/ros/indigo and the webserver is only able to display things relative to that directory. That would mean I have to put the videos and images into that directory which I can't due to permissions. The mjpeg server allows me to show images published to a topic so I can just retrieve everything from the mongodb, put it somewhere I have permissions and read it.

Maybe I got something wrong and that is easy to fix, but afaik I cannot tell the html5 player where to look for the video, because it would only be able to find it in a directory where I don't have write permissions.

@cdondrup
Copy link
Member Author

If you don't mind @marc-hanheide I merge this because it does build, install, and works for now, so I can continue working on the overall system. This can be fixed at a later point.

@marc-hanheide
Copy link
Member

Go, merge it, but I think this calls for a change in strands_webserver as we already discussed in #59.

@cburbridge
Copy link
Member

The media_server package already serves the video files over HTTP, so no need to have another webserver to serve them or write them to a file in addition to the file already in the mongodb...

@cdondrup
Copy link
Member Author

@cburbridge How would I show a video on a webpage then using the media server?
I'm rather bad at all these web things, sorry.

@marc-hanheide
Copy link
Member

check https://github.com/strands-project/strands_ui/blob/hydro-devel/mongodb_media_server/scripts/server.py#L43

seems you can simply use

<video width="356" height="200" >
<source src="http://MEDIAHOST:8027/get_media/<ID>" type="video/mp4" />
<em>Sorry, your browser doesn't support HTML5 video.</em>
</video>

@marc-hanheide
Copy link
Member

Sorry to render your video_server void ;-)

@cdondrup
Copy link
Member Author

Even better. Maybe I don't need the image server hack then either.

@cdondrup cdondrup closed this Mar 27, 2015
@cburbridge
Copy link
Member

Exactly as @marc-hanheide says. At the moment I only provided a Python API to query the list of available 'sets' and get the ID of files in the set (see README), but an http based API to allow javascript based queries is (low) on my todo list.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants