吾爱破解 - 52pojie.cn

 找回密码
 注册[Register]

QQ登录

只需一步,快速开始

查看: 1886|回复: 6
上一主题 下一主题
收起左侧

[其他原创] 视频文件信息补充完整并更改其文件名流程工具

[复制链接]
跳转到指定楼层
楼主
yibeijiu 发表于 2025-7-2 12:58 回帖奖励
本帖最后由 yibeijiu 于 2025-7-2 13:00 编辑

应论坛里坛友【Yeluan】需求(原帖地址:求一个能将视频文件信息补充完整并更改其文件名的工具 - 吾爱破解 - 52pojie.cn),测试了一个完整的自动提取视频文件信息补充完整并更改其文件名流程工具,需求如下,先放个工具地址:
-------------------------------------------------------------------------------------------------------
重命名脚本VideoRenamer.bat: V3_video_renamer_fixed.rar (3.68 KB, 下载次数: 12)
提取工具: MediaInfo_CLI_23.10_Windows_x64.rar (2.41 MB, 下载次数: 13)
------------------------------------------------------------------------------------------------------

网上找到的视频文件有很多都将文件名给改了的,所以我需要一个能将指定视频文件里的视频、音频相关编码提取到后将文件生成符合规范的完整资源名并将其文件名更改的工具(需要附带软件的下载链接),如:

“[超凡**2].The.Amazing.Spider-Man.2.2014.BluRay.2160p.x265.10bit.HDR.4Audio-MiniHD”

要求:
根据文件内实际信息,识别出视频是HDR的还是SDR的
根据文件内实际信息,识别出视频编码是H.264的还是H.265的
根据文件内实际信息,如视频位深度是10bit的就显示出来,如不是就不用
根据文件内实际信息,识别出音频编码及声道相关信息
(如果能识别到该文件是蓝光压制的还是流媒体下载的话,是最好的,不行的话也不强求)
-----------------------------------------------------------------------------------------------------------------
具体步骤:【1】下载MediaInfo CLI,可以解析你的视频文件信息,官方下载地址(https://mediaarea.net/en/MediaInfo/Download/Windows),直接下载链接(https://mediaarea.net/download/binary/mediainfo/23.10/MediaInfo_CLI_23.10_Windows_x64.zip)
【2】安装,解压该软件到任意文件夹(推荐:C:\MediaInfo),将 MediaInfo.exe 所在文件夹添加到系统环境变量 PATH 中(具体设置方式:A)右键"此电脑" → "属性" → "高级系统设置" → "环境变量",B)在系统变量里有path,新建,添加MediaInfo.exe 文件的所在路径,然后保存)
【3】验证是否安装成功了,命令行提示符,输入mediainfo --version,如果显示版本信息就OK了,到此第一部分准备工作结束。
【4】拖拽视频文件到脚本(VideoRenamer.bat)文件上或者双击 .bat 文件后手动输入路径运行
【5】然后工具会自动分析并显示详细的技术参数,确认后自动重命名为规范格式([视频名].年份.来源.分辨率.编码.位深度.HDR.音频信息)。


基本重要代码:
[Asm] 纯文本查看 复制代码
echo.
echo ===========================================
echo            Raw MediaInfo Output
echo ===========================================
type "!tempfile!"
echo ===========================================
echo.

REM Parse the standard MediaInfo output
set "current_section="
for /f "usebackq tokens=*" %%a in ("!tempfile!") do (
    set "line=%%a"
    
    REM Detect sections
    if "!line!"=="General" set "current_section=General"
    if "!line!"=="Video" set "current_section=Video"
    if "!line!"=="Audio" set "current_section=Audio"
    
    REM Parse General section
    if "!current_section!"=="General" (
        echo !line! | findstr /i "file size" >nul && call :parse_line "!line!" file_size
        echo !line! | findstr /i "duration" >nul && call :parse_line "!line!" duration
    )
    
    REM Parse Video section
    if "!current_section!"=="Video" (
        echo !line! | findstr /i "format" >nul && echo !line! | findstr /i "format profile" >nul || call :parse_video_format "!line!"
        echo !line! | findstr /i "width" >nul && call :parse_line "!line!" width
        echo !line! | findstr /i "height" >nul && call :parse_line "!line!" height
        echo !line! | findstr /i "bit depth" >nul && call :parse_bit_depth "!line!"
        echo !line! | findstr /i "color primaries" >nul && call :parse_line "!line!" color_primaries
        echo !line! | findstr /i "transfer characteristics" >nul && call :parse_line "!line!" transfer_char
        echo !line! | findstr /i "HDR format" >nul && call :parse_line "!line!" hdr_format
    )
    
    REM Parse Audio section
    if "!current_section!"=="Audio" (
        echo !line! | findstr /i "format" >nul && echo !line! | findstr /i "format profile" >nul || call :parse_audio_format "!line!"
        echo !line! | findstr /i "channel" >nul && call :parse_line "!line!" channels
    )
)

