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

cropping source stream #551

Open
alexisod opened this issue Apr 29, 2023 · 8 comments
Open

cropping source stream #551

alexisod opened this issue Apr 29, 2023 · 8 comments

Comments

@alexisod
Copy link

Is it possible to crop the source stream to certain dimensions?
In my case the camera stream is 2560x1920 and I would like to crop it so that I broadcast a stream of 2560x1440.

@svenerbeck
Copy link
Member

Hello alexisod,

Thank you for your comment.

You want to change the dimensions of the source stream, and you mentioned cropping it from 2560x1920 to 2560x1440. This functionality is available by default if you're looking for a way to resize the video within Restreamer.

We don't have a direct tutorial, as the process is simple. Please take a look at this video for guidance: https://www.youtube.com/watch?v=yPy3ElSkoSA

It is important to note that when resizing videos, the image quality may degrade significantly when enlarging them. Please keep this in mind when adjusting the dimensions of your video stream.

Please also note that this process involves encoding the video stream, which can be resource-intensive. Ensure your hardware can handle the processing load, or consider adjusting the encoding settings for optimal performance.

Cheerio
Sven

@alexisod
Copy link
Author

alexisod commented May 2, 2023

Hi Sven,

Thanks for gettting back to me.
I am not looking to proportionally resize the video. I would like to crop it, i.e. use a certain section of it. In the example I sent the width is 2560 and the height is 1920. I want to use the top 1440 i.e. crop out 480 pixels from the bottom.
I hope this is clearer.

Thanks again for your help

Alex

@svenerbeck
Copy link
Member

Hello alexisod

We apologize for the earlier misunderstanding. It seems our initial response may have been unclear due to the early hour and a lack of ☕ caffeinated beverages. To clarify, the cropping functionality you are seeking is currently not available in Restreamer, as there is no built-in cropping module. We have, however, taken note of your request and added it to our feature request list.

You can find the related discussion here: #345

Cheerio
Sven

@alexisod
Copy link
Author

alexisod commented May 2, 2023

Haha it happens to all of us:) No worries:)
Effectively and as far I I understood from my research, if there was a way to pass something like
-vf "crop=2560:1440:0:0"
as custom params to ffmpeg, that should do it.
Does this sound about right? (assuming there was a way to add custom parameters)?

Alexis

@grahhnt
Copy link

grahhnt commented Jun 27, 2023

it is possible to use ffmpeg to resize the stream then pipe it out again

isn't as clean as it being inside datarhei, but it is possible

https://superuser.com/questions/1282044/crop-video-stream-using-ffmpeg
cc: @alexisod

@alexisod
Copy link
Author

thanks @grahhnt
Would love to see it as part of datarhei one day!

@barroudjo
Copy link

barroudjo commented Jul 6, 2023

Actually you can crop with FFMPEG without re-encoding if your stream is using h264 or h265 as the video codec, with the h264_metadata (or h265_metadata).
Example :

ffmpeg -i "rtsp://192.168.1.64:554/h264Preview_01_main" -codec copy -f flv -bsf:v h264_metadata=crop_left=64:crop_right=64:crop_top=228:crop_bottom=228 "rtmp://cdg02.contribute.live-video.net/app/live"

The relevant FFMPEG option is: -bsf:v h264_metadata=crop_left=64:crop_right=64:crop_top=228:crop_bottom=228

Note that is only works if your player interprets correctly these metadata. For example it's not interpreted correctly by the player in firefox, but it is interpreted correctly by these of chrome and android.

So it'd be great if datarhei gave us the possibility of customizing the options passed to FFMPEG !

@svenerbeck
Copy link
Member

So it'd be great if datarhei gave us the possibility of customizing the options passed to FFMPEG !

Hello @barroudjo
Good point. We added this to the feature request list. #345

Cheerio,
Sven

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

4 participants