0
votes

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!

1
-framerate 2 is not the same as -framerate 1.74659, you should try testing with the exact same command line. - The Dark
At first, because of fps being int (later changed to float) tge command used to execute with -framerate 1 and none of the videos are playable - Arheisel
@Arheisel std::system calls the command processor. You also have execv and similar functions. You may need to call the latter instead of system. See here - PaulMcKenzie
What I meant was that you are saying "this command doesn't work from system but this different command works from the command line, therefore the problem is with system." I'm saying try running the exact same command from the command line as the problem may be with the actual command. - The Dark
You're right, im sorry. I will try it out and post the results. I also want to try execv but i cant find any documentation of it. - Arheisel

1 Answers

3
votes

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!