Menu Close

How can the TVideoGrabber SDK record in MP4 through the Multipurpose Encoder

You are here:
< Back

The typical sample code to record in MP4 is:

VideoGrabber.VideoSource = vs_VideoCaptureDevice;
VideoGrabber.VideoDevice = VideoGrabber.VideoDeviceIndex (“webcam name”); (1)
VideoGrabber.AudioDevice = VideoGrabber.AudioDeviceIndex (“microphone name”); (2)

VideoGrabber.RecordingMethod = rm_MP4;
VideoGrabber.AudioRecording = true;

CommandLine = “ffmpegLGPL.exe -i %PIPE% -pix_fmt yuv420p”;
CommandLine = CommandLine + ” -c:v h264 -threads 8 -b:v 30M -maxrate 40M -profile:v baseline “; (3)
CommandLine = CommandLine + ” -c:a aac -b:a 224k -f mp4 %FILENAME%”;
VideoGrabber.SetMultipurposeEncoderSettings (mpe_Recording, CommandLine);

VideoGrabber.EnableMultipurposeEncoder (mpe_Recording, true);
VideoGrabber.StartRecording();


(1) replace by the name of the webcam to use, as listed in the “video devices” list of MainDemo.exe
(2) replace by the name of the audio device to use, as listed in the “audio devices” list of MainDemo.exe
(3) to use the NVidia hardware encoder, replace this line by:
CommandLine = CommandLine + ” -c:v h264_nvenc -preset llhq -b:v 2500k -maxrate:v 3M -profile high”

 

Last Updated On July 08, 2019