REM Alternative parsing method using specific queries
if "!video_codec!"=="" (
    for /f "tokens=*" %%a in ('mediainfo --Inform^="Video;%%Format%%" "!videopath!" 2^>nul') do (
        set "format=%%a"
        if /i "!format!"=="AVC" set "video_codec=x264"
        if /i "!format!"=="HEVC" set "video_codec=x265"
        if /i "!format!"=="AV1" set "video_codec=AV1"
    )
)

if "!width!"=="" (
    for /f "tokens=*" %%a in ('mediainfo --Inform^="Video;%%Width%%" "!videopath!" 2^>nul') do set "width=%%a"
)

if "!height!"=="" (
    for /f "tokens=*" %%a in ('mediainfo --Inform^="Video;%%Height%%" "!videopath!" 2^>nul') do set "height=%%a"
)

if "!bit_depth!"=="" (
    for /f "tokens=*" %%a in ('mediainfo --Inform^="Video;%%BitDepth%%" "!videopath!" 2^>nul') do (
        set "bd=%%a"
        REM Only show bit depth if it's 10 or higher
        if "!bd!" GEQ "10" if "!bd!" NEQ "" set "bit_depth=!bd!bit"
    )
)

if "!audio_format!"=="" (
    for /f "tokens=*" %%a in ('mediainfo --Inform^="Audio;%%Format%%" "!videopath!" 2^>nul') do set "audio_format=%%a"
)

if "!audio_channels!"=="" (
    for /f "tokens=*" %%a in ('mediainfo --Inform^="Audio;%%Channels%%" "!videopath!" 2^>nul') do set "audio_channels=%%a"
)

REM Also try to get channel layout for better detection
set "channel_layout="
for /f "tokens=*" %%a in ('mediainfo --Inform^="Audio;%%ChannelLayout%%" "!videopath!" 2^>nul') do set "channel_layout=%%a"

REM Check HDR information
for /f "tokens=*" %%a in ('mediainfo --Inform^="Video;%%colour_primaries%%" "!videopath!" 2^>nul') do (
    if /i "%%a"=="BT.2020" set "hdr_candidate=true"
)

for /f "tokens=*" %%a in ('mediainfo --Inform^="Video;%%transfer_characteristics%%" "!videopath!" 2^>nul') do (
    if /i "%%a"=="PQ" set "hdr_type=HDR10"
    if /i "%%a"=="HLG" set "hdr_type=HLG"
    if /i "%%a"=="SMPTE ST 2084" set "hdr_type=HDR10"
)

for /f "tokens=*" %%a in ('mediainfo --Inform^="Video;%%HDR_Format%%" "!videopath!" 2^>nul') do (
    if "%%a" NEQ "" (
        if /i "%%a"=="Dolby Vision" set "hdr_type=DV"
        if /i "%%a"=="HDR10+" set "hdr_type=HDR10+"
        if /i "%%a"=="HDR10" set "hdr_type=HDR10"
    )
)

REM Determine resolution based on height
if defined height (
    if !height! GEQ 2160 set "resolution=2160p"
    if !height! GEQ 1440 if !height! LSS 2160 set "resolution=1440p"
    if !height! GEQ 1080 if !height! LSS 1440 set "resolution=1080p"
    if !height! GEQ 720 if !height! LSS 1080 set "resolution=720p"
    if !height! GEQ 480 if !height! LSS 720 set "resolution=480p"
)

