An additional solution with a different approach from the last mentioned solutions, is to check if your camera driver support the v4l2 camera controls (which is very common).
In the terminal just type:
v4l2-ctl -L
If your camera driver supports the v4l2 camera controls, you should get something like this (the list below depends on the controls that your camera driver supports):
contrast (int) : min=0 max=255 step=1 default=0 value=0 flags=slider
saturation (int) : min=0 max=255 step=1 default=64 value=64 flags=slider
hue (int) : min=0 max=359 step=1 default=0 value=0 flags=slider
white_balance_automatic (bool) : default=1 value=1 flags=update
red_balance (int) : min=0 max=4095 step=1 default=0 value=128 flags=inactive, slider
blue_balance (int) : min=0 max=4095 step=1 default=0 value=128 flags=inactive, slider
exposure (int) : min=0 max=65535 step=1 default=0 value=885 flags=inactive, volatile
gain_automatic (bool) : default=1 value=1 flags=update
gain (int) : min=0 max=1023 step=1 default=0 value=32 flags=inactive, volatile
horizontal_flip (bool) : default=0 value=0
vertical_flip (bool) : default=0 value=0
And if you are lucky it supports horizontal_flip and vertical_flip.
Then all you need to do is to set the horizontal_flip by:
v4l2-ctl --set-ctrl horizontal_flip=1
or the vertical_flip by:
v4l2-ctl --set-ctrl vertical_flip=1
and then you can call your video device to capture a new video (see example below), and the video will be rotated/flipped.
ffmpeg -f v4l2 -video_size 640x480 -i /dev/video0 -vcodec libx264 -f mpegts input.mp4
Of-course that if you need to process an already existing video, than this method is not the solution you are looking for.
The advantage in this approach is that we flip the image in the sensor level, so the sensor of the driver already gives us the image flipped, and that's saves the application (like FFmpeg) any further and unnecessary processing.