# Install ffmpeg, then run pip install ffmpeg-python
import ffmpeg
import os
# Put the videos you want to process in the "videos" folder
DIR = "videos"
def flip_video(path):
try:
(
ffmpeg.input(path)
.filter("hflip")
.output(
# Multiple ways to change metadata here
# 1. map_metadata=-1 - removes all metadata generated by FFMpeg
# 2. metadata="title=METADATA MAN"" - adds the metadata you want to add.
# To add multiple metadata params, just use the syntax below
path.replace(
".mp4",
"_flipped.mp4",
# map_metadata=-1,
# metadata="title=METADATA MAN",
{
"metadata:g:0": "title=My Title",
"metadata:g:1": "artist=Me",
"metadata:g:2": "album=X",
"metadata:g:3": "year=2019",
},
)
)
.run()
)
return True
except ffmpeg.Error as e:
print(e.stderr)
return False
def main():
files = os.listdir(DIR)
for file in files:
path = os.path.join(DIR, file)
flip_video(path)
if __name__ == "__main__":
main()