Hi all,
This might be useful to some of you wanting to do photogrammetry from videos you've taken with your drones and prepare them for processing with a service like WebODM. This creates excellent orthophotos, point clouds, and 3D models from your scenes.
This is not point and click, this is all command line stuff. But it's free. And if you use this often and with varying requirements, you'll soon discover that being able to script all of this is far superior to having to point and click yourself through windows...
Speaking of windows... I don't use (capital) Windows so I can't help you figuring out how to run it there, but I am told it's easy and all the software packages you need are available.
First you need to install some freely available software:
- ffmpeg FFmpeg
- python Python Releases for Windows
- exiftool ExifTool by Phil Harvey
- my scripts srt_tag.py and srt_concat.py tagtools.zip
Remember these are command line tools, you can generally run them with the -h command for help. For example, run my scripts using the command line
or
to figure out what parameters you need to give it.
If all of your video frames are split over multiple videos, skip this and read further down how to concatenate the videos and SRT files first.
If using a single video, process as follows:
1. convert video footage to frames:
fps=1 means extract one frame for every second of movie. If you want one frame every 2 seconds, use fps=0.5. framesdirectory is simply the name of the directory where you want the frames to go.
2. Then you need to geotag the extracted frames. Video frames do not have that built in automatically unlike still photos. But this can to a large degree be done using the SRT file:
-p 30 means the original footage was shot at 30 frames per second, -x is the file extension, you can also export png if you want in the ffmpeg export step above (creates much improved quality orthophotos, but the png's are 10x the size of the jpg). -f 1 means the frames are at 1 frame per second in the original footage. This is important so it knows which SRT frame number to use for the data.
3. Then you simply add those frames to your WebODM project and hit upload and go. Done!
If you need concatenate the videos first, follow these instructions:
1. Concatenate the videos. Create a file (I called that files.txt) that has a line like this for every video file you want to add to the resulting video:
2. Create the output video from this using this command:
3. Create a concatenated SRT file that has the correct data for each frame:
4. Now export the frames, same as above:
5. And geotag the output files, again, same as above:
6. Upload to your WebODM project and done!
Hope this helps!
This might be useful to some of you wanting to do photogrammetry from videos you've taken with your drones and prepare them for processing with a service like WebODM. This creates excellent orthophotos, point clouds, and 3D models from your scenes.
This is not point and click, this is all command line stuff. But it's free. And if you use this often and with varying requirements, you'll soon discover that being able to script all of this is far superior to having to point and click yourself through windows...
Speaking of windows... I don't use (capital) Windows so I can't help you figuring out how to run it there, but I am told it's easy and all the software packages you need are available.
First you need to install some freely available software:
- ffmpeg FFmpeg
- python Python Releases for Windows
- exiftool ExifTool by Phil Harvey
- my scripts srt_tag.py and srt_concat.py tagtools.zip
Remember these are command line tools, you can generally run them with the -h command for help. For example, run my scripts using the command line
Code:
python srt_tag.py -h
Code:
python srt_concat.py -h
If all of your video frames are split over multiple videos, skip this and read further down how to concatenate the videos and SRT files first.
If using a single video, process as follows:
1. convert video footage to frames:
Code:
ffmpeg -i DJI_0123.MP4 -vf fps=1 framesdirectory/%04d.jpg
fps=1 means extract one frame for every second of movie. If you want one frame every 2 seconds, use fps=0.5. framesdirectory is simply the name of the directory where you want the frames to go.
2. Then you need to geotag the extracted frames. Video frames do not have that built in automatically unlike still photos. But this can to a large degree be done using the SRT file:
Code:
python srt_tag.py -s DJI_0123.SRT -d framesdirectory/ -p 30 -x jpg -f 1
-p 30 means the original footage was shot at 30 frames per second, -x is the file extension, you can also export png if you want in the ffmpeg export step above (creates much improved quality orthophotos, but the png's are 10x the size of the jpg). -f 1 means the frames are at 1 frame per second in the original footage. This is important so it knows which SRT frame number to use for the data.
3. Then you simply add those frames to your WebODM project and hit upload and go. Done!
If you need concatenate the videos first, follow these instructions:
1. Concatenate the videos. Create a file (I called that files.txt) that has a line like this for every video file you want to add to the resulting video:
Code:
file '/Volumes/Video/Footage/2022-12-16/Hill/DJI_0251.MP4'
file '/Volumes/Video/Footage/2022-12-16/Hill/DJI_0252.MP4'
2. Create the output video from this using this command:
Code:
ffmpeg -f concat -safe 0 -i files.txt -c copy output.mp4
3. Create a concatenated SRT file that has the correct data for each frame:
Code:
python srt_concat.py -i concat_files.txt -o output.srt
4. Now export the frames, same as above:
Code:
ffmpeg -i output.mp4 -vf fps=1 framesdirectory/%04d.jpg
5. And geotag the output files, again, same as above:
Code:
python srt_tag.py -s output.srt -d framesdirectory/ -p 30 -x jpg -f 1
6. Upload to your WebODM project and done!
Hope this helps!
Last edited: