Monday, 22 April 2019

How to offset a video horizontally in ffmpeg?


I'm trying to make some 360° video, where the leftmost side shall be connected to the rightmost side in the interactive player.


Instead of setting that in the player, how can I shift the content by 50 pixels to the right and fill the new gap on the left side with the rightmost 50 pixel column, which got moved off the frame after the shift?


It's similar to the offset function in Photoshop, but I couldn't get it right with ffmpeg.



Answer



normal mandelbrot offset mandelbrot Mandelbrot examples: normal and offset to the right by 50 pixels.


You can use the overlay video filter:


ffmpeg -i input.mp4 -filter_complex \
"[0:v][0:v]overlay=50:0[bg]; \
[bg][0:v]overlay=50-W,format=yuv420p[out]" \
-map "[out]" -map 0:a -codec:v libx264 -crf 23 -preset medium -c:a copy out.mp4



  • format=yuv420p will ensure that your output will use a chroma subsampling scheme that playable by non-FFmpeg based players.




  • The audio will be stream copied instead of re-encoded.




  • Make sure you're using a recent build of ffmpeg. See the FFmpeg Download page for links to builds for Linux, OS X, and Windows.




  • See the FFmpeg and x264 Encoding Guide for additional information on getting a good output quality.




No comments:

Post a Comment

How can I VLOOKUP in multiple Excel documents?

I am trying to VLOOKUP reference data with around 400 seperate Excel files. Is it possible to do this in a quick way rather than doing it m...