Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Grey areas at border of rotated frames / content missing #79

Open
mviereck opened this issue Oct 15, 2019 · 3 comments
Open

Grey areas at border of rotated frames / content missing #79

mviereck opened this issue Oct 15, 2019 · 3 comments

Comments

@mviereck
Copy link

Coming from #78 :

Stabilizing a video can lead to grey areas at the border of the frames.
I've used this video generated from a series of captures:
vidstab.greyborder.source.mp4.zip

This affects many frames, I'll show the last one as an example:
alignimg0060 tif

ffmpeg/vidstab commands I've used:

ffmpeg -y -hide_banner -nostdin -i "align.source.mp4" \
  -vf "vidstabdetect=shakiness=10:accuracy=15:mincontrast=0.1:stepsize=6:show=1"  \
  align.show.mp4

ffmpeg -y -hide_banner -nostdin -i "align.source.mp4" \
  -vf "vidstabtransform=optzoom=0:smoothing=0:interpol=no:relative=1:crop=black:debug=1,unsharp=5:5:0.8:3:3:0.4" \
  align.result.mp4

Extracting angle and offsets from global_motions.trf and applying them with imagemagick, I get this result:
preview_0060 jpg

Comparing the two images shows:

  • The motive in the centre is exactly at the same place
  • The border including the gray area matches the borders of the image distorted with imagemagick.
  • Instead of the grey area there should be content from the source frame. Some content is missing.
@georgmartius
Copy link
Owner

Thanks for the bug report. There is surely something wrong here. I looks like it has something to do with the rotations and the different channels (color vs gray).

@mviereck
Copy link
Author

I found that I can avoid the bug if I split the video into .png images and generate a new video from the .png files:

  ffmpeg -y -hide_banner -nostdin -i align.source.mp4 sourceimg%04d.png
  
  ffmpeg -y -hide_banner -nostdin -f image2 -start_number 1 -i sourceimg%04d.png -safe 0 -vframes 1000 -vcodec libx264 -crf 25  -pix_fmt yuv420p align.source2.mp4

Using vidstab with align.source2.mp4 instead of align.source.mp4 does not show gray areas.

@mviereck
Copy link
Author

If I calculate rotation and distortion from global_motions.trf and apply the values with imagemagick, the result is slightly different from vid.stab. The alignment seems to be slightly better with imagemagick.
I assume there is some imprecision in the distortion of vid.stab that also might cause the difference between image and grey area as described above.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants