Arheisel
Arheisel

Reputation: 186

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:

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)

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)

What can possibly cause this behaviour? could cp command corrupt the file? (ran after the mpeg to move it out of the 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. Also, is the only one with a preview image in the file explorer.

Thank you very much!

Upvotes: 0

Views: 2427

Answers (1)

Arheisel
Arheisel

Reputation: 186

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!

Upvotes: 4

Related Questions