gmic-py icon indicating copy to clipboard operation
gmic-py copied to clipboard

video output is flickering badly after engrave

Open eyaler opened this issue 3 years ago • 1 comments

i am getting weird flickering when trying to apply engrave to a video gmic.run('input /content/input.mp4 fx_engrave 0.5,50,0.8,40,0,0,0,10,1,0,0,0,1,0,50,50 output /content/gmic.mp4,24.800000')

what i tried:

  • made sure my code works ok when using other filters
  • made sure this issue happens also for other videos
  • tried both b/w engrave as above as well as the color option
  • made sure the issue happens also with the default fps, different fps, different codec (btw seems that gmic is not able to output with codec AVC1)
  • gmic-py 2.9.2 and 2.9.4a1
  • I ran engrave filter on video in ZART and did not see a similar issue

possible solutions:

  • perhaps engrave outputs more than one layer and they get interleaved with the frames and i should be doing some merging?
  • i know i can break the video to frames and apply it on the images however i timed it and running on video was ~25% faster.

colab to reproduce (just run it): https://colab.research.google.com/drive/1cUDQhdlMJZee8qYa9BZkWK4cxYfDSjqF?usp=sharing

video showing issue is attached (warning - heavy flickering!):

https://user-images.githubusercontent.com/4436747/120935692-99df1100-c70c-11eb-9190-758a3f57e8b0.mp4

eyaler avatar Jun 06 '21 18:06 eyaler

i had several issues going on here:

  1. i accidentally had 0.8 in my argument list where i wanted 0,8... this meant that the remainder of the arguments where off by one and i was actually always running the engrave with the color option. if you run it with out the color option it works out of the box for videos
  2. indeed for the color option you get two outputs for each frame. if you are working with images you can use the gui_merge_layers command to blend them. however for video this does not work as it would merge all video frames to just one. you need to iterate over pairs... but i did not find an easy way to do that.
  3. i ended up substituting the fx_engrave with fx_engrave_preview which takes care of dealing with multiple images.

i have few questions remaining open so i will leave the issue open for now:

  1. for a given filter how can one now how many output layers to expect?
  2. when running on videos what would be the canonical way to merge all per-frame outputs to single frames (without knowing the number of outputs per frame)
  3. seems that some filters can also change the number of output channels. how can i know what to expect?

eyaler avatar Jun 11 '21 22:06 eyaler