REM Process audio channels with improved detection
if defined audio_channels (
    REM Remove any decimal places and convert to integer
    for /f "tokens=1 delims=." %%a in ("!audio_channels!") do set "audio_channels=%%a"
    
    REM Check channel layout first for more accurate detection
    if defined channel_layout (
        echo !channel_layout! | findstr /i "mono" >nul && set "audio_channels_text=Mono"
        echo !channel_layout! | findstr /i "stereo" >nul && set "audio_channels_text=Stereo"
        echo !channel_layout! | findstr /i "5.1" >nul && set "audio_channels_text=5.1"
        echo !channel_layout! | findstr /i "7.1" >nul && set "audio_channels_text=7.1"
        echo !channel_layout! | findstr /i "atmos" >nul && set "audio_channels_text=Atmos"
    )
    
    REM If channel layout didn't provide info, use channel count
    if not defined audio_channels_text (
        if "!audio_channels!"=="1" set "audio_channels_text=Mono"
        if "!audio_channels!"=="2" set "audio_channels_text=Stereo"
        if "!audio_channels!"=="6" set "audio_channels_text=5.1"
        if "!audio_channels!"=="8" set "audio_channels_text=7.1"
        REM Handle other common configurations
        if "!audio_channels!"=="3" set "audio_channels_text=2.1"
        if "!audio_channels!"=="4" set "audio_channels_text=Quad"
        if "!audio_channels!"=="5" set "audio_channels_text=4.1"
        if "!audio_channels!"=="7" set "audio_channels_text=6.1"
    )
) else (
    set "audio_channels_text="
)

REM Combine audio information
if defined audio_format (
    if defined audio_channels_text (
        set "audio_info=!audio_format!.!audio_channels_text!"
    ) else (
        set "audio_info=!audio_format!"
    )
) else (
    set "audio_info=Unknown"
)

REM Analyze source type from filename
echo !filename! | findstr /i "bluray blu-ray bdrip bdremux uhd" >nul && set "source_type=BluRay"
echo !filename! | findstr /i "web-dl webdl" >nul && set "source_type=WEB-DL"
echo !filename! | findstr /i "webrip web-rip" >nul && set "source_type=WEBRip"
echo !filename! | findstr /i "hdtv hdtvrip" >nul && set "source_type=HDTV"
echo !filename! | findstr /i "dvdrip dvd-rip" >nul && set "source_type=DVDRip"
echo !filename! | findstr /i "remux" >nul && set "source_type=REMUX"

REM Try to extract movie title and year
set "movie_title="
set "movie_year="

REM Extract year and title from filename
for /f "tokens=1-20 delims=._ -[](){}," %%a in ("!filename!") do (
    call :parse_bit_depth
set "input_line=%~1"
for /f "tokens=1,2* delims=:" %%x in ("!input_line!") do (
    set "value=%%y"
    REM Remove leading spaces
    for /f "tokens=* delims= " %%z in ("!value!") do (
        set "bd_value=%%z"
        REM Remove " bits" suffix if present
        set "bd_value=!bd_value: bits=!"
        set "bd_value=!bd_value:bits=!"
        REM Only set if 10 or higher
        if "!bd_value!" GEQ "10" set "bit_depth=!bd_value!bit"
    )
)
goto :eof

:check_token "%%a"
    call :check_token "%%b"
    call :check_token "%%c"
    call :check_token "%%d"
    call :check_token "%%e"
    call :check_token "%%f"
    call :check_token "%%g"
    call :check_token "%%h"
    call :check_token "%%i"
    call :check_token "%%j"
)


免费评分

参与人数 1吾爱币 +7 热心值 +1 收起 理由
苏紫方璇 + 7 + 1 欢迎分析讨论交流,吾爱破解论坛有你更精彩!

查看全部评分

本帖被以下淘专辑推荐:

发帖前要善用【论坛搜索】功能,那里可能会有你要找的答案或者已经有人发布过相同内容了,请勿重复发帖。

沙发
zhaohainuo 发表于 2025-7-2 14:17
看起来很不错的样子,谢谢分享
3#
wt5233 发表于 2025-7-2 14:29
4#
少马石 发表于 2025-7-2 15:19
5#
LOUI55 发表于 2025-7-2 15:32
学习了,谢谢。
6#
lxbmlx2022 发表于 2025-7-2 21:05
不错,谢谢分享
7#
duanliwen81 发表于 2026-9-29 14:44
工具的原理我:拖拽/输入路径 → 解析信息 → 拼装新名 → 确认后 ren 改名
您需要登录后才可以回帖 登录 | 注册[Register]

本版积分规则

返回列表

RSS订阅|小黑屋|处罚记录|联系我们|吾爱破解 - 52pojie.cn ( 京ICP备16042023号 | 京公网安备 11010502030087号 )

GMT+8, 2026-10-11 06:03

Powered by Discuz!

Copyright © 2001-2020, Tencent Cloud.

快速回复 返回顶部 返回列表