如何使用 GNU Make 从索引数据文件制作电影?
我正在尝试使用 linux 实用程序 make 来
- 运行脚本来生成数据
- 获取所有输出文件(data1.txt 到 data79.txt)并运行一个脚本来绘制它们每个
- 获取所有这些图像并制作一个是的
,我意识到在 shell/python 脚本中执行此操作非常简单,但我正在尝试学习如何在这种情况下使用 make 来更智能地完成工作。
我当前的 make 文件看起来像这样,但存在明显缺陷:
movie: data *.png
ffmpeg data_%d.png output.mp4
%.png: %.txt
python plot.py $< $@
data:
python make_data.py
I'm trying to use the linux utility make in order to
- Run a script to generate the data
- Take all of the output files (data1.txt to data79.txt) and run a script to plot them each
- Take all those images and make a movie from them
Yes, I realize that doing this in a shell/python script would be downright simple but I'm trying to learn how to use make in this context to do the work more intelligently.
My current make file looks something like this but is significantly flawed:
movie: data *.png
ffmpeg data_%d.png output.mp4
%.png: %.txt
python plot.py lt; $@
data:
python make_data.py
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您有几个问题,所以让我们按顺序解决它们。 (警告:我使用 GNUMake,所以我不能保证我的解决方案适用于其他风格,而且我不熟悉 ffmpeg。)
将它们放在一起,我们得到这样的结果:(
请注意,有些人喜欢将所有 PHONY 声明放在一起:“.PHONY:电影数据”。我更喜欢按照上面的方式进行操作。)
You have several problems, so let's take them in order. (Caveats: I use GNUMake, so I can't promise my solution will work with other flavors, and I am not familiar with ffmpeg.)
You can test this rule by itself: "make data".
This will work if the data files already exist (and you can test it after "make data"), but when we first run make, the data files don't exist. There are several ways to address this; the simplest is to run Make a second time from within a rule, after the data files have been made:
Putting it all together, we get something like this:
(Note that some people like to put all the PHONY declarations together: ".PHONY: movie data". I prefer to do it as above.)