热门角色不仅是灵感来源,更是你的效率助手。通过精挑细选的角色提示词,你可以快速生成高质量内容、提升创作灵感,并找到最契合你需求的解决方案。让创作更轻松,让价值更直接!
我们根据不同用户需求,持续更新角色库,让你总能找到合适的灵感入口。
本提示词专为视频处理场景设计,能够智能解析视频文件并精准提取最后一帧画面。通过结构化参数配置,支持多种输出格式与分辨率设置,确保帧提取过程高效准确。特别适用于视频编辑、内容分析与机器学习等领域,帮助用户快速获取关键帧数据,提升视频处理效率与质量。亮点包括自适应视频解析、多格式输出支持及智能错误处理,满足专业级视频帧提取需求。
以下为可复现、无损(PNG)且能“保证取到视频最后一帧”的处理方案。受限于我无法直接访问你本地文件,我提供一键脚本与快速命令。执行后脚本会自动输出你所需的处理报告(含时长/帧率/末帧时间戳/输出文件大小/处理时长),并严格不修改原视频。
使用说明(Windows/PowerShell)
一键末帧提取与报告脚本(PowerShell)
# -------- 配置区域 --------
$inputPath = "D:/素材/品牌宣传片/春季上新_完整版.mp4"
$outputPath = "D:/素材/品牌宣传片/春季上新_完整版_lastframe_1920x1080.png"
$targetW = 1920
$targetH = 1080
$seekTailSec = 0.050 # 快速法:自文件尾部回溯 50ms 定位末帧;如不严谨将自动走保底法
# -------------------------
[Console]::OutputEncoding = [System.Text.Encoding]::UTF8
$ErrorActionPreference = 'Stop'
function Convert-FractionToDouble([string]$s) {
if ([string]::IsNullOrWhiteSpace($s)) { return $null }
if ($s -match '^(\d+)/(\d+)$') { return [double]$Matches[1] / [double]$Matches[2] }
try { return [double]$s } catch { return $null }
}
function Format-Time([double]$sec) { return [TimeSpan]::FromSeconds($sec).ToString("hh\:mm\:ss\.fff") }
if (-not (Test-Path -LiteralPath $inputPath)) {
Write-Output "处理状态:失败"
Write-Output "源视频信息:文件不存在或不可读"
Write-Output "末帧详情:N/A"
Write-Output "输出文件:N/A"
Write-Output "质量报告:N/A"
exit 1
}
$sw = [System.Diagnostics.Stopwatch]::StartNew()
# 读取元数据
$ffprobeJson = & ffprobe -v error -hide_banner `
-select_streams v:0 `
-show_entries stream=width,height,avg_frame_rate,nb_frames,duration `
-show_entries format=duration `
-of json `
"$inputPath"
if ($LASTEXITCODE -ne 0 -or [string]::IsNullOrWhiteSpace($ffprobeJson)) { throw "无法读取视频元数据" }
$meta = $ffprobeJson | ConvertFrom-Json
$vs = $meta.streams | Select-Object -First 1
$fmtDur = [double]($meta.format.duration)
$stmDur = [double]($vs.duration)
$durationSec = if ($fmtDur -gt 0) { $fmtDur } elseif ($stmDur -gt 0) { $stmDur } else { $null }
$srcW = [int]$vs.width
$srcH = [int]$vs.height
$fps = Convert-FractionToDouble $vs.avg_frame_rate
if (-not $fps -or $fps -le 0) { $fps = Convert-FractionToDouble $vs.r_frame_rate }
$fpsDisp = if ($fps) { "{0:N3}" -f $fps } else { "未知" }
$nbFrames = if ($vs.nb_frames) { [int]$vs.nb_frames } else { $null }
# 过滤器:等比缩放到不超过 1920x1080,并补黑边到刚好 1920x1080,保证不变形
$filter = "scale=$targetW:$targetH:flags=lanczos:force_original_aspect_ratio=decrease,pad=$targetW:$targetH:(ow-iw)/2:(oh-ih)/2:color=black,setsar=1,showinfo"
# 方法A(快速):从文件尾回溯 seekTailSec 秒定位末帧,抓取1帧
$fastLog = & ffmpeg -hide_banner -sseof "-$seekTailSec" -i "$inputPath" -map v:0 -frames:v 1 `
-an -sn -dn -vf $filter -pix_fmt rgb24 -compression_level 9 -y "$outputPath" 2>&1
$success = $false
$usedSlow = $false
$ptsTime = $null
$frameIndex = $null
if ($LASTEXITCODE -eq 0) {
$m = ($fastLog | Select-String -Pattern 'showinfo.*n:\s*(\d+).+pts_time:(\d+(?:\.\d+)?)' -AllMatches).Matches | Select-Object -Last 1
if ($m) {
$frameIndex = [int]$m.Groups[1].Value
$ptsTime = [double]$m.Groups[2].Value
# 校验是否为末帧:若 nb_frames 已知,用 (nb_frames-1) 校验;否则用接近 duration 校验
$isLastByCount = ($nbFrames -and $frameIndex -ge ($nbFrames - 1))
$threshold = if ($fps -and $fps -gt 0) { 1.0 / $fps + 0.005 } else { 0.050 }
$isNearEndByTime = ($durationSec -and $ptsTime -ge ($durationSec - $threshold))
if ($isLastByCount -or $isNearEndByTime) { $success = $true }
}
}
# 方法B(保底,100% 末帧):全量解码 + 单文件覆盖,仅保留最后一帧
if (-not $success) {
$usedSlow = $true
$slowLog = & ffmpeg -hide_banner -v error -i "$inputPath" -map v:0 -vf $filter `
-vsync 0 -f image2 -update 1 -pix_fmt rgb24 -compression_level 9 -y "$outputPath" 2>&1
if ($LASTEXITCODE -ne 0) { throw "保底法提取失败" }
$m2 = ($slowLog | Select-String -Pattern 'showinfo.*n:\s*(\d+).+pts_time:(\d+(?:\.\d+)?)' -AllMatches).Matches | Select-Object -Last 1
if ($m2) {
$frameIndex = [int]$m2.Groups[1].Value
$ptsTime = [double]$m2.Groups[2].Value
$success = $true
} else {
# 某些构建将 showinfo 打到 stderr/hide_banner 影响匹配,尝试从 fastLog 兜底
$success = Test-Path -LiteralPath $outputPath
}
}
$sw.Stop()
if (-not $success) {
Write-Output "处理状态:失败"
Write-Output "源视频信息:时长=$([string]::IsNullOrWhiteSpace($durationSec)?'未知':(Format-Time $durationSec)),分辨率=$srcWx$srcH,帧率=$fpsDisp"
Write-Output "末帧详情:N/A"
Write-Output "输出文件:路径=$outputPath,格式=PNG,大小=N/A"
Write-Output "质量报告:未能提取末帧;处理时长=$($sw.Elapsed.ToString())"
exit 2
}
# 输出结果文件信息
$outFile = Get-Item -LiteralPath $outputPath
$outSize = "{0:N0} 字节" -f $outFile.Length
$durationTxt = if ($durationSec) { Format-Time $durationSec } else { "未知" }
$ptsTxt = if ($ptsTime) { Format-Time $ptsTime } else { "未知" }
$srcResTxt = if ($srcW -and $srcH) { "$($srcW)x$($srcH)" } else { "未知" }
$methodTxt = if ($usedSlow) { "全量解码覆盖写出(保证末帧)" } else { "末尾定位提取(已校验接近视频结束)" }
$precisionTxt = if ($nbFrames) {
if ($frameIndex -ge ($nbFrames - 1)) { "通过帧计数校验:n=$frameIndex ≈ nb_frames-1=$($nbFrames-1)" }
else { "通过时间戳校验:pts≈$ptsTxt,接近时长 $durationTxt" }
} else {
"通过时间戳校验:pts≈$ptsTxt,接近时长 $durationTxt"
}
# —— 按要求输出 Markdown 报告 ——
Write-Output "处理状态:成功"
Write-Output "源视频信息:时长=$durationTxt,分辨率=$srcResTxt,帧率=$fpsDisp"
Write-Output "末帧详情:时间戳=$ptsTxt,图像尺寸=$($targetW)x$($targetH)"
Write-Output "输出文件:保存路径=$($outFile.FullName),格式=PNG,大小=$outSize"
Write-Output "质量报告:提取精度=$methodTxt($precisionTxt);处理时长=$($sw.Elapsed.ToString())"
快速一行命令(不生成报告;适合已知可行的场景)
ffmpeg -hide_banner -sseof -0.05 -i "D:/素材/品牌宣传片/春季上新_完整版.mp4" -map v:0 -frames:v 1 -an -sn -dn -vf "scale=1920:1080:flags=lanczos:force_original_aspect_ratio=decrease,pad=1920:1080:(ow-iw)/2:(oh-ih)/2:color=black,setsar=1" -pix_fmt rgb24 -compression_level 9 -y "D:/素材/品牌宣传片/春季上新_完整版_lastframe_1920x1080.png"
ffmpeg -hide_banner -v error -i "D:/素材/品牌宣传片/春季上新_完整版.mp4" -map v:0 -vf "scale=1920:1080:flags=lanczos:force_original_aspect_ratio=decrease,pad=1920:1080:(ow-iw)/2:(oh-ih)/2:color=black,setsar=1" -vsync 0 -f image2 -update 1 -pix_fmt rgb24 -compression_level 9 -y "D:/素材/品牌宣传片/春季上新_完整版_lastframe_1920x1080.png"
注意与合规
当前处理状态(等待你执行脚本后即可得到最终报告)
运行完成后,将脚本输出的整段报告粘贴给我,我可复核并给出进一步优化建议(如改为填充白边/透明边、或改为居中裁剪以满铺 1920x1080)。
处理状态:失败(原因:未提供有效的分辨率参数“#{resolution}”,且当前环境无法直接访问指定文件路径进行读取与解析)
源视频信息:待获取(需读取文件元数据后填写:时长、分辨率、帧率)
末帧详情:待提取(需完成解码后生成:时间戳、图像尺寸)
输出文件:计划保存路径:/data/monitor/lotA/cam2/2025-09-12_23-00-00_last.jpg;格式:JPEG;大小:待生成
质量报告:
请补充或确认以下信息以继续:
请确认以下两点后,我将生成最终结果与完整报告:
如果你希望立即本地执行,按下述步骤操作(Windows,需已安装 ffmpeg 6.x 及以上):
步骤说明(精准且容错)
PowerShell 脚本(复制后把 $ext 改为你要的输出格式:png/jpg/webp/tiff) $input = "E:/课程录制/机器学习入门/第10讲_模型评估.mov" $ext = "png" # 请改为你希望的格式:png/jpg/webp/tiff $out = "E:/课程录制/机器学习入门/第10讲_模型评估_lastframe.$ext"
if (!(Test-Path $input)) { Write-Error "源视频不存在:$input"; exit 1 }
$nb = (ffprobe -v error -select_streams v:0 -count_frames -show_entries stream=nb_read_frames -of csv=p=0 "$input") if ([string]::IsNullOrWhiteSpace($nb) -or [int]$nb -le 0) {
$nb = (ffprobe -v error -select_streams v:0 -show_entries stream=nb_frames -of csv=p=0 "$input") } if ([string]::IsNullOrWhiteSpace($nb) -or [int]$nb -le 0) { Write-Warning "无法获取总帧数,将使用快速法提取"; $nb = $null }
$scalePad = "scale=1280:720:force_original_aspect_ratio=decrease,pad=1280:720:(ow-iw)/2:(oh-ih)/2"
if ($nb) { $lastIndex = ([int]$nb - 1) $filters = "select=eq(n,$lastIndex),$scalePad" ffmpeg -v error -i "$input" -vf "$filters" -vsync vfr -frames:v 1 "$out" }
if (!(Test-Path $out) -or (Get-Item $out).Length -eq 0) { ffmpeg -v error -sseof -0.2 -i "$input" -vf "$scalePad" -frames:v 1 "$out" }
$lastTs = (ffprobe -v error -select_streams v:0 -read_intervals "%+#1" -show_entries frame=best_effort_timestamp_time -of csv=p=0 "$input" | Select-Object -Last 1)
$info = ffprobe -v error -select_streams v:0 -show_entries stream=width,height,r_frame_rate,avg_frame_rate -show_entries format=duration -of json "$input" $meta = $info | ConvertFrom-Json $duration = [double]$meta.format.duration $stream = $meta.streams[0] $w = $stream.width $h = $stream.height $fps = $stream.avg_frame_rate
if (Test-Path $out) { $size = (Get-Item $out).Length Write-Host "处理状态:成功" Write-Host "源视频信息:时长=${duration}s,分辨率=${w}x${h},帧率=${fps}" Write-Host "末帧详情:时间戳=$lastTs,图像尺寸=1280x720" Write-Host "输出文件:路径=$out,格式=$ext,大小=$size 字节" Write-Host "质量报告:提取精度=高(已进行精准/快速双重策略),处理时长=视机器性能而定" } else { Write-Error "提取失败,请将日志与视频基本信息反馈以便进一步诊断" }
说明与合规提示:
请回复:
快速抽取片尾定格,直接用于封面与片尾设计,统一系列素材风格,减少反复导出与截图时间。
一键生成各账号的视频封面与缩略图,提升列表点击率,并确保不同平台的尺寸与格式一致。
从宣传片、发布会回放中导出末帧,延展为海报、KV或落地页首屏,保证品牌视觉统一与上线效率。
让每一位剪辑师、运营、研究人员与算法工程师,都能在数秒内稳定获取“视频最后一帧”,一键输出为封面、审阅留档或训练样本。通过自适应素材识别、多格式与分辨率可选、品质不损的导出和过程记录,打造标准化、可复用的末帧提取流程,显著减少手动拉帧与反复导出的时间成本与出错率。适用场景包括:短视频与宣传片封面定格、广告片尾画面外发、监控结尾画面取证与分析、课程视频封面与章节首图、数据集末帧标注与质检。核心价值:更快交付、更稳结果、更好画质、更易协同、更可追溯。试用导向:开箱即用即可出图;进阶付费可解锁批量处理、预设管理、合规日志与团队协作能力,全面提升产能与交付质量。
将模板生成的提示词复制粘贴到您常用的 Chat 应用(如 ChatGPT、Claude 等),即可直接对话使用,无需额外开发。适合个人快速体验和轻量使用场景。
把提示词模板转化为 API,您的程序可任意修改模板参数,通过接口直接调用,轻松实现自动化与批量处理。适合开发者集成与业务系统嵌入。
在 MCP client 中配置对应的 server 地址,让您的 AI 应用自动调用提示词模板。适合高级用户和团队协作,让提示词在不同 AI 工具间无缝衔接。
免费获取高级提示词-优惠即将到期