-
-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Unable to rotate camera image for portrait view #1242
Comments
It looks like you are using a modified version of the default detect output args for other roles. That's not going to work. You need to start with the default args for those specific roles and add to the transpose modifications to them. |
Hi, Thanks John |
I think I am getting a little further... Sorry I didn't pickup the following I the docs:
I now have the following in my config:
But I get the following error message:
Any advise? |
|
There are ways to do hwaccel for encoding too. Rtmp is just to display in home assistant. Record is for 24/7 recordings. Clips is for videos of each tracked object. |
Which is the role that displays the camera in the Frigate webpage, please? Could you point me to any docs that help with where I configure hwaccel for encoding? |
That would be detect, which is required. Just search around for ffmpeg hwaccel arguments based on your host OS. You can also do hwaccel for decoding too. Ideally you want both. I would start by trying to get it working for decoding. |
I will play with these settings later! Thanks! Great to have the image rotation. Thanks so much for your help. Zoneminder will be turned off soon - whoop! |
OK, I have tried what I think are the right hwaccel args for my hardware and see the following errors:
These are the values I added to my config file:
And here are the details about my hardware:
I appreciate all your guidance! |
From what I can tell, the Xeon X5650 does not support QuickSync, so you don't have hardware acceleration on that CPU. |
I think I may try to rotate my cams back to the standard orientation... It seems the power needed and CPU to process 2 of my cams to rotate 90 degrees side steps the graceful benefits of the lightweight nature of frigate. |
Rotating for detect only shouldn't add much if any CPU load. |
You are correct. That may be a reasonable compromise for my circumstances. It's a shame my camera firmware doesn't allow image rotation at source... I'm going to physically move one cam, but will be left with my front door cam rotated by 90 degrees. I mainly use this for a snapshot sent to me when someone rings the doorbell. I will need to figure out a way of rotating the jpg I pull from the camera stream in homeassistant. Hopefully, this is doable, as I view these a few times per day... I learned a lot from your help - many thanks! |
This is my video card details:
I am currently using this image: image: blakeblackshear/frigate:stable-amd64 Will I gain anything by swapping to the image that supports nvidia?: blakeblackshear/frigate:stable-amd64nvidia I guess I just insert this new image in my docker-compose config file and spin it up? Thanks |
The snapshots that frigate saves come from the detect stream, so they will be rotated. |
Not automatically. You need to determine if that card supports hwaccel in ffmpeg. |
@truxntrax what were your final working output args (detect) to get it to rotate? I'm not even concerned about hw encoding yet. |
Here are what i used:
|
@truxntrax I tried a gazillion options without luck including these exact options. I finally gave up and rolled back my config to a backup. But now I just tried your options and this time it's working. I must have had something else in my config that was conflicting. Now I will see if I can get it to use hardware. Thanks for the quick response! |
So I got the detector rotated but I'm trying to rotate the other stuff without re-encoding. I can run one of the videos from my doorbell through ffmpeg like this and then it plays back perfect: But once I introduce ffmpeg is so powerful but man does it take a ton of trial and error to figure out. |
I finally gave up and just wrote an app that watches for the end events and then waits for the file in the clips folder to finish writing and then I use ffmpeg to rotate the image. It's instant and takes no CPU because it's only changing the metadata. Problem solved. |
@noelhibbard can you post the command you were trying with the |
@noelhibbard can you share your solution please? |
@blakeblackshear I could never get it to work in conjunction with
You would think -90 would be 90ccw. Seems backwards. Hahaha My post process isn't working well though. It's hard to know for sure if it's done writing and it's looking like events get consolidated? An integrated post process would be awesome.  |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
This is still not something easy to achieve in the latest 0.12.0beta1 version. How can one restream a rotated image? |
You didn't follow the example, you have |
Even with that correction, the logs show;
I also tried
With no log error, but no rotation |
In that case I'd recommend creating a manual go2rtc config as described in the docs and adding it there You can see an example of it here https://github.com/AlexxIT/go2rtc#source-ffmpeg |
I am already running Go2RTC and Frigate 0.11 The goal here is to eliminate the need for two docker containers. But thanks anyway. I'll continue with my current setup until Frigate is more mature and can do a simple rotation on a FFMPEG transcode. |
Go2rtc is already built into frigate 0.12, you can provide a manual config file for the embedded go2rtc per our beta docs. I have a working example of this rotation on my own setup and it's working just fine. |
Could you provide the working sample? That would be much appreciated |
I found two ways to do it, you can either follow https://deploy-preview-4055--frigate-docs.netlify.app/configuration/live#webrtc-extra-configuration to edit the embedded go2rtc config and add the stream with or you can setup frigate like: faceshot_camera_rotated:
ffmpeg:
hwaccel_args: preset-nvidia-h264
input_args:
- -avoid_negative_ts
- make_zero
- -fflags
- nobuffer
- -flags
- low_delay
- -strict
- experimental
- -fflags
- +genpts+discardcorrupt
- -use_wallclock_as_timestamps
- "1"
- -c:v
- h264_cuvid
#- hevc_cuvid
inputs:
- path: rtsp://localhost:8554/faceshot_camera_rotated
roles:
- record
- path: "ffmpeg:rtsp://admin:[email protected]:8554/live0#video=h264#rotate=90"
roles:
- restream
- path: rtsp://admin:[email protected]:8554/live1
roles:
- detect
restream:
force_audio: false |
the second method didn't work with some of my cameras due to their URL and the password escaping that is done, I'd suggest just doing it the first way |
Thanks for the help @NickM-27 , could you provide a sample for the first method? I read that page but must admit I still don't see how to set a camera there |
You said you have go2rtc setup outside frigate right? Just take that config file and follow the instructions on those docs to set the config for the built in go2rtc. Then access the camera using localhost:8554/name_set_in_config |
I did some more testing. And I get this in the logs
With the following path:
It seems like this error: "Filtering and streamcopy cannot be used together" Refers to this in the logs.
Can we, in any way, not append "#video=copy"? |
Can we create a man\faq page for this? I've faced the same exact problem for my rotated reolink camera, still struggling. I can open separate issue for that if it will be considered |
the suggestion in 0.12 is to use go2rtc to create a rotated feed instead of doing it manually in frigate |
Yea, I kinda understand but is there more details on the topic or just we should learn go2rtc by ourselves? |
there's a whole page of documentation for go2rtc on the go2rtc repo https://github.com/AlexxIT/go2rtc#source-ffmpeg |
looks easy, but wasn't for me. but I just think my hardware is struggling with transcoding. but I managed this out, thanks for great software! |
I still didn't manage to rotate the camera stream. I'm using the latest Frigate in HT with this configuration: go2rtc: cameras: |
@mizarmess you need to do it all in one stanza or put the first part as a different stream. Go2rtc is serving you the normal stream |
Yes, true, thnx @NickM-27 you were right. I put it as a different stream and in the other one pointed to the first and it worked: `go2rtc: cameras: Thnx a lot, I lost a day on this :D |
@NickM-27 for my case I got rotated stream highly unstable. which repo I should report it? here or go2rtc? I'm not sure beacuse "manually" stream loads ok and work, but at some point frigate stops recording (while keeping detection from low res rotated substream) |
Sounds like you should report it here so we can see your config. |
Yes, is unstable also for me. I tried to test it and it seems when I restart Frigate the stream loads and after a while it starts getting errors. Here is my log:
....... and so on the same error Here is my config again:
|
if you have hwaccel I'd suggest using it, but in any case this is going to come down to the camera stream not being stable and ffmpeg not being able to handle the errors. You cut your log short so it doesn't show the actual reason for crashing |
Sorry. here is more log: 2023-04-13 14:08:52.438026779 [2023-04-13 16:08:52] watchdog.cam1 INFO : No frames received from cam1 in 20 seconds. Exiting ffmpeg... You could be right.. the camera is connected over WI-FI but I really tried with switches to get my connection stable. Maybe is not stable enough for ffmpeg but without go2rtc works fine. |
I'll try hacking some more. I'll setup two "cameras" - one for original stream and one for rotated stream and check how they perform. At the moment only comparison clue I have - is other camera (same camera model, same network, same go2rtc, frigate - but no rotation, work great). Will open a new issue as soon as I gather some clues |
Okay, I did some more testing, results not worth separate issue as for me, so posting here. Turns out that problem is with streams, yes, but the reason are not cameras themselves (although I have timeouts for sure, but frigate\go2rtc handle them pretty well) but the ffmpeg process. Seems, that my hardware struggles just enough while rotating single 4k stream (and smaller substream) so this lead to system overload and makes ffmpeg not catching up to the stream. This did cause multiple types of problems, like stream starting too long, stream disruption, EOFs, segments order instability and other funny logs I saw I lowered the sysyem load - lowered numbers of CPU detectors, switched to ext streams instead of mains for detection (yeah, yeah, don't tell me), tried to enable hwaccell where possible. LA becomes manageble low and I see no rotated stream disruption for the night. Still see timeouts in logs - but they don't cause any problems for recording\detections, as overloaded ffmpeg did. Now I'll assess the overall performance with new settings |
Is there any way to use go2rtc with hwaccel? Didn't work for me, if i need a stream rotated i have to disable it: hwaccel_args: -c:v go2rtc: Ramp: |
You can do it manually, what error did you get using hardware? |
For future reference to others bumping into this.. I've got a rotated camera stream that I wanted to rotate for the detect-role only, just to improve the detection reliability. I ended up with the following config that will rotate the detect role stream only, using hardware encoding on my integrated AMD Ryzen 5700g GPU. Note that the
|
you can't request rotation and have |
Describe the bug
I have used the following output_arg to rotate the image of one of my cams, but I get error messages and a green screen for my camera. I have also tried inverting (swapping height and width 1080*1920)
rtmp: -vf transpose=2 -f -rawvideo -pix_fmt yuv420p
and have tried:
rtmp: -vf transpose=1 -r 5 -f rawvideo -pix_fmt yuv420p
Version of frigate
0.8.4-5043040
Config file
Frigate container logs
Frigate stats
FFprobe from your camera
Run the following command and paste output below
Screenshots
If applicable, add screenshots to help explain your problem.
Computer Hardware
Camera Info:
Additional context

The camera works fine when I remove the output_args to attempt to rotate the image to accommodate portrait view. See screen shot.
The text was updated successfully, but these errors were encountered: