NGVideo Helper

NGVideo Helper#

Utilities for converting a neuroglancer video script to a Google Sheet and back.

The neuroglancer video_tool uses a very simple format for video scripts:

<url>
<duration>
<url>
<duration>
...

That format is simple to create, but annoying to edit.

This utility will load a video script into a Google Sheet in which each link has been converted to a JSON state and written out to a single column, with subsequent links in subsequent columns, with JSON settings aligned so that settings are easily compared across a whole row.

You can edit settings in the Google sheet, and then import them back into a video script using this utility.

Recommended Google Sheet template: https://docs.google.com/spreadsheets/d/1SC-szBtssuqMnVrNdZv9LHj4UB0rUFMwZaxeDnekA4c/edit?gid=162774670#gid=162774670

Copy that template and pass the URL of your copied sheet to this tool. Make sure your sheet is visible to “anyone with the link” and editable at least by you (via your GOOGLE_APPLICATION_CREDENTIALS).

Example usage:

SHEET_URL=https://docs.google.com/spreadsheets/d/15Q1oRLZQd1MWZOjRr_DyIkFbbhMZCSP4sbU78JXkoSM/edit?gid=162774670#gid=162774670
python ngvideo-helper script-to-sheet video_script.txt $SHEET_URL
python ngvideo-helper sheet-to-script $SHEET_URL video_script.txt

To install the neuroglancer video_tool:

pixi init selenium geckodriver pillow numpy requests tornado six google-apitools google-auth atomicwrites ffmpeg
pixi add --pypi neuroglancer

Note

This tool accepts (and produces) a non-standard format for neuroglancer video scripts which allows comments (starting with ‘#’) and blank lines. When writing to a video script, comments can be excluded with the --no-comments flag. Otherwise, you’ll have to exclude them yourself before running the neuroglancer video_tool:

pixi run python -m neuroglancer.tool.video_tool render \
    --browser firefox --no-headless --refresh-browser-timeout=10 \
    --hide-axis-lines --height=2160 --width=2160 \
    <(grep -v '^#' my-video.txt | grep -v '^$') my-video-frames

pixi run ffmpeg -r 24 -f image2 -s 2160x2160 -i my-video-frames/%07d.png \
    -vcodec libx264 -crf 25 -pix_fmt yuv420p my-video.mp4