我正在尝试创建一个只有单个图像的短视频。(我知道它有点傻,但它是对更大事物的测试)。
我用于渲染它的代码是:
#include <framework/mlt.h>
#include <stdlib.h>
#include <unistd.h>
int main() {
if(mlt_factory_init(NULL)) {
mlt_profile p = mlt_profile_init(NULL);
mlt_consumer target = mlt_factory_consumer(p, "avformat",
mlt_producer source = mlt_factory_producer(p, "hold", "/Users/leif/logo.png");
mlt_producer_set_in_and_out(source, 0, 10);
mlt_consumer_connect(target, mlt_producer_service(source));
mlt_consumer_start(target);
sleep(5);
mlt_consumer_stop(target);
mlt_consumer_close(target);
mlt_producer_close(source);
mlt_factory_close();
} else {
printf("No\n");
}
return 0;
}
这个文件logo.png
在哪里。
当我运行此代码并播放output.mp4
时,图片全部乱码。中间有一条绿线,logo叠加在自己身上很多。
另一方面,如果我将消费者更改为 SDL,则图像播放正常。
最后,如果我将消费者更改为 XML,然后使用 melt 命令行应用程序来呈现它:
melt -consumer avformat:xmlout.mp4 output.xml
并播放视频,它也可以正常播放。
我应该设置的 avformat 消费者中是否缺少某些东西?还是我在这里缺少的其他东西?
编辑:作为参考,输出的 xml 文件:output.xml
是:
<?xml version="1.0" encoding="utf-8"?>
<mlt LC_NUMERIC="en_US.UTF-8" version="6.2.0" root="/Users/leif/src/video/private" title="Anonymous Submission" parent="producer0" in="0" out="10">
<profile description="DV/DVD PAL" width="720" height="576" progressive="0" sample_aspect_num="16" sample_aspect_den="15" display_aspect_num="4" display_aspect_den="3" frame_rate_num="25" frame_rate_den="1" colorspace="601"/>
<producer id="producer0" title="Anonymous Submission" in="0" out="10">
<property name="length">15000</property>
<property name="eof">pause</property>
<property name="resource">/Users/leif/logo.png</property>
<property name="aspect_ratio">1.06667</property>
<property name="frame">0</property>
<property name="method">onefield</property>
<property name="mlt_service">hold</property>
<property name="global_feed">1</property>
</producer>
</mlt>