简体   繁体   English

从C ++系统调用时ffmpeg不起作用

[英]ffmpeg doesn't work when called from c++ system

I have a c++ script that coneverts a series of jpg into a .mp4 video, the command i use is the folllowing: 我有一个C ++脚本,可将一系列jpg转换为.mp4视频,我使用的命令如下:

std::system("ffmpeg -threads auto -y -framerate 1.74659 -i /mnt/ev_ramdsk/1/%05d-capture.jpg -vcodec libx264 -preset ultrafast /mnt/ev_ramdsk/1/video.mp4");

which produces a .mp4 video file like its supposed to except it cant be played from anywhere (tested in 2 computers and html5 video) 它会产生一个.mp4视频文件,该文件应与预期的一样,但不能在任何地方播放(在2台计算机和html5视频中测试)

But, if from the same computer where the program runs, i do: 但是,如果从运行程序的同一台计算机上,我会这样做:

ffmpeg -threads auto -y -framerate 2 -i %05d-capture.jpg -vcodec libx264 -preset ultrafast video.mp4

from the command line, the output video plays wonderfully (except in vlc, for vlc i have to use -vcodec mpeg4) 从命令行,输出视频播放出色(vlc除外,对于vlc,我必须使用-vcodec mpeg4)

What can possibly cause this behaviour? 什么可能导致这种行为? could cp command corrupt the file? cp命令会损坏文件吗? (ran after the mpeg to move it out of the ramfs) (在mpeg之后运行以将其移出ramfs)

EDIT: 编辑:

As requested, i ran the whole set of commands one by one in the console exactly as the program do (the program logs every single command it runs, i just repeated them). 根据要求,我完全按照程序的要求在控制台中逐个运行了整套命令(程序记录了它运行的每个命令,我只是重复了一次)。

The commands are: 这些命令是:

cp -r /var/cache/zoneminder/events/1/16/05/18/23/30/00/ /mnt/ev_ramdsk/1/
ffmpeg -threads auto -y -framerate 1.76729 -i /mnt/ev_ramdsk/1/%5d-capture.jpg -preset ultrafast /mnt/ev_ramdsk/1/video.mp4
cp /mnt/ev_ramdsk/1/video.mp4 /var/cache/evmanager/videos/1/2016_05_18_23_30_00_.mp4

The resulting .mp4 file can be played without any trouble. 生成的.mp4文件可以轻松播放。 Also, is the only one with a preview image in the file explorer. 此外,也是文件浏览器中唯一具有预览图像的文件。

Thank you very much! 非常感谢你!

Solved it! 解决了!

this was the winning answer. 是一个成功的答案。 finally got it to work using: 最终使它可以使用:

std::system("ffmpeg -threads auto -y -r 1.74659 -i /mnt/ev_ramdsk/1/%05d-capture.jpg -px_fmt yuv420p -preset ultrafast -r 10 /mnt/ev_ramdsk/1/video.mp4");

Thank you very much! 非常感谢你!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM