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

Feature request: Possibility to record small clips of x amount of seconds of a complete camera session #33

Open
al-sabr opened this issue Apr 8, 2020 · 6 comments

Comments

@al-sabr
Copy link

al-sabr commented Apr 8, 2020

Greetings!

I would like to know how complicated is it to implement a feature that specify Mona that I want to record my Webcam and that I want that the recording being persisted like session1_00.flv, session1_01.flv, session1_02.flv, etc .... session1_x.flv inside of folder session1 which is the stream name.

I am using Adobe AIR with RTMP.

Thank you.

@al-sabr
Copy link
Author

al-sabr commented May 24, 2020

Mathieu, Thomas any tip about where to work for this?

@thomasjammet
Copy link
Contributor

thomasjammet commented May 24, 2020

LUA implementation is a bit instable for now but you can try with the following script.
Just create the file main.lua in MonaServer www/ directory and copy the following lines :

function onConnection(client)

	function client:onRecordMedia(packet)
		client.file:write(tostring(packet))
	end

	function client:onAudio(track, tag, packet, reliable)
		client.recorder:writeAudio(tag, packet)
	end

	function client:onVideo(track, tag, packet, reliable)
		client.recorder:writeVideo(tag, packet)
	end

    function client:onPublish(publication)
		client.fileName = "dump_" .. publication.name .. "_" .. mona:time() .. ".flv"
		NOTE("Begin dumping file '", client.fileName ,"'")
		client.file = io.open(client.fileName, "wb")

		-- Create the FLV Media writer and start it
		client.recorder = mona:newMediaWriter("flv")
		client.recorder.onWrite = client.onRecordMedia
		client.recorder:beginMedia()

		-- Subscribe to the new publication
		client.subscription = mona:newSubscription(publication.name)
		client.subscription.onAudio = client.onAudio
		client.subscription.onVideo = client.onVideo
	end
	
	function client:onUnpublish(publication)
		if client.file then
			NOTE("End dumping file '" , client.fileName, "'")
			client.recorder:endMedia()
			client.file:close()
		end
	end
end

Sadly this is just a POC for now, we don't have time to make LUA stable for now, but at least you can try and see how it will work.

@al-sabr
Copy link
Author

al-sabr commented May 24, 2020

OK you thought I was talking about Lua. I was more asking C++ side so that such small features I could add with your guidance.

@thomasjammet
Copy link
Contributor

The lua script are here to make it easier for users to implement a custom behavior.
If you need a C++ implementation this will cost more time to explain and we are too busy for this, I hope you understand.
Now if you want to start from your own you can try to implement your custom code here in onPublish function :
https://github.com/MonaSolutions/MonaServer2/blob/master/MonaTiny/sources/MonaTiny.cpp#L154

@al-sabr
Copy link
Author

al-sabr commented Jun 1, 2020

I really don't understand why extending Mona has to be dependant on Lua when you can create dynamic extension for any C++ code via the CppMicroservices framework which is perfectly suitable for that purpose.

Creating a bundle delivered as a DLL/SO file and handle during runtime via CppMicroservices is so much easier than having to rely on Lua.

As I mentioned earlier why not make Mona a dynamic server where we can add and remove new functionalities on the fly without getting out of C++?

Why no one gets the fact that compiled static code can also be hooked into a running application an make that code become dynamic?

@al-sabr
Copy link
Author

al-sabr commented Jun 1, 2020

Thanx for the answer I really appreciate the guidance.

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

No branches or pull requests

2 participants