0

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!

8
  • 1
    -framerate 2 is not the same as -framerate 1.74659, you should try testing with the exact same command line. Commented May 18, 2016 at 23:52
  • 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 Commented May 19, 2016 at 0:16
  • @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 Commented May 19, 2016 at 0:41
  • 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. Commented May 19, 2016 at 0:57
  • 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. Commented May 19, 2016 at 0:59

1 Answer 1

4

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!

Sign up to request clarification or add additional context in comments.

2 Comments

You should mark (green tick) this as correct so others know there is a working solution.
Sorry, it didnt let me at the time and i just forgot

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.