【问题标题】:cutting a video with ffmpeg with an absolute endposition使用 ffmpeg 以绝对结束位置剪切视频
【发布时间】:2012-04-24 16:35:46
【问题描述】:

我想使用 ffmpeg 将视频切片。我有两个绝对的“职位”,不是一个开始和一个持续时间。所以我不能那样使用它:

ffmpeg -ss 00:00:12.12 -t 00:00:14.13 -i foo.mov...

(再次,-t 之后的时间不是持续时间)我是否必须计算 to 位置之间的持续时间,还是 ffmpeg 可以为我做到这一点?

【问题讨论】:

标签: video ffmpeg


【解决方案1】:

从 FFmpeg 1.2(2013 年 3 月发布)开始,可以使用 -to 选项代替 -t 来指定结束时间而不是持续时间。

【讨论】:

    【解决方案2】:

    使用这个 python 脚本

    #!/bin/python
    from sys  import argv
    from os   import system
    
    ffm = 'ffmpeg -i "' # input file
    aud = '" -acodec libfaac -aq  64 -ac 2 -ar 44100'
    vid =  ' -vcodec libx264 -crf 25 -r 25 -subq 9'
    c=0
    def encode(video,option=''):
       global c;   c+=1
       out = ' "'+ video + str(c) + '.mp4"'
       cmd = ffm + video + aud + vid + option + out
       print cmd;  system(cmd)
    
    def seconds(time):
       t = [float(x)  for x in time.split(':')]
       if len(t)==1:  return t[0]
       if len(t)==2:  return t[1]+t[0]*60
       if len(t)==3:  return t[2]+t[1]*60+t[0]*3600
    
    def split(time):
       (start,end) = [seconds(x) for x in time.split()]
       return ' -ss %s -t %s' % (start,end-start)
    
    for slice in argv[2].split(','):
      encode(argv[1],split(slice))
    #  $ python split.py "video.mpg" "1:50 9:10,7:30 15:30,13:30 20:10"
    

    阅读 ma​​n ffmpeg 我看到了几种可接受的 -ss-t

    格式

    这让您可以重叠切片。并且可以以毫秒精度进行拆分。

    $ python split.py "video.mpg" "55:30.356 1:01:10.895"
    

    您必须根据自己的喜好编辑 acodecvcodec

    我推荐使用 libx264 内核 高于 100 版的这些选项。

    【讨论】:

      【解决方案3】:

      使用 -ss 标记您的开始,使用 -t 标记最后的持续时间。 -t 选项表示两个绝对位置之间的差异,您必须计算。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2017-03-20
        • 2013-08-28
        • 2018-03-12
        • 2013-09-17
        • 2017-10-01
        • 2020-09-21
        • 2016-05-02
        • 2014-01-18
        相关资源
        最近更新 更多