<p>You can just use the crop filter.</p>

<pre><code>ffmpeg -loop 1 -t 10 -i img.png
       -vf "crop=w=W:h=ih:x='(iw-W)*t/10':y=0"
       -r 25 -pix_fmt yuv420p out.mp4
</code></pre>

<p>The crop filter crops the image to <code>Wxih</code> pixels where ih is the original height. You should substitute W with your target width in pixels. The position of the top-left corner of the crop window is set by the x and y expressions.</p>

<p>Since you only want to move left-to-right, y is set to a fixed 0. For x, the expression <code>(iw-W)*t/10</code> governs the horizontal position of the crop window. <code>t</code> is the processed frame's timestamp in fractional seconds. <code>W</code> is substituted with the target width. <code>iw</code> is the input width. The crop will start from the left edge and end at the right edge at t = 10 seconds.</p>

<hr>

<p>For an image sequence of 10 seconds, use</p>

<pre><code>ffmpeg -i img%d.png
       -vf "crop=w=W:h=ih:x='(iw-W)*t/10':y=0"
       -r 25 -pix_fmt yuv420p out.mp4
</code></pre>

CC BY-SA 4.0
2018-05-10T13:33:54.203Z
Looks good, the produced video thumbnail looks correct but the duration of the video is near 0. I tried to add :d=10 to the expresion and add -t to the general command and doesn't works.

Current command
```ffmpeg -y -framerate 1/10 -i test.jpg -vf "crop=w=1080:h=ih:x='(iw-1080)*t/10' :y=0" -r 25 -pix_fmt yuv420p outpanoramic.mp4
```
Aracem
CC BY-SA 4.0
2018-05-10T13:39:56.950Z
The command in your Q implies an image sequence `img%d.png` but you're applying to a single image. I'll modify my command for this case.
Gyan
CC BY-SA 4.0
2018-05-10T14:23:36.757Z
Perfect! It works now. Thank you very much!

I suggest you edit your answer to include both solutions, for one and for several images, perhaps someone find it useful
Aracem
CC BY-SA 4.0
2019-07-31T21:39:51.097Z
@Gyan what if I already made some changes to the video stream in filter_complex and named it [trimmed], how would I make a long input image to overlay from bottom to top and be able to set its speed?
r.mirzojonov
CC BY-SA 4.0
2019-08-01T04:45:01.480Z
Post a new Q with your full command.
Gyan
CC BY-SA 4.0
2018-05-10T05:30:59.503Z
2018-05-10T14:45:00.317Z
2018-05-10T14:45:00.317Z
Gyan
<p>I trying to create a video from a landscape image that moves from left to right of the image.</p>

<p>One form that I thought I can get this done is firstly generating N cropped images from the original one, each of them cropped more and more to the right and then apply some command like this one:</p>

<p><code>
  ffmpeg -framerate 1/X -i img%d.png -r 25 -pix_fmt yuv420p out.mp4
</code></p>

<p>This for sure works but is not the quickest and cleaning form to do it.
Are there a better method to accomplish this?</p>

<video><ffmpeg>
Create a video from a landscape image with ffmpeg
Aracem
# Create a video from a landscape image with ffmpeg

(Asked by: username_0 on 2018-05-09)

I trying to create a video from a landscape image that moves from left to right of the image.

One form that I thought I can get this done is firstly generating N cropped images from the original one, each of them cropped more and more to the right and then apply some command like this one:

`ffmpeg -framerate 1/X -i img%d.png -r 25 -pix_fmt yuv420p out.mp4`

This for sure works but is not the quickest and cleaning form to do it.
Are there a better method to accomplish this?

**Tags:** video, ffmpeg


---

## 1 answers

### Answer by username_1 on 2018-05-10. Score: 1 | Accepted answer

You can just use the crop filter.
ffmpeg -loop 1 -t 10 -i img.png
       -vf "crop=w=W:h=ih:x='(iw-W)*t/10':y=0"
       -r 25 -pix_fmt yuv420p out.mp4

The crop filter crops the image to Wxih pixels where ih is the original height. You should substitute W with your target width in pixels. The position of the top-left corner of the crop window is set by the x and y expressions.
Since you only want to move left-to-right, y is set to a fixed 0. For x, the expression (iw-W)*t/10 governs the horizontal position of the crop window. t is the processed frame's timestamp in fractional seconds. W is substituted with the target width. iw is the input width. The crop will start from the left edge and end at the right edge at t = 10 seconds.

For an image sequence of 10 seconds, use
ffmpeg -i img%d.png
       -vf "crop=w=W:h=ih:x='(iw-W)*t/10':y=0"
       -r 25 -pix_fmt yuv420p out.mp4

> **Comments:**
> **username_0**: Looks good, the produced video thumbnail looks correct but the duration of the video is near 0. I tried to add :d=10 to the expresion and add -t to the general command and doesn't works.  Current command ```ffmpeg -y -framerate 1/10 -i test.jpg -vf "crop=w=1080:h=ih:x='(iw-1080)*t/10' :y=0" -r 25 -pix_fmt yuv420p outpanoramic.mp4 ```  
> **username_1**: The command in your Q implies an image sequence `img%d.png` but you're applying to a single image. I'll modify my command for this case.  
> **username_0**: Perfect! It works now. Thank you very much!  I suggest you edit your answer to include both solutions, for one and for several images, perhaps someone find it useful  
> **username_2**: @username_1 what if I already made some changes to the video stream in filter_complex and named it [trimmed], how would I make a long input image to overlay from bottom to top and be able to set its speed?  
> **username_1**: Post a new Q with your full command.  

---

