newtranx CLI (newtranx)
Translate videos and podcasts from the terminal using the newtranx API.
Installation
CODEBLOCK0
Usage Process
1. login
CODEBLOCK1
Automatically obtain device ID, call the registration login interface to obtain token, and save it to ~/. newtranx/config. json . The token is valid for 15 days.
2. Upload videos
Supports local files and HTTP URLs, only supports mp4 format. If the format is not supported, please use ffmepg to transcode to mp4 file size not exceeding 5GB and duration not exceeding 4 hours.
Important: URLs containing ? or & must be quoted to avoid shell glob errors.
CODEBLOCK2
Restrictions:
-Format: mp4 only
-Size: not exceeding 5GB
Automatically upload videos in 4MB chunks and display upload progress. After uploading, output the task ID.
3. Submit translation task
CODEBLOCK3
Parameter description:
- -
--id (Required): Upload the returned task ID - INLINECODE3 (Required): Call the
npx newtranx-ai language command in the original language of the video to view - INLINECODE5 (Required): Call the
npx newtranx-ai language command to view the target translation language - INLINECODE7 : Number of speakers
- INLINECODE8 : Do you want to merge subtitles into the video
- INLINECODE9 : Do you want to rewrite it
- INLINECODE10 : Subtitle Font Size
- INLINECODE11 : Maximum number of characters per subtitle segment
- INLINECODE12 : Subtitle outline color
- INLINECODE13 : Subtitle main color
4. Regularly query query results
CODEBLOCK4
When 'iterationStatus==Succeeded', the result contains:
- - Translated video download link
- Source language subtitle file link
- Target language subtitle file link
- Metadata file link
5. Query supported languages
CODEBLOCK5
Return a list of language codes and names that can be used for the audio lang and trans lang parameters of the translate command.
Usage Tips
- 1. If the token expires, call
npx newtranx ai login and then retry. - It must be called according to the process.
newtranx CLI (newtranx)
使用newtranx API从终端翻译视频和播客。
安装
bash
npx --yes newtranx-ai
使用流程
1. 登录
bash
npx newtranx-ai login
自动获取设备ID,调用注册登录接口获取令牌,并保存至~/.newtranx/config.json。令牌有效期为15天。
2. 上传视频
支持本地文件和HTTP URL,仅支持mp4格式。若格式不支持,请使用ffmpeg转码为mp4。文件大小不超过5GB,时长不超过4小时。
重要提示:包含?或&的URL必须加引号,以避免shell通配符错误。
bash
npx newtranx-ai upload ./video.mp4
HTTP URL
npx newtranx-ai upload https://example.com/video.mp4
限制条件:
自动以4MB分块上传视频并显示上传进度。上传完成后输出任务ID。
3. 提交翻译任务
bash
npx newtranx-ai translate --id \
--audio-lang en-US \
--trans-lang zh-CN \
--max-speakers 2 \
--export-subtitle
参数说明:
- - --id(必填):上传返回的任务ID
- --audio-lang(必填):视频原始语言,调用npx newtranx-ai language命令查看
- --trans-lang(必填):目标翻译语言,调用npx newtranx-ai language命令查看
- --max-speakers:说话人数
- --export-subtitle:是否将字幕合并到视频中
- --re-transwrite:是否重新改写
- --subtitle-font-size:字幕字体大小
- --subtitle-max-chars:每段字幕最大字符数
- --subtitle-outline-color:字幕轮廓颜色
- --subtitle-primary-color:字幕主色
4. 定期查询结果
bash
默认输出翻译后视频下载链接
npx newtranx-ai status --id
输出原始VTT字幕下载链接
npx newtranx-cli status --id --subtitle
输出翻译后VTT字幕下载链接
npx newtranx-cli status --id --targetSubtitle
输出包含说话人信息的元数据下载链接
npx newtranx-cli status --id --metadata
当iterationStatus==Succeeded时,结果包含:
- - 翻译后视频下载链接
- 源语言字幕文件链接
- 目标语言字幕文件链接
- 元数据文件链接
5. 查询支持的语言
bash
npx newtranx-ai language
npx newtranx-ai language --region CN
返回可用于translate命令的audio-lang和trans-lang参数的语言代码和名称列表。
使用提示
- 1. 如果令牌过期,调用npx newtranx-ai login后重试。
- 必须按流程顺序调用。