func (s *Manager) generateScreenshot(ctx context.Context, sceneId string, at *float64) int {
	if err := instance.Paths.Generated.EnsureTmpDir(); err != nil {
		logger.Warnf("failure generating screenshot: %v", err)
	}

	j := job.MakeJobExec(func(ctx context.Context, progress *job.Progress) {
		sceneIdInt, err := strconv.Atoi(sceneId)
		if err != nil {
			logger.Errorf("Error parsing scene id %s: %s", sceneId, err.Error())
			return
		}

		var scene *models.Scene
		if err := s.TxnManager.WithReadTxn(ctx, func(r models.ReaderRepository) error {
			var err error
			scene, err = r.Scene().Find(sceneIdInt)
			return err
		}); err != nil || scene == nil {
			logger.Errorf("failed to get scene for generate: %s", err.Error())
			return
		}

		task := GenerateScreenshotTask{
			txnManager:          s.TxnManager,
			Scene:               *scene,
			ScreenshotAt:        at,
			fileNamingAlgorithm: config.GetInstance().GetVideoFileNamingAlgorithm(),
		}

		task.Start(ctx)

		logger.Infof("Generate screenshot finished")
	})

	return s.JobManager.Add(ctx, fmt.Sprintf("Generating screenshot for scene id %s", sceneId), j)
}
// generate default screenshot if at is nil
generate default screenshot if at is nil
// generate default screenshot if at is nil
func (s *Manager) generateScreenshot(ctx context.Context, sceneId string, at *float64) int {
	if err := instance.Paths.Generated.EnsureTmpDir(); err != nil {
		logger.Warnf("failure generating screenshot: %v", err)
	}
	j := job.MakeJobExec(func(ctx context.Context, progress *job.Progress) {
		sceneIdInt, err := strconv.Atoi(sceneId)
		if err != nil {
			logger.Errorf("Error parsing scene id %s: %s", sceneId, err.Error())
			return
		}
		var scene *models.Scene
		if err := s.TxnManager.WithReadTxn(ctx, func(r models.ReaderRepository) error {
			var err error
			scene, err = r.Scene().Find(sceneIdInt)
			return err
		}); err != nil || scene == nil {
			logger.Errorf("failed to get scene for generate: %s", err.Error())
			return
		}
		task := GenerateScreenshotTask{
			txnManager:          s.TxnManager,
			Scene:               *scene,
			ScreenshotAt:        at,
			fileNamingAlgorithm: config.GetInstance().GetVideoFileNamingAlgorithm(),
		}
		task.Start(ctx)
		logger.Infof("Generate screenshot finished")
	})
	return s.JobManager.Add(ctx, fmt.Sprintf("Generating screenshot for scene id %s", sceneId), j)
}
func ( s * Manager ) generateScreenshot ( ctx context . Context , sceneId string , at * float64 ) int { if err := instance . Paths . Generated . EnsureTmpDir ( ) ; err != nil { logger . Warnf ( " " , err ) } j := job . MakeJobExec ( func ( ctx context . Context , progress * job . Progress ) { sceneIdInt , err := strconv . Atoi ( sceneId ) if err != nil { logger . Errorf ( " " , sceneId , err . Error ( ) ) return } var scene * models . Scene if err := s . TxnManager . WithReadTxn ( ctx , func ( r models . ReaderRepository ) error { var err error scene , err = r . Scene ( ) . Find ( sceneIdInt ) return err } ) ; err != nil || scene == nil { logger . Errorf ( " " , err . Error ( ) ) return } task := GenerateScreenshotTask { txnManager : s . TxnManager , Scene : * scene , ScreenshotAt : at , fileNamingAlgorithm : config . GetInstance ( ) . GetVideoFileNamingAlgorithm ( ) , } task . Start ( ctx ) logger . Infof ( " " ) } ) return s . JobManager . Add ( ctx , fmt . Sprintf ( " " , sceneId ) , j ) }
generate default screenshot if at is nil
generate default screenshot if at is nil