Q:

Create a video from a landscape image with ffmpeg

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?

A:

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

