So in this article, we will document the setup of the video stabilization utility in the NervProj framework (inside the NervHome project). This utility will be based on the former version written in bash scripts and converted into a modern python application in the process.
$ nv_admin convert_movies --stabilize --gopro3p --normaudio
if cmd == "convert_movies": CHECK(len(params)<=3,"Unexpected number of arguments: %s" % args) stabilize=False # Should default to auto correction here: correctLens="auto" normAudio=False if "--stabilize" in params: logDEBUG("Using stabilization.") stabilize=True if "--gopro3p" in params: logDEBUG("Applying lens correction for gopro3+") correctLens="gopro3p" if "--no-lens-correction" in params: logDEBUG("Disabling lens correction") correctLens="none" if "--normaudio" in params: logDEBUG("Applying audio normalization."); normAudio=True # Before doing any video conversion we should concat the gopro files (by default): nvConcatGoproFiles(os.getcwd()) conv = nvVideoConverter(os.getcwd(), stabilize=stabilize, correctLens=correctLens, normAudio=normAudio) conv.convertMovies() return
$ nvp tools install
"vconv": { "custom_python_env": "media_env", "cmd": "${PYTHON} ${PROJECT_ROOT_DIR}/nvh/media/video_converter.py", "python_path": ["${PROJECT_ROOT_DIR}", "${NVP_ROOT_DIR}"] },
nvp vconv convert -s -n
⇒ This could be usefull to validate the video processing.
def hstack_files(self, inputs): """Generate hstack video from a list of input video files""" tools: ToolsManager = self.get_component("tools") ffmpeg = tools.get_tool_path("ffmpeg") # For now assume we only have 2 files: self.check(len(inputs) == 2, "Invalid number of input files.") # We add support here for lens correction: base_cmd = [ffmpeg, "-threads", "8"] for fname in inputs: base_cmd += ["-i", fname] base_cmd += [ "-filter_complex", "[0:v]crop=iw/2:ih:0:0[left]; [1:v]crop=iw/2:ih:ow:0[right]; [left][right]hstack", ] # Ouput file name: out_file = Path(inputs[0]) out_file = out_file.with_suffix(".hstack" + out_file.suffix) base_cmd += [out_file] logger.info("Executing command: %s", base_cmd) res, rcode, outs = self.execute(base_cmd) if not res: logger.error("hstack video generation failed with return code %d:\n%s", rcode, outs)
$ nvp vconv hsxs DSCF0066.MOV DSCF0066.x265.mkv