gpt4 book ai didi

ruby - ffmpeg:处理输入时发现无效数据

转载 作者:行者123 更新时间:2023-12-04 22:53:12 24 4
gpt4 key购买 nike

我遇到 ffmpeg 抛出错误的情况:

Invalid data found when processing input

我在这里查看了其他答案,但我的情况有所不同。我在 Ruby 中生成了一个文本文件,其中包含我想将其连接在一起的输入文件列表。

我在 Ruby 中生成,该命令用于 bash ,这也是我手动复制的输出:
ffmpeg -y -f concat -safe 0 -i /Volumes/Dragon2/Yums/randoms.txt /Volumes/Dragon2/Yums/final.mp4

引发错误:
/Volumes/Dragon2/Yums/randoms.txt: Invalid data found when processing input

这是那个文件:
file '/Volumes/Dragon2/Yums/0CEDC3CA-4571-4271-9938-A161EC2A887B.mov'
file '/Volumes/Dragon2/Yums/0D25D907-D053-443B-AFC6-9F12B1711BBF.mov'
file '/Volumes/Dragon2/Yums/6A272808-7706-435D-801E-ACE6B42EC749.mov'
file '/Volumes/Dragon2/Yums/6E9BA2F1-C5E7-4C1C-B290-D116105732FA.mov'
file '/Volumes/Dragon2/Yums/0A41C7B7-74CE-484E-B029-3AE57B8BB4EA.mov'

bash 运行它时,它会提示输入文件 randoms.txt 包含无效数据。当我在 bash 中复制并粘贴相同的命令时,它工作正常。我对这两者有何不同以及为什么 ffmpegshell 中启动时不高兴感到困惑。

我怎样才能让它工作?我错过了什么?干杯

编辑:原始 ruby 代码:
`clear`
require 'pathname'
require 'pp'

s = '/Volumes/Dragon2/Yums'
files = []

Dir.foreach(s) do |path|
files << "#{ s }/#{ path }"
end

result = files.sample(files.size) # randomizer

f = File.open("#{ s }/randoms.txt", 'w+')
result.each_with_index do |item, i|
pp "#{ i }: #{ item }" if item.include?('mov')
f << "file '#{ item }'\n" if item.include?('mov')
end

`echo `

File.delete("#{ s }/final.mp4") if File.exists?("#{ s }/final.mp4")
s = "ffmpeg -y -f concat -safe 0 -i #{ s }/randoms.txt #{ s }/final.mp4"
puts s

sleep 3
`#{ s }`

我也尝试过 system s 以及相同的错误。语法生成良好,输出良好,手动操作良好。

最佳答案

我需要 f.close写文件所以ffmpeg可以从中读取。但是 shellwords也是关键。谢谢你 。

关于ruby - ffmpeg:处理输入时发现无效数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52414228/

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