Video encode using c++

Hello,

I need to try to encode the video into H264 using OpenCV using C++, Can anyone share some reference to perform H264 video encode.

Hi,
I think it in the doc here

Hello,

When I try to run the copy and run the code, it pops with a message “Not Enough Parameters”.

------------------------------------------------------------------------------
This program shows how to write video files.
You can extract the R or G or B color channel of the input video.
Usage:
./video-write <input_video_name> [ R | G | B] [Y | N]
------------------------------------------------------------------------------

Not enough parameters

C:\Naveen\projects\ocv\repo\DMS\x64\Debug\DMS.exe (process 19812) exited with code -1.
To automatically close the console when debugging stops, enable Tools->Options->Debugging->Automatically close the console when debugging stops.
Press any key to close this window . . .

did you try :

For example, a valid command line would look like:

video-write.exe video/Megamind.avi R Y

do i need to download an video-write.exe? I am using the video in .mp4 format hope that should support.

Sorry but I do not understand
You post an error message about video_write.exe so You already got video-write.exe !?

seriously consider to use ffmpeg (on the cmdline) not opencv to re-encode an existing video file.

and that demo program won’t do, what you wanted (it’s writing only a single color channel to the video)

last, iirc writing h264 still has a patent issue, i’m not sure if e.g. opencv’s windows ffmpeg wrapper has it.

I dont see any .exe file, after copying the example file from the link you shared, I build and running it, and on the debugger console I see the error as “Not enough parameters”.
Am I failing to give the inputs, since in the code if(argc!=4) it prints this error, If so, where should I provide this input?

I am new to this openCV, what you mean by consider using ffmpeg on the cmdline not opencv?
I am just copying the code, build and run the code.

there are ready made, well tested programs for your problem.
dont abuse a computer-vision library for it (it’s not meant to do that)

and again, that sample code will require a lot of hacking, before you can use it.
you’ll need to throw out the split / merge part (and the resp. args) and write the original frame instead

I appreciate your help in sharing the information.

can you please share some link on step by step procedure to use the ffmpeg?
I saw the link which you shared, Should I download ffmpeg, if so after downloading how to use it?

https://ffmpeg.org/ffmpeg.html

and if that’s not enough, try a search engine.

or perhaps you might like to use a graphical video editor instead? or just a video converter like Handbrake?

in this forum we don’t teach how to use computers. that’s not the purpose of this forum.

if you really want to …

then you first need to know some C++, which includes knowing what your editor/IDE does.

if you simply click “run”, it may run your program, but without command line arguments.

you should know what “command line arguments” are in general, and you should know how to run programs from a terminal/console.

maybe you noticed… you saved that example code as “DMS.cpp” (or something like that), so your IDE made the file DMS.exe from that. that is the file you executed. the code talks about itself, but it doesn’t know what file you put it in, so it thinks it’s called video-write

Yes I do understand the forum usage and I dint ask on how to use computer, I know the usage of computer better.
If someone is new to the topic, it does not mean they are dumb enough on computer world. Each one has their limitations and everyone is well experienced in their own topics.

If you can help, help and make them to move along, if not you dont need to take your damn time to comment to the thread. Just Ignore and proceed with what makes you fascinated.

You might be experienced enough on working this topics and I appreciate for sharing the useful information.

Thanks Guys, I explored on ffmpeg and found how powerful it is for video encoding and can achieve more.

You need to either
A) Learn how to pass parameter to the program when it is run or debugged in Visual Studio (there is a menu item or dialog somewhere in VS)
B) Run the executable outside of VS in a Windows console; wherever VS builds the .exe

These are very basic VS things, not related to OpenCV

I know it either on how to use VS and on how to pass it.