synap5e / obs-screenshot-plugin

An OBS Studio filter plugin to save screenshots of a source/scene
GNU General Public License v2.0
132 stars 20 forks source link

Jpeg support #7

Open dinther opened 4 years ago

dinther commented 4 years ago

The PNG files look like they are not compressed which is a bit of a bandwidth hog when uploading every few seconds. Jpeg support would be awesome.

synap5e commented 4 years ago

I'd be concerned about the CPU usage of encoding jpegs at a rate that png's are causing bandwidth issues. If you need high frequency images sent over network I feel like a mjpeg stream to a url through a custom ffpmeg output might work better than this plugin.

What is your use case for this in particular?

dinther commented 4 years ago

Hey Simon, thanks for writing back.

I am working on a new controller app which enables a wide range of hardware to be used on OBS as a controller. https://obsproject.com/forum/threads/scripted-obs-controller.117657/ Thinking ahead to the next phase I can imagine scenarios where viewers wish to decide on which scene to select in OBS.

So I was thinking to generate a thumbnail every 5 seconds or so and upload that to a regular web server. It doesn't have to be full res. I love how you implemented the screenshot feature as a filter and I noticed it will only be active if that actual source is rendered.

On Mon, Apr 6, 2020 at 2:47 PM Simon Pinfold notifications@github.com wrote:

I'd be concerned about the CPU usage of encoding jpegs at a rate that png's are causing bandwidth issues. If you need high frequency images sent over network I feel like a mjpeg stream to a url through a custom ffpmeg output might work better than this plugin.

What is your use case for this in particular?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/synap5e/obs-screenshot-plugin/issues/7#issuecomment-609538334, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAJDHVHKLIITXN62GXFU5VDRLE7ERANCNFSM4L5DK2ZQ .

-- Regards

Paul van Dinther

synap5e commented 4 years ago

Ah, yeah that makes sense where you need individual sources.

Code wise, JPEG support should (hopefully) be as simple as changing AV_CODEC_ID_PNG to AV_CODEC_ID_JPEG https://github.com/synap5e/obs-screenshot-plugin/blob/master/screenshot-filter.c#L452 I can see how well this works when I next go through the code, or you could try it out if you need sooner.

For resizing, I would imagine adding in sws_scale before encoding would be the way to go. Right now the image is a direct dump of the source, so resizing it wouldn't change anything and the only way to change it would be to add a resize filter before this filter in the chain (which would also change the output).

I'm a bit unclear on how your app would use this plugin, would it script OBS to add the filter to each source?

dinther commented 4 years ago

I really need to learn C++. I looked the other day at the source and then I needed a drink. The app would not directly setup your plugin. I would simply set it up manually for a particular use. But what I want to do is make a web page where viewers can vote which scene to switch to next by clicking on the regularly refreshed thumbnail of the preferred scene.

The web page URL can be made to feed into my controller program and the thumbnail uploads are simply handled by your plugin.

On Wed, Apr 8, 2020 at 2:08 AM Simon Pinfold notifications@github.com wrote:

Ah, yeah that makes sense where you need individual sources.

Code wise, JPEG support should (hopefully) be as simple as changing AV_CODEC_ID_PNG to AV_CODEC_ID_JPEG

https://github.com/synap5e/obs-screenshot-plugin/blob/master/screenshot-filter.c#L452 I can see how well this works when I next go through the code, or you could try it out if you need sooner.

For resizing, I would imagine adding in sws_scale before encoding would be the way to go. Right now the image is a direct dump of the source, so resizing it wouldn't change anything and the only way to change it would be to add a resize filter before this filter in the chain (which would also change the output).

I'm a bit unclear on how your app would use this plugin, would it script OBS to add the filter to each source?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/synap5e/obs-screenshot-plugin/issues/7#issuecomment-610408613, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAJDHVFSO6HUON2FTN3XHYLRLMXWTANCNFSM4L5DK2ZQ .

-- Regards

Paul van Dinther

synap5e commented 4 years ago

Marking this as help wanted in the meantime. If anyone wishes to experiment with AV_CODEC_ID and/or sws_scale along with the corresponding properties (dropdowns, etc.) I would be happy to help with any issues that are encountered.

iareski commented 2 years ago

Ah, yeah that makes sense where you need individual sources.

Code wise, JPEG support should (hopefully) be as simple as changing AV_CODEC_ID_PNG to AV_CODEC_ID_JPEG https://github.com/synap5e/obs-screenshot-plugin/blob/master/screenshot-filter.c#L452 I can see how well this works when I next go through the code, or you could try it out if you need sooner.

For resizing, I would imagine adding in sws_scale before encoding would be the way to go. Right now the image is a direct dump of the source, so resizing it wouldn't change anything and the only way to change it would be to add a resize filter before this filter in the chain (which would also change the output).

I'm a bit unclear on how your app would use this plugin, would it script OBS to add the filter to each source?

Hello friends can u help me with that? I need to a export .jpg instead of .png

synap5e commented 2 years ago

The fork https://github.com/norihiro/obs-screenshot-plugin has this