Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/shinniuwu/bad-apple-ascii-api-java

A Java-based API that generates ASCII art from the "Bad Apple.
https://github.com/shinniuwu/bad-apple-ascii-api-java

api ascii-animation bad-apple java jcodec open-source

Last synced: 1 day ago
JSON representation

A Java-based API that generates ASCII art from the "Bad Apple.

Awesome Lists containing this project

README

        

Great! I've added the image. Here's the updated README:

# Bad Apple ASCII API

This Java API allows you to convert frames from the "Bad Apple!!" MP4 video into ASCII art. You can use this API to retrieve ASCII art representations of individual frames or stream them continuously. Additionally, an HTML file is provided to display the ASCII art in a web browser.

![Bad Apple ASCII Art](https://cdn.discordapp.com/attachments/1184247115086561483/1242229481897463888/image.png?ex=664d13db&is=664bc25b&hm=51afe63b09316727cfbc188d9ec6711d896a4915f42f8896ad6e338331081607&)

## Usage

### Running the Server

1. Clone this repository.
2. Ensure you have Java installed on your system.
3. Run the `Main` class to start the HTTP server.
4. Access the API at `http://localhost:8080/play`.

### Retrieving ASCII Art

#### Single Frame

You can retrieve ASCII art for a specific frame by accessing:

```
GET /play/{frameNumber}
```

Replace `{frameNumber}` with the desired frame number.

#### Streaming Frames

You can stream ASCII art frames continuously by accessing:

```
GET /play
```

This endpoint will return ASCII art for frames sequentially.

### HTML Display

Included in this repository is an HTML file (`index.html`) that displays the ASCII art in a web browser. Open the HTML file in a browser to see the ASCII art animation.

## Dependencies

This project uses the following dependencies:

- JCodec: A library for reading and writing video/audio files in Java.
- com.sun.net.httpserver: HTTP server included in the Java SE platform.

## How It Works

The API uses JCodec to extract frames from the "Bad Apple!!" MP4 video and converts each frame into ASCII art. The ASCII art is generated by converting the pixel values of the frame's grayscale image to ASCII characters. The server streams ASCII art frames upon client requests.

## Example

```java
// Java example to retrieve ASCII art for frame number 50
String asciiArt = fetchAsciiArt(50);
System.out.println(asciiArt);
```

## Authors

- Hana

## License

This project is licensed under the [Apache License 2.0](LICENSE).