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!
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
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:
- player's problem
- you were exit before the video transcode finished
- 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~)