如何有效地分割视频

如何有效地分割视频

本文介绍了FFmpeg:如何有效地分割视频?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望将一个大的avi视频分割成两个较小的连续视频。我正在使用ffmpeg。

I wish to split a large avi video into two smaller consecutive videos. I am using ffmpeg.

一种方式是运行ffmpeg两次:

One way is to run ffmpeg two times:

ffmpeg -i input.avi -vcodec copy -acodec copy -ss 00:00:00 -t 00:30:00 output1.avi
ffmpeg -i input.avi -vcodec copy -acodec copy -ss 00:30:00 -t 00:30:00 output2.avi

但是根据ffmpeg的联机帮助页我可以使用一个行从一个输入文件中创建多个输出文件:

But according to manpage of ffmpeg, I can make more than one ouput file from one input file using just one line:

ffmpeg -i input.avi -vcodec copy -acodec copy -ss 00:00:00 -t 00:30:00 output1.avi \
   -vcodec copy -acodec copy -ss 00:30:00 -t 00:30:00 output2.avi

我的问题是,后续的方法是否节省了计算时间和内存?

My question is, does the later approach save computation time and memory?

推荐答案

ffmpeg维基链接回到本页面,参考如何有效分割视频。我不相信这个页面回答了这个问题,所以我做了@AlcubierreDrive建议...

The ffmpeg wiki links back to this page in reference to "How to split video efficiently". I'm not convinced this page answers that question, so I did as @AlcubierreDrive suggested…

echo "Two commands"
time ffmpeg -v quiet -y -i input.ts -vcodec copy -acodec copy -ss 00:00:00 -t 00:30:00 -sn test1.mkv
time ffmpeg -v quiet -y -i input.ts -vcodec copy -acodec copy -ss 00:30:00 -t 01:00:00 -sn test2.mkv
echo "One command"
time ffmpeg -v quiet -y -i input.ts -vcodec copy -acodec copy -ss 00:00:00 -t 00:30:00 \
  -sn test3.mkv -vcodec copy -acodec copy -ss 00:30:00 -t 01:00:00 -sn test4.mkv

哪些输出...

Two commands
real    0m16.201s
user    0m1.830s
sys 0m1.301s

real    0m43.621s
user    0m4.943s
sys 0m2.908s

One command
real    0m59.410s
user    0m5.577s
sys 0m3.939s

我测试了SD&高清文件,经过几个运行&一个数学。

I tested a SD & HD file, after a few runs & a little maths.

Two commands SD 0m53.94 #2 wins
One command  SD 0m49.63

Two commands SD 0m55.00
One command  SD 0m52.26 #1 wins

Two commands SD 0m58.60 #2 wins
One command  SD 0m58.61

Two commands SD 0m54.60
One command  SD 0m50.51 #1 wins

Two commands SD 0m53.94
One command  SD 0m49.63 #1 wins

Two commands SD 0m55.00
One command  SD 0m52.26 #1 wins

Two commands SD 0m58.71
One command  SD 0m58.61 #1 wins

Two commands SD 0m54.63
One command  SD 0m50.51 #1 wins

Two commands SD 1m6.67s #2 wins
One command  SD 1m20.18

Two commands SD 1m7.67
One command  SD 1m6.72 #1 wins

Two commands SD 1m4.92
One command  SD 1m2.24 #1 wins

Two commands SD 1m1.73
One command  SD 0m59.72 #1 wins

Two commands HD 4m23.20
One command  HD 3m40.02 #1 wins

Two commands SD 1m1.30
One command  SD 0m59.59 #1 wins

Two commands HD 3m47.89
One command  HD 3m29.59 #1 wins

Two commands SD 0m59.82
One command  SD 0m59.41 #1 wins

Two commands HD 3m51.18
One command  HD 3m30.79 #1 wins

SD文件 = 1.35GB DVB运输流

高清文件 = 3.14GB DVB传输流

SD file = 1.35GB DVB transport stream
HD file = 3.14GB DVB transport stream

如果您正在处理高清,单个命​​令会更好,它符合在输入文件之后使用-ss进行慢速搜索的手册注释。 SD文件的差异可以忽略不计。

The single command is better if you are handling HD, it agrees with the manuals comments on using -ss after the input file to do a 'slow seek'. SD files have a negligible difference.

两个命令版本应该更快,在快速搜索的输入文件之前添加一个-ss,然后更准确缓慢寻求。

The two command version should be quicker by adding another -ss before the input file for the a 'fast seek' followed by the more accurate slow seek.

这篇关于FFmpeg:如何有效地分割视频?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-23 08:44