time4tea / gopro-dashboard-overlay

Programs to process GoPro MP4 & Generic GPX/FIT files and create video dashboards & maps
GNU General Public License v3.0
384 stars 52 forks source link

Tool to rotate video files #76

Open kfhdk opened 2 years ago

kfhdk commented 2 years ago

Hi,

I made a little tool to rotate video files as the orientatation sometimes is wrong. I mount my gopro upside down on my bike. It rotates the video by setting metadata in the file. https://github.com/time4tea/gopro-dashboard-overlay/compare/main...kfhdk:gopro-dashboard-overlay:rotate

time4tea commented 1 year ago

Thank you for submitting this! - However... could it be simpler just as a ffmpeg command line? Is the python code required? If it were an ffmpeg command line I'd be happy to include it in the docs.

KyleGW commented 1 year ago

I've used both ffmpeg and exiftool to accomplish adding the rotation metadata to a file when I forgot to unlock the orientation lock on the gopro, and recorded with it upside down. Note this just adds the rotation metadate which many players will support. Neither of these actually re-encodes the file with a rotation applied to the video stream. If you need to do that, the commands below are not what you need.

ffmpeg command: ffmpeg -i input.mp4 -map_metadata 0 -metadata:s:v rotate="180" -codec copy output.mp4

exiftool (this will make a copy of the file with the metadata applied: exiftool.exe -rotation=180 -api LargeFileSupport=1 input.MP4

bphilli7 commented 3 months ago

Add this filter line to an ffmpeg profile will rotate the source video 180 deg during the gopro-dashboard.py rendering step:

"filter": "[0:v]rotate=PI:c=none:ow=rotw(0):oh=roth(0)[rotate0];[rotate0][1:v]overlay",

Adjust the "rotate=PI" argument for other rotation angles (e.g. PI/2)