<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>Tool on Mental Studio</title>
    <link>https://we8log.com/mental/tags/tool/</link>
    <description>Recent content in Tool on Mental Studio</description>
    <generator>Hugo -- gohugo.io</generator>
    <language>zh</language>
    <copyright>CC 4.0 BY</copyright>
    <lastBuildDate>Sat, 18 Apr 2026 17:40:38 +0800</lastBuildDate>
    <atom:link href="https://we8log.com/mental/tags/tool/index.xml" rel="self" type="application/rss+xml" />
    <item>
      <title>视频处理工具</title>
      <link>https://we8log.com/mental/post/26040/</link>
      <pubDate>Sat, 18 Apr 2026 17:40:38 +0800</pubDate>
      <guid>https://we8log.com/mental/post/26040/</guid>
      <description>需求 以前我是很少拍视频的，主要是拍照，但是自从买了DJI的Action4和Neo2以后，视频内容就多了，转换视频的需求也多了。&#xA;GUI工具固然好用，但是操作麻烦效率低下，我需要的功能也没那么复杂，通常就是转个码率分辨率（便于网上发），或者裁剪一下什么的，ffmpeg足矣。&#xA;但是用过ffmpeg的人都知道，这玩意儿功能是强大，但是命令行参数也是复杂得一笔，为了省事，我把常用的几个操作都写成shell脚本，时间一长就积累了一堆脚本，用起来也还是不方便。&#xA;解决 这几天一怒之下拿AI把这些脚本整合成一个，于是有这个工具脚本：&#xA;#!/bin/bash # mp4tool.sh - 视频处理多功能工具 # 用法: mp4tool.sh [选项] 输入文件 # 选项: # -b 码率 指定视频码率 (如 1500K, 3M) # -s 分辨率 缩放分辨率 (720p/1080p/2160p/4k)，仅缩小不放大 # -f 修复模式，使用copy方式不重新编码 # -cpu 强制使用CPU编码，默认使用GPU # -dji DJI模式，使用轨道映射，默认码率*4 # -t 竖屏转横屏（可选p参数，如-tp则填充16:9） # -cs 时间 开头剪辑位置（秒数或HH:MM:SS格式） # -ce 时间 结尾剪辑位置（秒数或HH:MM:SS格式，时间格式表示结束点位置） # -p 后缀 输出文件后缀，默认为 &amp;#34;out&amp;#34; # -af 音频文件 指定外部音频文件作为视频音轨 # 默认值 BITRATE=&amp;#34;&amp;#34; SCALE=&amp;#34;&amp;#34; FIX_MODE=false USE_CPU=false DJI_MODE=false TRANSPOSE_MODE=&amp;#34;&amp;#34; CUT_START=0 CUT_END=0 SUFFIX=&amp;#34;out&amp;#34; INPUT=&amp;#34;&amp;#34; CUT_END_ARG=&amp;#34;&amp;#34; AUDIO_FILE=&amp;#34;&amp;#34; # 将时间字符串转换为秒数 # 支持格式：纯数字（秒）、SS、MM:SS、HH:MM:SS parse_time() { local time_str=&amp;#34;$1&amp;#34; # 检查是否包含冒号 if [[ &amp;#34;$time_str&amp;#34; == *&amp;#34;:&amp;#34;* ]]; then # 时间格式，解析 HH:MM:SS 或 MM:SS local IFS=&amp;#39;:&amp;#39; read -ra parts &amp;lt;&amp;lt;&amp;lt; &amp;#34;$time_str&amp;#34; local seconds=0 local multiplier=1 # 从后往前处理 for (( i=${#parts[@]}-1; i&amp;gt;=0; i-- )); do seconds=$(( seconds + ${parts[i]} * multiplier )) multiplier=$(( multiplier * 60 )) done echo &amp;#34;$seconds&amp;#34; else # 纯数字，直接返回秒数 echo &amp;#34;$time_str&amp;#34; fi } # 解析参数 while [[ $# -gt 0 ]]; do case $1 in -b) BITRATE=&amp;#34;$2&amp;#34; BITRATE_SPECIFIED=true shift 2 ;; -s) SCALE=&amp;#34;$2&amp;#34; shift 2 ;; -f) FIX_MODE=true shift ;; -cpu) USE_CPU=true shift ;; -dji) DJI_MODE=true shift ;; -tp) TRANSPOSE_MODE=&amp;#34;pad&amp;#34; shift ;; -t) TRANSPOSE_MODE=&amp;#34;rotate&amp;#34; shift ;; -cs) CUT_START=$(parse_time &amp;#34;$2&amp;#34;) shift 2 ;; -ce) CUT_END_ARG=&amp;#34;$2&amp;#34; shift 2 ;; -af) AUDIO_FILE=&amp;#34;$2&amp;#34; shift 2 ;; -p) SUFFIX=&amp;#34;$2&amp;#34; shift 2 ;; *) INPUT=&amp;#34;$1&amp;#34; shift ;; esac done # 检查输入文件 if [ -z &amp;#34;$INPUT&amp;#34; ]; then echo &amp;#34;用法: mp4tool.</description>
    </item>
  </channel>
</rss>
