void video_manager::begin_recording_mng(const char *name, uint32_t index, screen_device *screen) { // stop any existing recording end_recording_mng(index); mng_info_t &info = m_mngs[index]; // reset the state info.m_mng_frame = 0; info.m_mng_next_frame_time = machine().time(); // create a new movie file and start recording info.m_mng_file = std::make_unique<emu_file>(machine().options().snapshot_directory(), OPEN_FLAG_WRITE | OPEN_FLAG_CREATE | OPEN_FLAG_CREATE_PATHS); osd_file::error filerr; if (name != nullptr) { std::string full_name(name); if (index > 0) { char name_buf[256] = { 0 }; snprintf(name_buf, 256, "%s%d", name, index); full_name = name_buf; } filerr = info.m_mng_file->open(full_name.c_str()); } else { filerr = open_next(*info.m_mng_file, "mng"); } if (filerr == osd_file::error::NONE) { // start the capture int rate = int(screen->frame_period().as_hz()); png_error pngerr = mng_capture_start(*info.m_mng_file, m_snap_bitmap, rate); if (pngerr != PNGERR_NONE) { osd_printf_error("Error capturing MNG, png_error=%d\n", pngerr); return end_recording_mng(index); } // compute the frame time info.m_mng_frame_period = attotime::from_hz(rate); } else { osd_printf_error("Error creating MNG, osd_file::error=%d\n", int(filerr)); info.m_mng_file.reset(); } }
void video_manager::begin_recording(const char *name, movie_format format) { // create a snapshot bitmap so we know what the target size is create_snapshot_bitmap(nullptr); // start up an AVI recording if (format == MF_AVI) { // stop any existing recording end_recording(format); // reset the state m_avi_frame = 0; m_avi_next_frame_time = machine().time(); // build up information about this new movie screen_device *screen = machine().first_screen(); avi_file::movie_info info; info.video_format = 0; info.video_timescale = 1000 * ((screen != nullptr) ? ATTOSECONDS_TO_HZ(screen->frame_period().attoseconds()) : screen_device::DEFAULT_FRAME_RATE); info.video_sampletime = 1000; info.video_numsamples = 0; info.video_width = m_snap_bitmap.width(); info.video_height = m_snap_bitmap.height(); info.video_depth = 24; info.audio_format = 0; info.audio_timescale = machine().sample_rate(); info.audio_sampletime = 1; info.audio_numsamples = 0; info.audio_channels = 2; info.audio_samplebits = 16; info.audio_samplerate = machine().sample_rate(); // create a new temporary movie file osd_file::error filerr; std::string fullpath; { emu_file tempfile(machine().options().snapshot_directory(), OPEN_FLAG_WRITE | OPEN_FLAG_CREATE | OPEN_FLAG_CREATE_PATHS); if (name != nullptr) filerr = tempfile.open(name); else filerr = open_next(tempfile, "avi"); // if we succeeded, make a copy of the name and create the real file over top if (filerr == osd_file::error::NONE) fullpath = tempfile.fullpath(); } if (filerr == osd_file::error::NONE) { // compute the frame time m_avi_frame_period = attotime::from_seconds(1000) / info.video_timescale; // create the file and free the string avi_file::error avierr = avi_file::create(fullpath, info, m_avi_file); if (avierr != avi_file::error::NONE) { osd_printf_error("Error creating AVI: %s\n", avi_file::error_string(avierr)); return end_recording(format); } } } // start up a MNG recording else if (format == MF_MNG) { // stop any existing recording end_recording(format); // reset the state m_mng_frame = 0; m_mng_next_frame_time = machine().time(); // create a new movie file and start recording m_mng_file = std::make_unique<emu_file>(machine().options().snapshot_directory(), OPEN_FLAG_WRITE | OPEN_FLAG_CREATE | OPEN_FLAG_CREATE_PATHS); osd_file::error filerr; if (name != nullptr) filerr = m_mng_file->open(name); else filerr = open_next(*m_mng_file, "mng"); if (filerr == osd_file::error::NONE) { // start the capture screen_device *screen = machine().first_screen(); int rate = (screen != nullptr) ? ATTOSECONDS_TO_HZ(screen->frame_period().attoseconds()) : screen_device::DEFAULT_FRAME_RATE; png_error pngerr = mng_capture_start(*m_mng_file, m_snap_bitmap, rate); if (pngerr != PNGERR_NONE) { osd_printf_error("Error capturing MNG, png_error=%d\n", pngerr); return end_recording(format); } // compute the frame time m_mng_frame_period = attotime::from_hz(rate); } else { osd_printf_error("Error creating MNG, osd_file::error=%d\n", int(filerr)); m_mng_file.reset(); } } }
void video_manager::begin_recording(const char *name, movie_format format) { // stop any existign recording end_recording(); // create a snapshot bitmap so we know what the target size is create_snapshot_bitmap(NULL); // reset the state m_movie_frame = 0; m_movie_next_frame_time = machine().time(); // start up an AVI recording if (format == MF_AVI) { // build up information about this new movie avi_movie_info info; info.video_format = 0; info.video_timescale = 1000 * ((machine().primary_screen != NULL) ? ATTOSECONDS_TO_HZ(machine().primary_screen->frame_period().attoseconds) : screen_device::DEFAULT_FRAME_RATE); info.video_sampletime = 1000; info.video_numsamples = 0; info.video_width = m_snap_bitmap.width(); info.video_height = m_snap_bitmap.height(); info.video_depth = 24; info.audio_format = 0; info.audio_timescale = machine().sample_rate(); info.audio_sampletime = 1; info.audio_numsamples = 0; info.audio_channels = 2; info.audio_samplebits = 16; info.audio_samplerate = machine().sample_rate(); // create a new temporary movie file file_error filerr; astring fullpath; { emu_file tempfile(machine().options().snapshot_directory(), OPEN_FLAG_WRITE | OPEN_FLAG_CREATE | OPEN_FLAG_CREATE_PATHS); if (name != NULL) filerr = tempfile.open(name); else filerr = open_next(tempfile, "avi"); // compute the frame time m_movie_frame_period = attotime::from_seconds(1000) / info.video_timescale; // if we succeeded, make a copy of the name and create the real file over top if (filerr == FILERR_NONE) fullpath = tempfile.fullpath(); } if (filerr == FILERR_NONE) { // create the file and free the string avi_error avierr = avi_create(fullpath, &info, &m_avifile); if (avierr != AVIERR_NONE) mame_printf_error("Error creating AVI: %s\n", avi_error_string(avierr)); } } // start up a MNG recording else if (format == MF_MNG) { // create a new movie file and start recording m_mngfile = auto_alloc(machine(), emu_file(machine().options().snapshot_directory(), OPEN_FLAG_WRITE | OPEN_FLAG_CREATE | OPEN_FLAG_CREATE_PATHS)); file_error filerr; if (name != NULL) filerr = m_mngfile->open(name); else filerr = open_next(*m_mngfile, "mng"); if (filerr == FILERR_NONE) { // start the capture int rate = (machine().primary_screen != NULL) ? ATTOSECONDS_TO_HZ(machine().primary_screen->frame_period().attoseconds) : screen_device::DEFAULT_FRAME_RATE; png_error pngerr = mng_capture_start(*m_mngfile, m_snap_bitmap, rate); if (pngerr != PNGERR_NONE) return end_recording(); // compute the frame time m_movie_frame_period = attotime::from_hz(rate); } else { mame_printf_error("Error creating MNG\n"); global_free(m_mngfile); m_mngfile = NULL; } } }