mapillary / mapillary_tools

Command line tools for processing and uploading Mapillary imagery
BSD 2-Clause "Simplified" License
264 stars 137 forks source link

[Feature Request] Allow png when extracting samples from video #626

Closed joshinils closed 1 year ago

joshinils commented 1 year ago

currently the call to ffmpeg only uses jpg when extracting images; https://github.com/mapillary/mapillary_tools/blob/a3964b6918fbbcd97c08a0db1677f4e61cbbcdb6/mapillary_tools/ffmpeg.py#L20

I'd like to have this exposed as a setting, so I can extract png, which hopefully are of better quality than jpg.

the quality control argument for ffmpeg is omitted: https://github.com/mapillary/mapillary_tools/blob/a3964b6918fbbcd97c08a0db1677f4e61cbbcdb6/mapillary_tools/ffmpeg.py#L269

according to https://stackoverflow.com/a/10234065/10314791 ffmpeg uses the default of -q:v 2 which is not lossless

ptpt commented 1 year ago

There is no PNG support at the server side so it's unlikely for mapillary_tools to upload them.

Do you have any highest quality samples uploaded we can check? If it's that significantly improvement, we can consider it as the default option, or expose -q:v $QUALITY_VALUE to the users.

joshinils commented 1 year ago

https://www.mapillary.com/app/?panos=true&lat=52.6331496&lng=13.2916513&z=17&dateFrom=2023-01-01&username%5B%5D=cyton&pKey=1633345693801133&focus=photo&x=0.03062270562499947&y=0.42070207684694805&zoom=3 was uploaded with the unchanged jpg and -qscale 2

I have now changed the .../mapillary_tools/ffmpeg.py file to png, and to jpg with -qscale 1, to get comparable images of the street name sign;

-qscale 2 = 2.551 MB GS015642_NA_001707 jpg2

-qscale 1 = 2.547 MB GS015642_NA_001707 jpg1

png = 51.500 MB GS015642_NA_001707

when I zoom in, I can see the 8x8 jpeg compression blocks and artifacts, but no discernible quality difference between qscale 1 and qscale 2. The png does not have those blocks, but the filesize increase of 20x is not worth it.

With that, and the fact that the website probably would need jpeg anyway to serve, I will close this, since it doesn't make any difference in the end.

I was just hoping that the quality loss came from that, not because I sampled the frames from a Video, instead of setting the gopro max to record a frame every two seconds.