parameters: (source_file, target_file, threshold=0.5, codec='libx264')
docstring: Strip out NSFW sections from source_file and write the cleaned video to target_file
docstring_summary: Strip out NSFW sections from source_file and write the cleaned video to target_file
docstring_tokens: Strip out NSFW sections from source_file and write the cleaned video to target_file
function: def remove_nsfw(source_file, target_file, threshold=0.5, codec='libx264'):
      """Strip out NSFW sections from source_file and write the cleaned video to target_file """
      print "uploading %s" % source_file
      data_uri = upload_file(source_file)
      print "examining %s" % data_uri
      nsfw_segments = detect_nudity(data_uri)
      print "cleaning %s (threshold=%s)" % (source_file, threshold)
      clip = VideoFileClip(source_file)
      shift = 0
      for segment in nsfw_segments['detections']:
          if segment['average_confidence'] > threshold:
              (start, stop) = (int(segment['start_time']), int(math.ceil(segment['stop_time'])))
              print "removing %s-%s" % (start, stop)
              clip = clip.cutout(start-shift,stop-shift)
              shift += stop-start
      print "writing %s (codec=%s)" % (target_file, codec)
      clip.write_videofile(target_file, codec=codec)
      client.file(data_uri).delete()
function_tokens: def remove_nsfw ( source_file , target_file , threshold = 0.5 , codec = 'libx264' ) : print "uploading %s" % source_file data_uri = upload_file ( source_file ) print "examining %s" % data_uri nsfw_segments = detect_nudity ( data_uri ) print "cleaning %s (threshold=%s)" % ( source_file , threshold ) clip = VideoFileClip ( source_file ) shift = 0 for segment in nsfw_segments [ 'detections' ] : if segment [ 'average_confidence' ] > threshold : ( start , stop ) = ( int ( segment [ 'start_time' ] ) , int ( math . ceil ( segment [ 'stop_time' ] ) ) ) print "removing %s-%s" % ( start , stop ) clip = clip . cutout ( start - shift , stop - shift ) shift += stop - start print "writing %s (codec=%s)" % ( target_file , codec ) clip . write_videofile ( target_file , codec = codec ) client . file ( data_uri ) . delete ( )