+ Asset *asset = new Asset(filename);
+ switch( mode ) {
+ case SNAPSHOT_PNG:
+ asset->format = FILE_PNG;
+ asset->png_use_alpha = 1;
+ break;
+ case SNAPSHOT_JPEG:
+ asset->format = FILE_JPEG;
+ asset->jpeg_quality = 90;
+ break;
+ case SNAPSHOT_TIFF:
+ asset->format = FILE_TIFF;
+ asset->tiff_cmodel = 0;
+ asset->tiff_compression = 0;
+ break;
+ }
+ asset->width = fw;
+ asset->height = fh;
+ asset->audio_data = 0;
+ asset->video_data = 1;
+ asset->video_length = 1;
+ asset->layers = 1;
+
+ File file;
+ int processors = preferences->project_smp + 1;
+ if( processors > 8 ) processors = 8;
+ file.set_processors(processors);
+ int ret = file.open_file(preferences, asset, 0, 1);
+ if( !ret ) {
+ file.start_video_thread(1, fcolor_model,
+ processors > 1 ? 2 : 1, 0);
+ VFrame ***frames = file.get_video_buffer();
+ VFrame *frame = frames[0][0];
+ TransportCommand command;
+ //command.command = audio_tracks ? NORMAL_FWD : CURRENT_FRAME;
+ command.command = CURRENT_FRAME;
+ command.get_edl()->copy_all(edl);
+ command.change_type = CHANGE_ALL;
+ command.realtime = 0;
+
+ RenderEngine render_engine(0, preferences, 0, 0);
+ CICache video_cache(preferences);
+ render_engine.set_vcache(&video_cache);
+ render_engine.arm_command(&command);
+
+ double position = edl->local_session->get_selectionstart(1);
+ int64_t source_position = (int64_t)(position * edl->get_frame_rate());
+ int ret = render_engine.vrender->process_buffer(frame, source_position, 0);
+ if( !ret )
+ ret = file.write_video_buffer(1);
+ file.close_file();
+ }
+ if( !ret ) {
+ asset->awindow_folder = AW_MEDIA_FOLDER;
+ mwindow->edl->assets->append(asset);
+ mwindow->awindow->gui->async_update_assets();
+ }
+ else {
+ eprintf("snapshot render failed");
+ asset->remove_user();
+ }
+ return 1;
+}