-loop and -framerate Errors
Why -loop or -framerate stops a job on audio or video, and how to check what your file really is
You will see this when an input has -loop on it and the file is not a format that option works on:
> Invalid input option: -loop does not work on inputs[0] (format: mp3). It works on still image formats such as PNG and JPEG, and a file's name does not settle its format, so check that this input is the file you meant to send. To repeat audio, video or a GIF, use -stream_loop.
-framerate on an audio file or an MP4 stops the same way, in FFmpeg's words with our advice after them:
> FFmpeg command failed: Option framerate not found. Invalid option for this file type. -loop works only on image inputs, and -framerate only on image and raw video inputs. A file's name does not settle its format, so check that each input is the file you meant to send. To repeat a file, use -stream_loop. To set a frame rate, use -r on the output.
-loop belongs to FFmpeg's image readers, and audio and video readers do not have it, so FFmpeg stops before reading a frame. -framerate also works on raw video streams such as .h264. The -loop refusal stops a job before it is billed.
File Check
A file named image.jpg can still be audio. Check what is inside it:
ffprobe -v error -show_entries format=format_name -of csv=p=0 image.jpg
| Output | What the file is |
|---|---|
image2 | A still image: -loop applies |
A name ending in _pipe, such as png_pipe, jpeg_pipe, webp_pipe, bmp_pipe or tiff_pipe | An image reader: -loop applies. One picture is a still image. A file holding many pictures, such as a Motion JPEG stream, plays as video |
mjpeg | The Motion JPEG reader: one picture is a still image and many play as video, but -loop does not apply |
gif, apng | An animation: use -stream_loop |
mp3, avi, mov,mp4,m4a,3gp,3g2,mj2 | Audio or video, whatever the file is called |
An error line before the format, such as No JPEG data found in image | Not a usable image. A web page or error response saved as image.jpg looks like this |
A name ending in _pipe does not say how many pictures the file holds. Count them:
ffprobe -v error -count_packets -select_streams v:0 -show_entries stream=nb_read_packets -of csv=p=0 image.webp
A count of 1 is a still image, which adds no input minutes. A higher count is billed as video: the count divided by the frame rate, which is 25 frames per second unless the input sets -framerate or -r. With -loop a stream like that repeats, so set -t or -shortest to end the output.
Common Causes
image.jpg hides the mistake, because the stored file keeps that extension.-loop has to sit on the image.-stream_loop.@quote-card adds -loop to its profile image, and to a background whose URL ends in .png, .jpg, .jpeg or .webp, so check the files at profileImageUrl and backgroundUrl.Solutions
-loop
Put it on the image:
{
"inputs": [
{
"url": "gs://your-bucket/image.jpg",
"options": [{ "option": "-loop", "argument": "1" }]
},
{ "url": "gs://your-bucket/audio.mp3" }
],
"outputFormat": "mp4",
"options": [
{ "option": "-c:v", "argument": "libx264" },
{ "option": "-c:a", "argument": "aac" },
{ "option": "-shortest" },
{ "option": "-pix_fmt", "argument": "yuv420p" }
]
}
-stream_loop
This repeats audio, video or a GIF. The argument is how many extra times it plays:
{
"inputs": [
{
"url": "gs://your-bucket/clip.mp4",
"options": [{ "option": "-stream_loop", "argument": "1" }]
}
],
"outputFormat": "mp4"
}
-r
To set the frame rate of a video, put -r on the output in options.
Related Articles
Why an audio-only conversion is refused, and how to check whether your source has sound
Why -filter_complex is blocked and what to use instead for overlays, text, concatenation, and other complex video operations
Can't find what you're looking for?