Jump to content

[TOPIC: topicViewTemplate]
[GLOBAL: userSmallPhoto]
Photo

Video Streaming from an IP Camera
Started by born2b.epic Apr 30 2018 10:31 AM

10 replies to this topic

Best Answer born2b.epic , 08 May 2018 - 09:33 AM

Update: Hello, I have recently been playing with Webview, and found that this is the most appropriate way of attempting to "livestream" from an ip enabled camera. The way to do it, is embed the livestream in an html page, and have the webview request that page.

 

Many thanks to Rob and roaminggamer!

[TOPIC CONTROLS]
[/TOPIC CONTROLS]
[modOptionsDropdown]
[/modOptionsDropdown]
[reputationFilter]
[TOPIC: post.html]
#1

born2b.epic

[GLOBAL: userInfoPane.html]
born2b.epic
  • Observer

  • 13 posts
  • Corona SDK

Hello Corona,

 

I am currently developing a security business app for my client, I have been using Corona SDK for awhile now, however I am presented with a new challenge, streaming video from an IP enabled camera.

 

I have been reading every topic on this subject and have not found a concrete answer, which is why I have started a new topic.

 

So my question is, is there a way to stream video onto the app using a common protocol such as rtsp, without opening the media player on the device?

 

For example, let's say on a Hikvision (one of the most common camera brands) Ip Camera that supports rtsp, would there be a way to have the user open the app, and see what the camera is seeing, and then perform an action within the app?

 

To be even more specific, can the user see what the camera is seeing, and then click a button right below the "camera stream" to execute an action, all from the same app?

 

Any and all help is greatly appreciated, I've always loved the community on this platform and I hope to find some useful information.

 

Thank you everyone....

 

Update: Hello, I have recently been playing with Webview, and found that this is the most appropriate way of attempting to "livestream" from an ip enabled camera. The way to do it, is embed the livestream in an html page, and have the webview request that page.

 

Many thanks to Rob and roaminggamer!



[TOPIC: post.html]
#2

Rob Miracle

[GLOBAL: userInfoPane.html]
Rob Miracle
  • Moderator

  • 24,315 posts
  • Corona Staff

Corona does not offer any API's that are useful for streaming video. Our "streaming" API's assume there is a complete file to download and can start playing the file before it completes downloading, but we don't have anything for fetching a non-ending stream. Now that said, you could potentially use Corona's "native" features to implement RTSP on the native side.

 

Rob



[TOPIC: post.html]
#3

born2b.epic

[GLOBAL: userInfoPane.html]
born2b.epic
  • Observer

  • 13 posts
  • Corona SDK

Hello Rob, 

 

Thank you for your response. Since, there is no way to directly stream "live video" on corona, would there be a way to open a socket, receive the video through rtsp, close the connection and play the video. Then while in the background, the connection is reopened and receives another "batch" while first video plays? Then once the first finishes, it gets deleted and the cycle continues?

 

If not, I have found out and tested that Corona Sdk does support getting an image file from the hikvision camera. With that in mind, would it be possible to obtain multiple images and create an animation as smooth as possible, while in the background, it is getting another batch of image files to play the next animation once the first is over and the cycle continues? (Currently, in theory, this one seems to be the best option, and at the very least simulate some degree of live video.) 

 

Also would it be possible to implement either option with a button underneath the video?

 

Again, 

Thank you, for responding.



[TOPIC: post.html]
#4

Rob Miracle

[GLOBAL: userInfoPane.html]
Rob Miracle
  • Moderator

  • 24,315 posts
  • Corona Staff

Corona supports Lua sockets so you could do that.

 

I really don't know much about the camera's you're working with or out the data is prepared, so I wouldn't feel comfortable offering any recommendations there.

 

Rob



[TOPIC: post.html]
#5

born2b.epic

[GLOBAL: userInfoPane.html]
born2b.epic
  • Observer

  • 13 posts
  • Corona SDK

would you mind sending me a private message, with your thoughts on this? I understand, you would not want to display the wrong information out to the community. This is a topic that has been brought up several times in the past, and if I can make it work, I would have something to offer to the community, or at the very least a way to finally bring this topic to rest.

 

Please let me know if you are willing to send me a private message.

 

Again, thank you for your help.



[TOPIC: post.html]
#6

Rob Miracle

[GLOBAL: userInfoPane.html]
Rob Miracle
  • Moderator

  • 24,315 posts
  • Corona Staff

It's useless for me to send you a private message because I have no information to advise you with. It's best to hopefully get a community developer with some experience to answer this. 

 

Rob



[TOPIC: post.html]
#7

born2b.epic

[GLOBAL: userInfoPane.html]
born2b.epic
  • Observer

  • 13 posts
  • Corona SDK

Alright, in that case, I have another question. 

 

Is it possible to create a loop for a network request, save the image, display the image, wait quarter of a second, perform another network request, save the new image, delete the old one, and display the new image and so on...

 

Would display.loadRemoteImage be more efficient?

 

Would there be any other more efficient way that you can think of, to make it as smooth as possible, perhaps a small delay to get multiple images before receiving more images? 

 

Thank you once again, I appreciate you sharing the information that you know with me.



[TOPIC: post.html]
#8

roaminggamer

[GLOBAL: userInfoPane.html]
roaminggamer
  • Corona Geek

  • 6,920 posts
  • Corona SDK

@born,

 

Tip: Usually one question per thread is the standard.  Otherwise, anyone reading the title later will miss any unrelated nuggets from later unrelated questions.

 

i.e. This is for you now and future readers later, so keeping posts one question per is the best for everyone.

 

That said, "You can essentially make a loop like the one you describe, but you would NOT start the timer to download the next image till the prior image is received."

 

The way I would do this is (pseudo-code)


local genRequest( arg1, ... , argN )

   local function listener( event )
      -- This part of the code is algorithmically defined based on arg1 .. argN above

      -- In the phase the signifies we received the image do this:
      timer.performWithDelay( 500, function() genRequest( some args ) end )
      -- you would also update the fill of the image you're replacing here.
   end

   network.request( url, method, listener [, params] )
end



[TOPIC: post.html]
#9

roaminggamer

[GLOBAL: userInfoPane.html]
roaminggamer
  • Corona Geek

  • 6,920 posts
  • Corona SDK

I have an example that does essentially this, but instead of filling one rectangle, it fulls multiple:

 

https://github.com/roaminggamer/RG_FreeStuff/raw/master/AskEd/2018/04/generatedListener.zip

 

This will give you a basis for making your own version and functionality.


Edited by roaminggamer, 03 May 2018 - 08:26 AM.


[TOPIC: post.html]
#10

born2b.epic

[GLOBAL: userInfoPane.html]
born2b.epic
  • Observer

  • 13 posts
  • Corona SDK

Hello roaminggamer,

 

Thank you for your help. I've looked into your code, and it looks similar to what I want to implement.

 

Also thank you for letting me know about the one question per post rule. I'll keep it concise from now on, on future posts.

 

Thank you.



[TOPIC: post.html]
#11

born2b.epic

[GLOBAL: userInfoPane.html]
born2b.epic
  • Observer

  • 13 posts
  • Corona SDK

  Best Answer

Update: Hello, I have recently been playing with Webview, and found that this is the most appropriate way of attempting to "livestream" from an ip enabled camera. The way to do it, is embed the livestream in an html page, and have the webview request that page.

 

Many thanks to Rob and roaminggamer!




[topic_controls]
[/topic_controls]