标题: [其他] ffmpeg分割如何强制插入关键帧 [打印本页]
作者: xp3000 时间: 2021-4-9 12:14 标题: ffmpeg分割如何强制插入关键帧
视频关键帧缺少,如果片段小,切割视频后会一片漆黑只有声音,
用ffmpeg分割,安时间段提取视频,但是会出现不一样的结果,不知道哪里问题
比如下面,想提取每一秒的视频,但是变成开头部分到每一秒的视频- @echo off & setlocal enabledelayedexpansion
- title ffmpeg间隔1秒分割视频
- for %%i in (*.avi *.mkv *.mp4 *.flv) do (md "%%~ni"
- for /f "tokens=2-5delims=:., " %%a in ('ffmpeg -i "%%i" 2^>^&1 ^| find "Duration:"') do (
- set /a t=%%a*3600+%%b*60+%%c
- echo 视频长度!t!秒,将分割!t!个文件
- pause
-
- for /l %%j in (1 1 !t!) do (set T=%%j&set/a TT=!T!-1
- set /a hh=!TT!/3600
- set /a mm=!TT!%%3600/60
- set /a ss=!TT!%%60
- set hh=00!h!
- set mm=00!m!
- set ss=00!s!
-
- set /a h=!T!/3600
- set /a m=!T!%%3600/60
- set /a s=!T!%%60
- set h=00!h!
- set m=00!m!
- set s=00!s!
- ffmpeg -ss !hh:~-2!:!mm:~-2!:!ss:~-2!.000 -t !h:~-2!:!m:~-2!:!s:~-2!.000 -accurate_seek -i "%%i" -codec copy -avoid_negative_ts 1 "%~dp0%%~ni\!t!%%~xi"
- )
- )
- )
- pause
复制代码
链接:https://pan.xunlei.com/s/VMXoikqkVYJldEFdNZ-GSk52A1
提取码:bf3e
有没有办法直接在视频上设置关键帧?比如每个片段大于120帧就平均分割,在1秒处强制设置一个关键帧,或外部导入一张透明的PNG作为关键帧
作者: xp3000 时间: 2021-4-9 12:22
- ffmpeg -ss 00:00:00.000 -t 00:00:01.000 -accurate_seek -i "南极之恋.mp4" -codec copy -avoid_negative_ts 1 "D:\搞笑视频\南极之恋\1.mp4"
- ffmpeg -ss 00:00:01.000 -t 00:00:02.000 -accurate_seek -i "南极之恋.mp4" -codec copy -avoid_negative_ts 1 "D:\搞笑视频\南极之恋\2.mp4"
- ffmpeg -ss 00:00:02.000 -t 00:00:03.000 -accurate_seek -i "南极之恋.mp4" -codec copy -avoid_negative_ts 1 "D:\搞笑视频\南极之恋\3.mp4"
- ffmpeg -ss 00:00:03.000 -t 00:00:04.000 -accurate_seek -i "南极之恋.mp4" -codec copy -avoid_negative_ts 1 "D:\搞笑视频\南极之恋\4.mp4"
- ffmpeg -ss 00:00:04.000 -t 00:00:05.000 -accurate_seek -i "南极之恋.mp4" -codec copy -avoid_negative_ts 1 "D:\搞笑视频\南极之恋\5.mp4"
- ffmpeg -ss 00:00:05.000 -t 00:00:06.000 -accurate_seek -i "南极之恋.mp4" -codec copy -avoid_negative_ts 1 "D:\搞笑视频\南极之恋\6.mp4"
- ffmpeg -ss 00:00:06.000 -t 00:00:07.000 -accurate_seek -i "南极之恋.mp4" -codec copy -avoid_negative_ts 1 "D:\搞笑视频\南极之恋\7.mp4"
- ffmpeg -ss 00:00:07.000 -t 00:00:08.000 -accurate_seek -i "南极之恋.mp4" -codec copy -avoid_negative_ts 1 "D:\搞笑视频\南极之恋\8.mp4"
- ffmpeg -ss 00:00:08.000 -t 00:00:09.000 -accurate_seek -i "南极之恋.mp4" -codec copy -avoid_negative_ts 1 "D:\搞笑视频\南极之恋\9.mp4"
- ffmpeg -ss 00:00:09.000 -t 00:00:10.000 -accurate_seek -i "南极之恋.mp4" -codec copy -avoid_negative_ts 1 "D:\搞笑视频\南极之恋\10.mp4"
- ffmpeg -ss 00:00:10.000 -t 00:00:11.000 -accurate_seek -i "南极之恋.mp4" -codec copy -avoid_negative_ts 1 "D:\搞笑视频\南极之恋\11.mp4"
- ffmpeg -ss 00:00:11.000 -t 00:00:12.000 -accurate_seek -i "南极之恋.mp4" -codec copy -avoid_negative_ts 1 "D:\搞笑视频\南极之恋\12.mp4"
- ffmpeg -ss 00:00:12.000 -t 00:00:13.000 -accurate_seek -i "南极之恋.mp4" -codec copy -avoid_negative_ts 1 "D:\搞笑视频\南极之恋\13.mp4"
- ffmpeg -ss 00:00:13.000 -t 00:00:14.000 -accurate_seek -i "南极之恋.mp4" -codec copy -avoid_negative_ts 1 "D:\搞笑视频\南极之恋\14.mp4"
- ffmpeg -ss 00:00:14.000 -t 00:00:15.000 -accurate_seek -i "南极之恋.mp4" -codec copy -avoid_negative_ts 1 "D:\搞笑视频\南极之恋\15.mp4"
- ffmpeg -ss 00:00:15.000 -t 00:00:16.000 -accurate_seek -i "南极之恋.mp4" -codec copy -avoid_negative_ts 1 "D:\搞笑视频\南极之恋\16.mp4"
- ffmpeg -ss 00:00:16.000 -t 00:00:17.000 -accurate_seek -i "南极之恋.mp4" -codec copy -avoid_negative_ts 1 "D:\搞笑视频\南极之恋\17.mp4"
- ffmpeg -ss 00:00:17.000 -t 00:00:18.000 -accurate_seek -i "南极之恋.mp4" -codec copy -avoid_negative_ts 1 "D:\搞笑视频\南极之恋\18.mp4"
- ffmpeg -ss 00:00:18.000 -t 00:00:19.000 -accurate_seek -i "南极之恋.mp4" -codec copy -avoid_negative_ts 1 "D:\搞笑视频\南极之恋\19.mp4"
- ffmpeg -ss 00:00:19.000 -t 00:00:20.000 -accurate_seek -i "南极之恋.mp4" -codec copy -avoid_negative_ts 1 "D:\搞笑视频\南极之恋\20.mp4"
- ffmpeg -ss 00:00:20.000 -t 00:00:21.000 -accurate_seek -i "南极之恋.mp4" -codec copy -avoid_negative_ts 1 "D:\搞笑视频\南极之恋\21.mp4"
- ffmpeg -ss 00:00:21.000 -t 00:00:22.000 -accurate_seek -i "南极之恋.mp4" -codec copy -avoid_negative_ts 1 "D:\搞笑视频\南极之恋\22.mp4"
- ffmpeg -ss 00:00:22.000 -t 00:00:23.000 -accurate_seek -i "南极之恋.mp4" -codec copy -avoid_negative_ts 1 "D:\搞笑视频\南极之恋\23.mp4"
- ffmpeg -ss 00:00:23.000 -t 00:00:24.000 -accurate_seek -i "南极之恋.mp4" -codec copy -avoid_negative_ts 1 "D:\搞笑视频\南极之恋\24.mp4"
- ffmpeg -ss 00:00:24.000 -t 00:00:25.000 -accurate_seek -i "南极之恋.mp4" -codec copy -avoid_negative_ts 1 "D:\搞笑视频\南极之恋\25.mp4"
- ffmpeg -ss 00:00:25.000 -t 00:00:26.000 -accurate_seek -i "南极之恋.mp4" -codec copy -avoid_negative_ts 1 "D:\搞笑视频\南极之恋\26.mp4"
- ffmpeg -ss 00:00:26.000 -t 00:00:27.000 -accurate_seek -i "南极之恋.mp4" -codec copy -avoid_negative_ts 1 "D:\搞笑视频\南极之恋\27.mp4"
- ffmpeg -ss 00:00:27.000 -t 00:00:28.000 -accurate_seek -i "南极之恋.mp4" -codec copy -avoid_negative_ts 1 "D:\搞笑视频\南极之恋\28.mp4"
- ffmpeg -ss 00:00:28.000 -t 00:00:29.000 -accurate_seek -i "南极之恋.mp4" -codec copy -avoid_negative_ts 1 "D:\搞笑视频\南极之恋\29.mp4"
- ffmpeg -ss 00:00:29.000 -t 00:00:30.000 -accurate_seek -i "南极之恋.mp4" -codec copy -avoid_negative_ts 1 "D:\搞笑视频\南极之恋\30.mp4"
- ffmpeg -ss 00:00:30.000 -t 00:00:31.000 -accurate_seek -i "南极之恋.mp4" -codec copy -avoid_negative_ts 1 "D:\搞笑视频\南极之恋\31.mp4"
- ffmpeg -ss 00:00:31.000 -t 00:00:32.000 -accurate_seek -i "南极之恋.mp4" -codec copy -avoid_negative_ts 1 "D:\搞笑视频\南极之恋\32.mp4"
- ffmpeg -ss 00:00:32.000 -t 00:00:33.000 -accurate_seek -i "南极之恋.mp4" -codec copy -avoid_negative_ts 1 "D:\搞笑视频\南极之恋\33.mp4"
- ffmpeg -ss 00:00:33.000 -t 00:00:34.000 -accurate_seek -i "南极之恋.mp4" -codec copy -avoid_negative_ts 1 "D:\搞笑视频\南极之恋\34.mp4"
- ffmpeg -ss 00:00:34.000 -t 00:00:35.000 -accurate_seek -i "南极之恋.mp4" -codec copy -avoid_negative_ts 1 "D:\搞笑视频\南极之恋\35.mp4"
- ffmpeg -ss 00:00:35.000 -t 00:00:36.000 -accurate_seek -i "南极之恋.mp4" -codec copy -avoid_negative_ts 1 "D:\搞笑视频\南极之恋\36.mp4"
- ffmpeg -ss 00:00:36.000 -t 00:00:37.000 -accurate_seek -i "南极之恋.mp4" -codec copy -avoid_negative_ts 1 "D:\搞笑视频\南极之恋\37.mp4"
- ffmpeg -ss 00:00:37.000 -t 00:00:38.000 -accurate_seek -i "南极之恋.mp4" -codec copy -avoid_negative_ts 1 "D:\搞笑视频\南极之恋\38.mp4"
- ffmpeg -ss 00:00:38.000 -t 00:00:39.000 -accurate_seek -i "南极之恋.mp4" -codec copy -avoid_negative_ts 1 "D:\搞笑视频\南极之恋\39.mp4"
- ffmpeg -ss 00:00:39.000 -t 00:00:40.000 -accurate_seek -i "南极之恋.mp4" -codec copy -avoid_negative_ts 1 "D:\搞笑视频\南极之恋\40.mp4"
- ffmpeg -ss 00:00:40.000 -t 00:00:41.000 -accurate_seek -i "南极之恋.mp4" -codec copy -avoid_negative_ts 1 "D:\搞笑视频\南极之恋\41.mp4"
- ffmpeg -ss 00:00:41.000 -t 00:00:42.000 -accurate_seek -i "南极之恋.mp4" -codec copy -avoid_negative_ts 1 "D:\搞笑视频\南极之恋\42.mp4"
- ffmpeg -ss 00:00:42.000 -t 00:00:43.000 -accurate_seek -i "南极之恋.mp4" -codec copy -avoid_negative_ts 1 "D:\搞笑视频\南极之恋\43.mp4"
- ffmpeg -ss 00:00:43.000 -t 00:00:44.000 -accurate_seek -i "南极之恋.mp4" -codec copy -avoid_negative_ts 1 "D:\搞笑视频\南极之恋\44.mp4"
- ffmpeg -ss 00:00:44.000 -t 00:00:45.000 -accurate_seek -i "南极之恋.mp4" -codec copy -avoid_negative_ts 1 "D:\搞笑视频\南极之恋\45.mp4"
- ffmpeg -ss 00:00:45.000 -t 00:00:46.000 -accurate_seek -i "南极之恋.mp4" -codec copy -avoid_negative_ts 1 "D:\搞笑视频\南极之恋\46.mp4"
- ffmpeg -ss 00:00:46.000 -t 00:00:47.000 -accurate_seek -i "南极之恋.mp4" -codec copy -avoid_negative_ts 1 "D:\搞笑视频\南极之恋\47.mp4"
- ffmpeg -ss 00:00:47.000 -t 00:00:48.000 -accurate_seek -i "南极之恋.mp4" -codec copy -avoid_negative_ts 1 "D:\搞笑视频\南极之恋\48.mp4"
- ffmpeg -ss 00:00:48.000 -t 00:00:49.000 -accurate_seek -i "南极之恋.mp4" -codec copy -avoid_negative_ts 1 "D:\搞笑视频\南极之恋\49.mp4"
- ffmpeg -ss 00:00:49.000 -t 00:00:50.000 -accurate_seek -i "南极之恋.mp4" -codec copy -avoid_negative_ts 1 "D:\搞笑视频\南极之恋\50.mp4"
- ffmpeg -ss 00:00:50.000 -t 00:00:51.000 -accurate_seek -i "南极之恋.mp4" -codec copy -avoid_negative_ts 1 "D:\搞笑视频\南极之恋\51.mp4"
- ffmpeg -ss 00:00:51.000 -t 00:00:52.000 -accurate_seek -i "南极之恋.mp4" -codec copy -avoid_negative_ts 1 "D:\搞笑视频\南极之恋\52.mp4"
- ffmpeg -ss 00:00:52.000 -t 00:00:53.000 -accurate_seek -i "南极之恋.mp4" -codec copy -avoid_negative_ts 1 "D:\搞笑视频\南极之恋\53.mp4"
- ffmpeg -ss 00:00:53.000 -t 00:00:54.000 -accurate_seek -i "南极之恋.mp4" -codec copy -avoid_negative_ts 1 "D:\搞笑视频\南极之恋\54.mp4"
- ffmpeg -ss 00:00:54.000 -t 00:00:55.000 -accurate_seek -i "南极之恋.mp4" -codec copy -avoid_negative_ts 1 "D:\搞笑视频\南极之恋\55.mp4"
- ffmpeg -ss 00:00:55.000 -t 00:00:56.000 -accurate_seek -i "南极之恋.mp4" -codec copy -avoid_negative_ts 1 "D:\搞笑视频\南极之恋\56.mp4"
- ffmpeg -ss 00:00:56.000 -t 00:00:57.000 -accurate_seek -i "南极之恋.mp4" -codec copy -avoid_negative_ts 1 "D:\搞笑视频\南极之恋\57.mp4"
- ffmpeg -ss 00:00:57.000 -t 00:00:58.000 -accurate_seek -i "南极之恋.mp4" -codec copy -avoid_negative_ts 1 "D:\搞笑视频\南极之恋\58.mp4"
- ffmpeg -ss 00:00:58.000 -t 00:00:59.000 -accurate_seek -i "南极之恋.mp4" -codec copy -avoid_negative_ts 1 "D:\搞笑视频\南极之恋\59.mp4"
- ffmpeg -ss 00:00:59.000 -t 00:01:00.000 -accurate_seek -i "南极之恋.mp4" -codec copy -avoid_negative_ts 1 "D:\搞笑视频\南极之恋\60.mp4"
- ffmpeg -ss 00:01:00.000 -t 00:01:01.000 -accurate_seek -i "南极之恋.mp4" -codec copy -avoid_negative_ts 1 "D:\搞笑视频\南极之恋\61.mp4"
- ffmpeg -ss 00:01:01.000 -t 00:01:02.000 -accurate_seek -i "南极之恋.mp4" -codec copy -avoid_negative_ts 1 "D:\搞笑视频\南极之恋\62.mp4"
- ffmpeg -ss 00:01:02.000 -t 00:01:03.000 -accurate_seek -i "南极之恋.mp4" -codec copy -avoid_negative_ts 1 "D:\搞笑视频\南极之恋\63.mp4"
复制代码
全部内容是这样的,比如最后一行提取00:01:02.000 到 00:01:03.000之间的视频,也是1秒,但是变成一分多钟,其他也一样
作者: nwm310 时间: 2021-4-9 21:25
本帖最后由 nwm310 于 2021-4-10 09:20 编辑
-t 長度
-to 終點
獲得每個關鍵幀的時間- ffprobe.exe -v error -select_streams v -show_entries "frame=key_frame,pkt_pts_time" -of csv -sexagesimal a.mp4 | find "frame,1,"
复制代码
獲得 1:23 (1分23秒) 附近的關鍵幀時間
cmd窗口 1:23%+#1
bat 1:23%%+#1- ffprobe.exe -v error -select_streams v -show_entries "frame=pkt_pts_time" -of csv -sexagesimal -read_intervals 1:23%+#1 a.mp4
复制代码
作者: xp3000 时间: 2021-4-10 08:08
原来这样,没关键帧还是不能分割,插入关键帧又重新编码,大了不少
欢迎光临 批处理之家 (http://www.bathome.net/) |
Powered by Discuz! 7.2 |