AllenNeuralDynamics / dynamic-foraging-task

Bonsai/Harp workflow for Dynamic Foraging with Python GUI for visualization and control
MIT License
5 stars 4 forks source link

High speed cameras generate warning about unused codec option #588

Open alexpiet opened 2 months ago

alexpiet commented 2 months ago

02:10:24 PM:INFO:Foraging:Foraging.py:log_subprocess_output:line 4288:BONSAI: [out#0/avi @ 0000013ff6d2af00] Codec AVOption crf (Select the quality for constant quality mode) has not been used for any stream. The most likely reason is either wrong type (e.g. a video option with no video streams) or that it is a private option of some encoder which was not actually used for any stream.

I checked, and the logs include this warning before the recent addition of the -v 24 verbose option, it was just getting buried in other information. This message appears twice, once for each camera. It appears whether I pressed "preview" or "record"

This is the codec in Settings_box1.csv codec,-vcodec h264_nvenc -crf 23 -preset fast -b:v 50M

I dont know what -crf 23 does, or if it matters. @XX-Yin @ZhixiaoSu

alexpiet commented 1 month ago

@ZhixiaoSu @XX-Yin Can you investigate this?

ZhixiaoSu commented 1 month ago

In cpu compression, -crf 23 controls the compression level, the larger the number, the higher the compression. But as we switched to gpu compression, we should change the flag to -rc vbr -cq 23. I got the same error when using -crf locally.

ZhixiaoSu commented 1 month ago

I attempted to test different codecs, but the codec in video writer doesn't seem to update according to the one in box settings. @XX-Yin Is there a different location I should check to update the codec?

XX-Yin commented 1 month ago

There are four boxes. I assume that you changed the right Settings_box#.csv?

alexpiet commented 1 month ago

Might be obvious - but you need to close the GUI after changing the codec, you can't just start/stop the camera.

ZhixiaoSu commented 1 month ago

@XX-Yin Yes, I change the one in setting folder. For 446, each computer only has one settings file, so it's hard to be wrong. And, yes, @alexpiet I restarted the GUI together with Bonsai and check the codecs after restarting. The parameter I tested with was bitrate, changing the number to 25M in csv file didn't change the one in bonsai.

ZhixiaoSu commented 1 month ago

I just figured out why: since the cameras are in restart loggers, the codec doesn’t update until we trigger the camera. After triggering, the codec gets updated.

XX-Yin commented 1 month ago

[like] Xinxin Yin reacted to your message:


From: ZhixiaoSu @.> Sent: Friday, July 19, 2024 2:26:16 AM To: AllenNeuralDynamics/dynamic-foraging-task @.> Cc: Xinxin Yin @.>; Mention @.> Subject: Re: [AllenNeuralDynamics/dynamic-foraging-task] High speed cameras generate warning about unused codec option (Issue #588)

I just figured out why: since the cameras are in restart loggers, the codec doesn’t update until we trigger the camera. After triggering, the codec get updated.

— Reply to this email directly, view it on GitHubhttps://github.com/AllenNeuralDynamics/dynamic-foraging-task/issues/588#issuecomment-2237943964, or unsubscribehttps://github.com/notifications/unsubscribe-auth/A2CTX5XF5T5ECGXT3XU5AY3ZNB2MRAVCNFSM6AAAAABKKLD24OVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDEMZXHE2DGOJWGQ. You are receiving this because you were mentioned.Message ID: @.***>

ZhixiaoSu commented 1 month ago

I tested '-rc vbr -cq 23' on 6A and 6B, it worked well without warnings. I'll check the video quality of 6A, which still has this codec now. If it looks ok, let's update all the codecs.

XX-Yin commented 1 month ago

Hi @ZhixiaoSu, looks great! Can you also check if the video quality/size changes with the -cq value?

ZhixiaoSu commented 1 month ago

It should in theory, as it has similar functions as -crf in cpu codec. Let me check it with a real mouse there.

ZhixiaoSu commented 1 month ago

Videos look ok, @mlee10201 will help update the codecs this week (week of 7/29).

alexpiet commented 1 month ago

We should make a PR to change the settings template file so all the rigs use the same codec. @mlee10201 share the final codec you used.

galenlynch commented 1 month ago

Is this the same codec as the one Bruno was recommending?

mlee10201 commented 1 month ago

codec,-vcodec h264_nvenc -rc vbr -cq 23 -preset fast -b:v 50M -v 24 this is what it's been updated to

ZhixiaoSu commented 1 month ago

Let’s also include sound attenuation in the settings. I can add it this week.