我尝试使用以下命令使用视频的开始和结束时间来剪切视频

ffmpeg -ss 00:00:03 -t 00:00:08 -i movie.mp4 -acodec copy -vcodec copy -async 1 cut.mp4

通过使用上面的命令,我想把视频从00:00:03剪辑到00:00:08。但它并没有在这两个时间之间剪切视频,而是剪切了前11秒的视频。有人能帮我解决这个问题吗?

编辑1:

我尝试使用mark4o建议的以下命令进行切割

ffmpeg -i movie.mp4 -ss 00:00:03 -t 00:00:08 -async 1 cut.mp4

但是显示了以下错误。

编码器“aac”是实验性的,但实验性编解码器未启用

因此,我在命令中添加了-strict -2,即,

ffmpeg -i movie.mp4 -ss 00:00:03 -t 00:00:08 -async 1 -strict -2 cut.mp4

现在它工作得很好。


当前回答

我感兴趣的是基于毫秒的切割时间,并注意到秒(以及它们的分数)可以被指定为切割如下:

ffmpeg -i input.mp4 -ss 17.5 -to 20.5 output.mp4

对于持续时间而不是结束时间,使用-t而不是-to:

ffmpeg -i input.mp4 -ss 17.5 -t 3 output.mp4

其他回答

ffmpeg -i movie.mp4 -ss 00:00:03 -t 00:00:08 -async 1 -c copy cut.mp4 

立即使用-c copy for make in。在这种情况下,ffmpeg将不会重新编码视频,只是将削减到根据大小。

我感兴趣的是基于毫秒的切割时间,并注意到秒(以及它们的分数)可以被指定为切割如下:

ffmpeg -i input.mp4 -ss 17.5 -to 20.5 output.mp4

对于持续时间而不是结束时间,使用-t而不是-to:

ffmpeg -i input.mp4 -ss 17.5 -t 3 output.mp4

使用ffmpeg-python库,我这样做了。但是在安装ffmpeg-library之前,必须先卸载ffmpeg。详见我的github。 https://github.com/johntsunami/ffmpeg-python-video-trimmer/blob/main/trimmer.py

sys.path.append(r"C:\Users\johnc\Desktop\ffmpeg\bin")
stream = ffmpeg.input(r"C:/Users/johnc/Desktop/krystal.mp4",ss=57, t=55)  # ss is start time,  t IS DURATION

## SEPARATES AUDIO AND VIDEO INDEPENDENTLY BECAUSE SOMETIMES IT DOESNT HAVE AUDIO UNLESS YOU DO THIS>

audio = stream.audio 
video = stream.video   #.trim(start=60,end=115).filter('setpts','PTS-STARTPTS') ## CURRENTLY IS GOOD BUT DOESNT CUT DURATION AFTER 55 seconds

#overwrite_output overwrites it automatically if i dont want it just use output
stream = ffmpeg.output(audio, video, r'C:\Users\johnc\Desktop\output.mp4')


ffmpeg.run(stream)

请随意使用这个工具https://github.com/rooty0/ffmpeg_video_cutter我之前写过 这就是ffmpeg的cli前端…你只需要创建一个yaml你想要削减…就像这样

cut_method: delete  # we're going to delete following video fragments from a video
timeframe:
  - from: start   # waiting for people to join the conference
    to: 4m
  - from: 10m11s  # awkward silence
    to: 15m50s
  - from: 30m5s   # Off-Topic Discussion
    to: end

然后运行一个工具得到结果

使用-to代替-t: -to指定结束时间,-t指定持续时间