使用ffprobe查看视频信息,并生成json文件

ffprobe -v quiet -print_format json -show_format -show_streams /mnt/2.mp4 >>/mnt/media_json.txt

其中/mnt/2.mp4 是视频的路径

/mnt是生成文件的位置

media_json.txt是文件名字

好的,关于使用 property_tree 生成 json 文件,可以参考以下代码示例: ```c++ #include <iostream> #include <boost/property_tree/ptree.hpp> #include <boost/property_tree/json_parser.hpp> namespace pt = boost::property_tree; int main() { pt::ptree json; json.put("name", "John Doe"); json.put("age", 30); pt::write_json("example.json", json); //将 ptree 内容写入 example.json 文件 return 0; } ``` 在这段代码中,我们通过 `boost::property_tree` 库创建了一个 `pt::ptree` 对象,并通过 `put` 函数向其中添加了两个键值对。之后,我们使用 `write_json` 函数将 `ptree` 对象的内容写入到指定的 json 文件(此处为 `example.json`)中。 需要注意的是,本例中的 json 文件中只包含两个键值对。如果需要添加更多字段,只需在 `ptree` 对象中添加更多数据即可。 如果你需要从 json 文件中读取数据,可以使用 `read_json` 函数来实现。与 `write_json` 类似,该函数将从指定的 json 文件中读取数据,然后将其存储到 `ptree` 对象中。以下是一个简单的示例: ```c++ #include <iostream> #include <boost/property_tree/ptree.hpp> #include <boost/property_tree/json_parser.hpp> namespace pt = boost::property_tree; int main() { pt::ptree json; pt::read_json("example.json", json); //从 example.json 文件中读取数据 std::string name = json.get<std::string>("name"); int age = json.get<int>("age"); std::cout << "Name: " << name << std::endl; std::cout << "Age: " << age << std::endl; return 0; } ``` 在本例中,我们使用 `read_json` 函数将 `example.json` 文件中的数据读取到 `ptree` 对象中。之后,我们使用 `get` 函数从 `ptree` 中获取 `name` 和 `age` 两个字段的数据,并将其存储到相应的变量中。最后,我们将这些变量的值输出到控制台上。 希望这个例子能够回答你的问题。如果还有其他问题,请随时问我!
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值