gpt4 book ai didi

linux - 如何使用 .sh 文件提取帧并设置每秒帧数

转载 作者:行者123 更新时间:2023-12-04 23:01:13 25 4
gpt4 key购买 nike

我正在尝试使用 shell 脚本文件从视频中提取特征,同时从不知道如何设置每秒帧数的视频中提取特征。

#!/bin/bash
frames_folder_path=./data
videos_folder_path=./videos
ext=mp4

mkdir "${frames_folder_path}"

for video_file_path in "${videos_folder_path}"/*."${ext}"; do
slash_and_video_file_name="${video_file_path:${#videos_folder_path}}"
slash_and_video_file_name_without_extension="${slash_and_video_file_name%.${ext}}"
video_frames_folder_path="${frames_folder_path}${slash_and_video_file_name_without_extension}";
mkdir "${video_frames_folder_path}"
ffmpeg -i "${video_file_path}" "${video_frames_folder_path}/%d.jpg"
done
我试过这段代码来提取特征。我只想每秒提取 2 帧,但它以默认帧速率每秒删除 30 帧。
如何使用 shell 脚本文件解决此问题。

最佳答案

添加 -r 2在文件路径和输出路径之间,这里 2 是每秒帧数(FPS)ffmpeg -i "${video_file_path}" "${video_frames_folder_path}/%d.jpg"用这个ffmpeg -i "${video_file_path}" -r 2 "${video_frames_folder_path}/%d.jpg"

#!/bin/bash
frames_folder_path=./data
videos_folder_path=./vid
ext=mp4

mkdir "${frames_folder_path}"

for video_file_path in "${videos_folder_path}"/*."${ext}"; do
slash_and_video_file_name="${video_file_path:${#videos_folder_path}}"
slash_and_video_file_name_without_extension="${slash_and_video_file_name%.${ext}}"
video_frames_folder_path="${frames_folder_path}${slash_and_video_file_name_without_extension}";
mkdir "${video_frames_folder_path}"
ffmpeg -i "${video_file_path}" -r 2 "${video_frames_folder_path}/%d.jpg"
done

关于linux - 如何使用 .sh 文件提取帧并设置每秒帧数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/72742331/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com