CatManJump
New Member
I want to recording video from usb camera.
This is my open camera code:
This is my recording video code:
I use that code can not recording video,please help me.
Think you very much.
This is my open camera code:
captureSource = obs_source_create("dshow_input", "DshowWindowsCapture",NULL, nullptr);
if (captureSource != nullptr)
{
auto settings = obs_source_get_settings( captureSource );
obs_data_set_string( settings, "id", "dshow_input" );
obs_data_set_string( settings, "video_device_id", deviceID );
obs_source_update( captureSource, settings );
properties = obs_source_properties(captureSource);
obs_property_t *property = obs_properties_first(properties);
while (property) {
obs_property_next(&property);
}
obs_data_release(settings);
return 0;
}
This is my recording video code:
fileOutput = obs_output_create("ffmpeg_output", "adv_ffmpeg_output", nullptr, nullptr);
obs_data_t* settings = obs_data_create();
string out_file_name = "D:/CMJ.mp4";
obs_data_set_string(settings, "url", out_file_name.c_str());
obs_data_set_string(settings, "format_name", RECORD_OUTPUT_FORMAT);
obs_data_set_string(settings, "format_mime_type", RECORD_OUTPUT_FORMAT_MIME);
obs_data_set_string(settings, "muxer_settings", "movflags=faststart");
obs_data_set_int(settings, "gop_size", VIDEO_FPS * 10);
obs_data_set_string(settings, "video_encoder", VIDEO_ENCODER_NAME);
obs_data_set_int(settings, "video_encoder_id", VIDEO_ENCODER_ID);
if (VIDEO_ENCODER_ID == AV_CODEC_ID_H264)
obs_data_set_string(settings, "video_settings", "profile=main x264-params=crf=22");
else if (VIDEO_ENCODER_ID == AV_CODEC_ID_FLV1)
obs_data_set_int(settings, "video_bitrate", VIDEO_BITRATE);
obs_data_set_int(settings, "audio_bitrate", AUDIO_BITRATE);
obs_data_set_string(settings, "audio_encoder", "aac");
obs_data_set_int(settings, "audio_encoder_id", AV_CODEC_ID_AAC);
obs_data_set_string(settings, "audio_settings", NULL);
obs_data_set_int(settings, "scale_width", OUT_WIDTH);
obs_data_set_int(settings, "scale_height", OUT_HEIGHT);
obs_output_set_mixer(fileOutput, 1);
obs_output_set_media(fileOutput, obs_get_video(), obs_get_audio());
obs_output_update(fileOutput, settings);
obs_data_release(settings);
obs_output_start(fileOutput)
I use that code can not recording video,please help me.
Think you very much.