From 73d9effd3b4ac9095455934b05150646423ca2ea Mon Sep 17 00:00:00 2001 From: Galen Lynch Date: Tue, 19 Nov 2024 16:18:51 -0800 Subject: [PATCH 1/3] Change gray online encoding string again --- docs/articles/data_formats/video.rst | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/docs/articles/data_formats/video.rst b/docs/articles/data_formats/video.rst index d2fc210f..1ec97140 100644 --- a/docs/articles/data_formats/video.rst +++ b/docs/articles/data_formats/video.rst @@ -68,13 +68,17 @@ or ``gray``. For color videos, the input arguments might need to be altered to match the color space of the input. - - output arguments: ``-vf "scale=out_color_matrix=bt709:out_range=full" -c:v h264_nvenc -pix_fmt nv12 -color_range full -colorspace bt709 -color_trc linear -tune hq -preset p4 -rc vbr -cq 12 -b:v 0M -metadata author="Allen Institute for Neural Dynamics" -maxrate 700M -bufsize 350M`` + - output arguments: ``-vf "scale=out_color_matrix=bt709:out_range=full,format=bgr24,scale=out_range=full" -c:v h264_nvenc -pix_fmt yuv420p -color_range full -colorspace bt709 -color_trc linear -tune hq -preset p4 -rc vbr -cq 12 -b:v 0M -metadata author="Allen Institute for Neural Dynamics" -maxrate 700M -bufsize 350M`` - input_arguments: ``-colorspace bt709 -color_primaries bt709 -color_range full -color_trc linear`` and the following encoding codec string for offline re-encoding (optimized for quality and size): - output arguments: ``-vf "scale=out_color_matrix=bt709:out_range=full:sws_dither=none,format=yuv420p10le,colorspace=ispace=bt709:all=bt709:dither=none,scale=out_range=tv:sws_dither=none,format=yuv420p" -c:v libx264 -preset veryslow -crf 18 -pix_fmt yuv420p -metadata author="Allen Institute for Neural Dynamics" -movflags +faststart+write_colr`` +For higher bitdepth (more than eight) recordings, change the output arguments of the online encoding to be as follows: + - output arguments: ``-vf "scale=out_color_matrix=bt709:out_range=full,format=rgb48le,scale=out_range=full" -c:v h264_nvenc -pix_fmt yuv420p -color_range full -colorspace bt709 -color_trc linear -tune hq -preset p4 -rc vbr -cq 12 -b:v 0M -metadata author="Allen Institute for Neural Dynamics" -maxrate 700M -bufsize 350M`` +This is almost the same, except the intermediate color representation is 48 bits per pixel instead of 24. + Application notes ##################### From 85498238b941acab28899a6dd6b4ce3fd85f456f Mon Sep 17 00:00:00 2001 From: bruno-f-cruz <7049351+bruno-f-cruz@users.noreply.github.com> Date: Tue, 19 Nov 2024 19:42:13 -0800 Subject: [PATCH 2/3] Update default encoder string for ffmpeg --- src/aind_behavior_services/rig/__init__.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/aind_behavior_services/rig/__init__.py b/src/aind_behavior_services/rig/__init__.py index 2bf4cdb8..f7f8ca39 100644 --- a/src/aind_behavior_services/rig/__init__.py +++ b/src/aind_behavior_services/rig/__init__.py @@ -21,11 +21,11 @@ class VideoWriterFfmpeg(BaseModel): frame_rate: int = Field(default=30, ge=0, description="Encoding frame rate") container_extension: str = Field(default="mp4", description="Container extension") output_arguments: str = Field( - default='-vf "scale=out_color_matrix=bt709:out_range=full" -c:v h264_nvenc -pix_fmt nv12 -color_range full -colorspace bt709 -color_trc linear -tune hq -preset p4 -rc vbr -cq 12 -b:v 0M -metadata author="Allen Institute for Neural Dynamics" -maxrate 700M -bufsize 350M', # E501 + default='-vf "scale=out_color_matrix=bt709:out_range=full,format=bgr24,scale=out_range=full" -c:v h264_nvenc -pix_fmt yuv420p -color_range full -colorspace bt709 -color_trc linear -tune hq -preset p4 -rc vbr -cq 12 -b:v 0M -metadata author="Allen Institute for Neural Dynamics" -maxrate 700M -bufsize 350M', # E501 description="Output arguments", ) input_arguments: str = Field( - default="-v verbose -colorspace bt709 -color_primaries bt709 -color_range full -color_trc linear", + default="-colorspace bt709 -color_primaries bt709 -color_range full -color_trc linear", description="Input arguments", ) From 066a8e2b7be353d02a1b72edce5c589805b96ce1 Mon Sep 17 00:00:00 2001 From: bruno-f-cruz <7049351+bruno-f-cruz@users.noreply.github.com> Date: Tue, 19 Nov 2024 19:46:22 -0800 Subject: [PATCH 3/3] Format note and warning sections --- docs/articles/data_formats/video.rst | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/docs/articles/data_formats/video.rst b/docs/articles/data_formats/video.rst index 1ec97140..b5fa0b01 100644 --- a/docs/articles/data_formats/video.rst +++ b/docs/articles/data_formats/video.rst @@ -64,10 +64,9 @@ or - Acquire without any gamma correction - Use ``ffmpeg`` with the following encoding codec string for online encoding (optimized for compression quality and speed): - Note: this has been tested with monochrome videos with the raw pixel format - ``gray``. For color videos, the input arguments might need to be altered to - match the color space of the input. - + .. note:: + This pipeline has been designed and tested with monochrome videos with the raw pixel format ``gray``. For color videos, the arguments might need to be altered to match the color space of the input. + - output arguments: ``-vf "scale=out_color_matrix=bt709:out_range=full,format=bgr24,scale=out_range=full" -c:v h264_nvenc -pix_fmt yuv420p -color_range full -colorspace bt709 -color_trc linear -tune hq -preset p4 -rc vbr -cq 12 -b:v 0M -metadata author="Allen Institute for Neural Dynamics" -maxrate 700M -bufsize 350M`` - input_arguments: ``-colorspace bt709 -color_primaries bt709 -color_range full -color_trc linear`` @@ -75,8 +74,11 @@ and the following encoding codec string for offline re-encoding (optimized for q - output arguments: ``-vf "scale=out_color_matrix=bt709:out_range=full:sws_dither=none,format=yuv420p10le,colorspace=ispace=bt709:all=bt709:dither=none,scale=out_range=tv:sws_dither=none,format=yuv420p" -c:v libx264 -preset veryslow -crf 18 -pix_fmt yuv420p -metadata author="Allen Institute for Neural Dynamics" -movflags +faststart+write_colr`` -For higher bitdepth (more than eight) recordings, change the output arguments of the online encoding to be as follows: - - output arguments: ``-vf "scale=out_color_matrix=bt709:out_range=full,format=rgb48le,scale=out_range=full" -c:v h264_nvenc -pix_fmt yuv420p -color_range full -colorspace bt709 -color_trc linear -tune hq -preset p4 -rc vbr -cq 12 -b:v 0M -metadata author="Allen Institute for Neural Dynamics" -maxrate 700M -bufsize 350M`` +.. warning:: + + For higher bit depth (more than 8 bit) recordings, change the output arguments of the online, first stage, encoding to be as follows: + - output arguments: ``-vf "scale=out_color_matrix=bt709:out_range=full,format=rgb48le,scale=out_range=full" -c:v h264_nvenc -pix_fmt yuv420p -color_range full -colorspace bt709 -color_trc linear -tune hq -preset p4 -rc vbr -cq 12 -b:v 0M -metadata author="Allen Institute for Neural Dynamics" -maxrate 700M -bufsize 350M`` + This is almost the same, except the intermediate color representation is 48 bits per pixel instead of 24. Application notes