findPub

findPub

👀发现有趣的公开频道/群组 有趣的链接,适合有趣的人 投稿/交流:https://t.me/FindPub
tg_channel
telegram

FFmpeg Image Processing

The following commands are used to process input files (image_source) and generate output files (out_source):

  1. Image compression: ffmpeg can compress images perfectly and generate new compressed images with a specified compression level.

    ffmpeg -i image_source -q compress_level out_source

    compress_level: a positive integer indicating the compression level. The higher the value, the higher the compression level.#

  2. Proportional compression: ffmpeg can compress images to a specified size while maintaining the original aspect ratio.

    ffmpeg -i image_source -vf scale=width out_source

    width: the width of the compressed image#

    height: the height of the compressed image#

    If either width or height is set to -1, the original aspect ratio will be maintained during compression.#

  3. Image cropping: ffmpeg can specify the cropping position and size of an image.

    ffmpeg -i image_source -vf crop=width:height:from_x out_source

    width: the width of the cropped image#

    height: the height of the cropped image#

    from_x: the starting position on the X-axis for cropping#

    from_y: the starting position on the Y-axis for cropping#

    If from_x and from_y are not specified, the cropping will start from the center of the original image.#

  4. Adding a watermark image: ffmpeg can add a watermark image to an image and specify its size, position, and opacity.

    ffmpeg -i image_source -vf movie=logo_source,scale=logo_width,lut=a=val*opacity_num[watermask];[in][watermask] overlay=from_xout -y out_source

    logo_source: the path of the watermark image#

    logo_width: the width of the watermark image#

    logo_height: the height of the watermark image#

    opacity_num: the opacity of the watermark image#

    from_x: the starting position on the X-axis for the watermark#

    from_y: the starting position on the Y-axis for the watermark#

  5. Adding a text watermark: ffmpeg can add a text watermark to an image and specify the font, color, size, content, and position of the text.

    ffmpeg -i image_source -vf drawtext=fontfile=font_ttf_path=font_color=font_size=message_info=from_x=from_y out_source

    font_ttf_path: the path of the font file (must be set to an absolute path)#

    font_color: the color of the font#

    font_size: the size of the font#

    message_info: the content of the watermark text#

    from_x: the starting position on the X-axis for the watermark#

    from_y: the starting position on the Y-axis for the watermark#

    If the watermark text is in Chinese, a Chinese font must be set to avoid displaying garbled characters.#

  6. Rotating an image by a specified angle: ffmpeg can rotate an image by a specified angle and generate a new image.

    ffmpeg -i image_source -vf rotate=route_num*PI/180 -y out_source

    route_num: the angle of rotation#

    If route_num is greater than 0, the image will be rotated clockwise. If route_num is less than 0, the image will be rotated counterclockwise.#

  7. Special shortcut commands for image rotation: Although the previous command can theoretically perform all image rotation operations, ffmpeg still provides special shortcut commands for rotation.

    ffmpeg -i image_source -vf transpose=route_number -y out_source

    route_number=0: rotate 90 degrees clockwise and then mirror horizontally#

    route_number=1: rotate 90 degrees clockwise#

    route_number=2: rotate 90 degrees counterclockwise#

    route_number=3: rotate 90 degrees counterclockwise and then mirror horizontally#

  8. Horizontal flip of an image:

    ffmpeg -i image_source -vf hflip out_source

  9. Vertical flip of an image:

    ffmpeg -i image_source -vf vflip out_source

Loading...
Ownership of this post data is guaranteed by blockchain and smart contracts to the creator alone.