Ever wished a picture could tell a story, not just in a thousand words but in a real-time video? Welcome to the future! Using ChatGPT’s innovative “Code Interpreter” feature, you can now turn that dream into reality. Join me as we delve into the magic to generate video from image using ChatGPT. Ready to embark on this journey?
See the steps below
Step1: Enable Code Interpreter
- We will be using the ChatGPT Code Interpreter model.
- To enable it, go to Settings -> Beta Features -> Code Interpreter
- It will be available to all ChatGPT plus users within this week.
Step2: Select Code Interpreter
- Select the “Code Interpreter” option from the dropdown menu.
- Then, upload the image that you want to animate.
Step3: Sample Image
- I’m highlighting dishes from an upscale dining establishment.
- Hence, I’ll instruct GPT to slide the food visual from the left side to the right.
- Adjust the GPT prompt I’ve shared, and craft your unique animations!
Prompt to Generate Video from Image using ChatGPT:
- This image is a panoramic shot.
- Help me turn it into a video with aspect ratio 3:2, with the image filling the entire video (so the sides are cut off). The video should be centered in the middle of the image.
- Then, pan the video smoothly (with no sudden jumps) as follows:
- Start: Center –> Right –> Center –> Left –> Center: End
- Use the imageio library to help you. Save the frames directly to a video file instead of into a list.
- Use a frame step of 8 pixels. If necessary, crop the edges of the image so that the size of the image is divisible by the frame step.
Response from ChatGPT:
First, we need to install the imageio library. Since the environment where I’m running doesn’t have internet access, I can’t install new packages. But I will guide you through the process. If you want to do this on your local machine, you can use the following command to install imageio
Step1: Got to Chrome Extension Store
Step2: Search for ‘WebChatGPT’
Step3: Click on ‘Add to Chrome’
Now try the same prompt in the new window of ChatGPT. This time it has created the video after adding the required libraries ‘imageio’ and ‘moviepy’
Scenario 2 (if the original image is not a Panaroma shot):
Step1: Cropping of Image
The original image is square with a size of 1024×1024 pixels. To maintain the desired aspect ratio of 3:2, we need to crop the image to a size of 1024×680 pixels. The image will be cropped from the sides to make it fit the desired aspect ratio. The cropped image will be centered in the original image.
Step2: Calculate Coordinates
Next, we will calculate the start and end coordinates for the panning effect. The panning will start from the center, move to the right, return to the center, move to the left, and finally return to the center. The frame step will be 8 pixels as per your request. Let’s calculate these coordinates.
Step3: Adjust Dimensions of Frames
It appears we encountered an error. The error message indicates that all images in a video should have the same size. This error is likely because the FFMPEG writer in imageio is resizing the frames due to the dimensions not being divisible by the macro_block_size, which is a requirement for many video codecs and players.
Step4: Recalculate the Panning Distance
I apologize for the inconvenience. The error suggests that there are frames in the video that do not have the same size. This could have occurred due to an issue with the frame cropping process during the panning effect. I will re-check the process to identify and correct the issue.
Step5: Handle AssertionError & Generate Video from Image using ChatGPT
We encountered an AssertionError which means that there’s at least one frame in the video that doesn’t have the same size as the others. This inconsistency might be due to the coordinates going beyond the dimensions of the image during the panning effect.