Created
March 30, 2020 06:14
-
-
Save jagedn/7dd11ce2b12c54390b973c168b058397 to your computer and use it in GitHub Desktop.
Descarga las cámaras de tráfico de Madrid para poder construir un mp4 con ella posteriormente
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import groovy.util.slurpersupport.GPathResult | |
new File("madrid").deleteDir() | |
new File("madrid").mkdirs() | |
xml = 'http://informo.munimadrid.es/informo/tmadrid/CCTV.kml'.toURL().getText("ISO-8859-1") | |
xml = xml.substring(xml.indexOf('<')) // el kml tiene caracteres erróneos al principio, así es Madrid | |
kml = new XmlSlurper().parseText(xml).declareNamespace("xmlns":"http://earth.google.com/kml/2.2") | |
kml.Document.Placemark.sort{ | |
it.ExtendedData.Data[1].Value.text() | |
}.eachWithIndex{ item, idx-> | |
String description = item.description.text() | |
String url = description.split(' ').find{ it.startsWith('src=')}.substring(4) | |
new File("madrid/madrid${idx}.jpg").bytes = url.toURL().bytes | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Si tienes instalado groovy simplemente descarga el fichero madrid.groovy en un directorio y ejecuta:
groovy madrid.groovy
Si no tienes, o quieres instalar groovy, puedes ejecutarlo mediante docker:
docker run --rm -v "$PWD":/home/groovy/scripts -w /home/groovy/scripts groovy:latest groovy https://gist.githubusercontent.com/jagedn/7dd11ce2b12c54390b973c168b058397/raw/adcf37a02eef67bd4c4b5c5b2475baa653b04d55/madrid.groovy
El script creará una carpeta
madrid
y descargará todas las imágenes disponibles en ella.Una vez descargadas podrás hacer un mp4 con todas ellas usando ffmpeg:
ffmpeg -framerate 1 -i madrid/madrid%d.jpg -c:v libx264 -profile:v high -crf 20 -pix_fmt yuv420p madrid.mp4
Ejemplo https://www.youtube.com/watch?v=POrXtao5IeQ