numberwolf / FFmpeg-PlusPlus

🔥 FFmpeg扩展版本,1.支持OpenGL图形渲染,自定义着色器 滤镜、特效、转场。2.支持FLV+HEVC/AV1/Opus编码解码 🔥 FFmpeg Extension: 1.Support GLSL OpenGL(Filter/Effect/Transition/Shaders); 2. And Transcode FLV with HEVC/AV1/Opus Codec

Home Page:https://www.zzsin.com/shaderplus.html

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

There is a black bar at the bottom of the output video after applying the effect ?

zomeelee opened this issue · comments

Hi, @numberwolf, thank you for your nice work! I can now apply effects on videos, but sometimes(not always) there is a black bar at the bottom in the output video, and i am sure the input is all right. Do you have any idea why did it happened? I can provide more details if necessary. Thank you!
Screen Shot 2021-05-26 at 4 45 43 PM

Hi, @zomeelee
Can you give me your input video with your filter content?

I need to check here's problem.

And your shader files

Hi, @numberwolf, thank you for your reply! As I used a bash file to process multiple videos at one time, this is the command that I used:

add_effect_on_video_command_line=(./ffmpeg -i ${effect_in_file} -filter_complex "[0:v]plusglshader=sdsource='${effect_fragment_shader}':vxsource='${effect_vertex_shader}'" -c:v libx264 -pix_fmt yuv420p -y ${current_effect_out_video})

and the vertex shader is:

attribute vec2 position;
varying vec2 TextureCoordsVarying;
const float PI = 3.1415926;
uniform float playTime;

void main(void)
 {
    gl_Position = vec4(position, 0, 1);
    TextureCoordsVarying.x = position.x * 0.5 + 0.5;
    TextureCoordsVarying.y = position.y * 0.5 + 0.5;
}

and the fragment shader is:

uniform sampler2D tex;
varying vec2 TextureCoordsVarying;
uniform float playTime;


void main() {
    //TextureCoordsVarying.x = TextureCoordsVarying.x * 0.5 + 0.5;
    //TextureCoordsVarying.y = TextureCoordsVarying.y * 0.5 + 0.5;

    float duration = 0.7;
    float maxAlpha = 0.4;
    float maxScale = 1.8;

    float progress = mod(playTime, duration) / duration; // 0~1
    float alpha = maxAlpha * (1.0 - progress);
    float scale = 1.0 + (maxScale - 1.0) * progress;


    vec2 uv = TextureCoordsVarying.xy;
    vec4 col = vec4(1.0);

    gl_FragColor = texture2D(tex, uv)*vec4(1.0, 1.0, 0.5, 0.5);
}

and the input and output video are as below:

input.mp4
output.mp4

I have rerun it on my macbook. It's successed.
suc

Which your system? Linux without video card , mac or windows?

I need your enviorment's informations.

Did you running with xvfb?

Successed on Ubuntu without video card.

See:
http://hevc.xvideo.video/output.mp4

my code:

local file_path="./github-gl-badcase.mp4"
    shadername="old"

    xvfb-run -a --server-args="-screen 0 1280x720x24 -ac -nolisten tcp -dpi 96 +extension RANDR" \
    ./ffmpeg -v debug \
    -ss 0 -t 5 \
    -i $file_path \
    -filter_complex \
    "plusglshader=sdsource=./${shadername}_shader.gl:vxsource=./${shadername}_vertex.gl:duration=5" \
    -vcodec libx264 \
    -an \
    -pix_fmt yuv420p \
    -y output.mp4

Hi, @numberwolf ,
my environment is :
MacBook Pro,
macOS Big Sur = 11.2.3,
ffmpeg=4.3.2

It's very strange that the black bar at the bottom sometimes appears, and sometimes when I export the video once again, it's gone! what's the reason maybe behind the strange thing?

Emmmm...

I guess the reasons:

  1. player's problem
  2. you were exit before the video transcode finished
  3. video card's problem?

Hi, @numberwolf,
thank you for your time and suggestions!

After testing many times, it seems that the strange thing happens because of the external monitor. Almost everytime when my MacBook connects to the external monitor, the black bar appears in the output video, but when I unplug the external monitor, the result is OK.

I don't know what's the real reason behind it. Maybe the external monitor changes the OpenGL Context?

Thank you once again for your nice work, @numberwolf !

Its my pleasure~
( I think reason was render with threads on diff multi video-card's problem~)