5

I need scale up video from one DOS game using FFmpeg. But with Nearest-neighbor interpolation on left side and xBR filter on the other one.

Input (320x200)

enter image description here

Output (1280x800)

enter image description here

Here is a command, where's xBR processing whole screen...

ffmpeg
    -i input.avi
    -sws_flags neighbor
    -vcodec libx264 -strict -2
    -preset veryslow -qp 0
    -filter:v "xbr=4"
    output.mp4

1 Answer 1

9

Left & right

Different filter on each side
I cropped the image to make the output size smaller just for display purposes.

This will show the whole video on each side. Left is xbr and right is scale.

Using hstack

ffmpeg -i input.avi -filter_complex \
"[0:v]xbr=4[bg]; \
 [0:v]scale=iw*4:-1:flags=neighbor[fg]; \
 [bg][fg]hstack,format=yuv420p[v]" \
-map "[v]" -map 0:a -movflags +faststart output.mp4

All input streams to hstack must have the same pixel format and same width.

Using pad & overlay

ffmpeg -i input.avi -filter_complex \
"[0:v]xbr=4,pad=iw*2[bg]; \
 [0:v]scale=iw*4:-1:flags=neighbor[fg]; \
 [bg][fg]overlay=w,format=yuv420p[v]" \
-map "[v]" -map 0:a -movflags +faststart output.mp4

This method is slower and more complex than just using hstack.


Left & right: With 10 pixel border

With 10 pixel border

ffmpeg -i input.avi -filter_complex \
"[0:v]xbr=4,pad=iw*2+10[bg]; \
 [0:v]scale=iw*4:-1:flags=neighbor[fg]; \
 [bg][fg]overlay=w+10,format=yuv420p[v]" \
-map "[v]" -map 0:a -movflags +faststart output.mp4

Split screen: left & right

Split screen: left & right

ffmpeg -i input.avi -filter_complex \
"[0:v]xbr=4[bg]; \
 [0:v]scale=iw*4:-1:flags=neighbor,crop=iw/2:ih:ow:0[fg]; \
 [bg][fg]hstack[v]" \
-map "[v]" -map 0:a -movflags +faststart output.mp4

Top & bottom

Top & bottom

Using vstack

ffmpeg -i input.avi -filter_complex \
"[0:v]xbr=4[bg]; \
 [0:v]scale=iw*4:-1:flags=neighbor[fg]; \
 [bg][fg]vstack,format=yuv420p[v]" \
-map "[v]" -map 0:a -movflags +faststart output.mp4

All input streams to vstack must have the same pixel format and same width.

Using pad & overlay

ffmpeg -i input.avi -filter_complex \
"[0:v]xbr=4,pad=iw*2[bg]; \
 [0:v]scale=iw*4:-1:flags=neighbor[fg]; \
 [bg][fg]overlay=0:h,format=yuv420p[v]" \
-map "[v]" -map 0:a -movflags +faststart output.mp4

This method is slower and more complex than just using vstack.


Split screen: top & bottom

Split screen: top & bottom

ffmpeg -i input.avi -filter_complex \
"[0:v]xbr=4[bg]; \
 [0:v]scale=iw*4:-1:flags=neighbor,crop=iw:ih/2:0:oh[fg]; \
 [bg][fg]vstack[v]" \
-map "[v]" -map 0:a -movflags +faststart output.mp4
1

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .