LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 08-31-2019, 04:53 AM   #1
linustalman
LQ Guru
 
Registered: Mar 2010
Location: Ireland
Distribution: Debian 12 Bookworm
Posts: 5,725

Rep: Reputation: 479Reputation: 479Reputation: 479Reputation: 479Reputation: 479
Question How to fix an upsidedown video?


Hi.

I've got a video that's upsidedown. How can this be fixed? Preferably without reencoding?

Thanks.
 
Old 08-31-2019, 05:57 AM   #2
petelq
Member
 
Registered: Aug 2008
Location: Yorkshire
Distribution: openSUSE(Leap and Tumbleweed) and a (not so) regularly changing third and fourth
Posts: 627

Rep: Reputation: Disabled
You can do it with ffmpeg. Something like
Code:
ffmpeg -i in.mp4 -vf "transpose=2" out.mp4
The only problem is I can't remember the transpose number.I think it's 1 to 4, so you could experiment. You might get it right first time or have to scrap 3 files.
 
1 members found this post helpful.
Old 08-31-2019, 09:26 AM   #3
linustalman
LQ Guru
 
Registered: Mar 2010
Location: Ireland
Distribution: Debian 12 Bookworm
Posts: 5,725

Original Poster
Rep: Reputation: 479Reputation: 479Reputation: 479Reputation: 479Reputation: 479
Quote:
Originally Posted by petelq View Post
You can do it with ffmpeg. Something like
Code:
ffmpeg -i in.mp4 -vf "transpose=2" out.mp4
The only problem is I can't remember the transpose number.I think it's 1 to 4, so you could experiment. You might get it right first time or have to scrap 3 files.
I tried all 4 numbers - the orientation was always wrong. I think something is up with my original video/encoding method though (I originally converted from .mp4 to .mkv) - your command is likely fine.

This did work but it did not keep the video as VP8 and Vorbis (it only kept Vorbis)
Code:
ffmpeg -i 1.mkv -vf vflip,hflip -r 30 -qscale 0 -acodec copy 2.mkv
 
Old 08-31-2019, 09:38 AM   #4
Firerat
Senior Member
 
Registered: Oct 2008
Distribution: Debian sid
Posts: 2,683

Rep: Reputation: 783Reputation: 783Reputation: 783Reputation: 783Reputation: 783Reputation: 783Reputation: 783
try
Code:
-vf "transpose=2,transpose=2"
 
Old 08-31-2019, 09:47 AM   #5
Firerat
Senior Member
 
Registered: Oct 2008
Distribution: Debian sid
Posts: 2,683

Rep: Reputation: 783Reputation: 783Reputation: 783Reputation: 783Reputation: 783Reputation: 783Reputation: 783
you could just do this in playback with mpv

Code:
mpv video.mp4 -vf "transpose=2,transpose=2"
of using ffmpeg you would need to re-encode
 
Old 08-31-2019, 12:20 PM   #6
teckk
LQ Guru
 
Registered: Oct 2004
Distribution: Arch
Posts: 5,140
Blog Entries: 6

Rep: Reputation: 1828Reputation: 1828Reputation: 1828Reputation: 1828Reputation: 1828Reputation: 1828Reputation: 1828Reputation: 1828Reputation: 1828Reputation: 1828Reputation: 1828
Rotate, from my notes.
Code:
ffmpeg -i infile.mp4 ... -vf "transpose=1" outfile.mp4

0 = 90CounterCLockwise and Vertical Flip
1 = 90Clockwise 
2 = 90CounterClockwise 
3 = 90Clockwise and Vertical Flip
Rotate clockwise 90 deg twice to flip
Code:
ffmpeg -i input.mp4 -vf "transpose=1,transpose=1" output.mp4
Or
Code:
ffmpeg -i input2.mp4 -vf "rotate=PI/1" output2.mp4
 
Old 08-31-2019, 02:26 PM   #7
Firerat
Senior Member
 
Registered: Oct 2008
Distribution: Debian sid
Posts: 2,683

Rep: Reputation: 783Reputation: 783Reputation: 783Reputation: 783Reputation: 783Reputation: 783Reputation: 783
ahh, yeah the flip might be important
 
Old 09-01-2019, 09:16 AM   #8
linustalman
LQ Guru
 
Registered: Mar 2010
Location: Ireland
Distribution: Debian 12 Bookworm
Posts: 5,725

Original Poster
Rep: Reputation: 479Reputation: 479Reputation: 479Reputation: 479Reputation: 479
Question

Quote:
Originally Posted by Firerat View Post
you could just do this in playback with mpv

Code:
mpv video.mp4 -vf "transpose=2,transpose=2"
of using ffmpeg you would need to re-encode
Hi Firerat. That didn't work for me.

Code:
mpv 1.mkv -vf "transpose=2,transpose=2"
Output:
Code:
Option vf: transpose doesn't exist.
Error parsing option vf (option could not be parsed)
Setting command line option '--vf=transpose=2,transpose=2' failed.
Exiting... (Fatal error)
 
Old 09-01-2019, 09:17 AM   #9
linustalman
LQ Guru
 
Registered: Mar 2010
Location: Ireland
Distribution: Debian 12 Bookworm
Posts: 5,725

Original Poster
Rep: Reputation: 479Reputation: 479Reputation: 479Reputation: 479Reputation: 479
Question

How could I convert a .mp4 video to have VP8 & Vorbis (to a .mkv or .webm file) and keep the same quality?
 
Old 09-01-2019, 09:21 AM   #10
linustalman
LQ Guru
 
Registered: Mar 2010
Location: Ireland
Distribution: Debian 12 Bookworm
Posts: 5,725

Original Poster
Rep: Reputation: 479Reputation: 479Reputation: 479Reputation: 479Reputation: 479
Exclamation

Quote:
Originally Posted by Firerat View Post
try
Code:
-vf "transpose=2,transpose=2"
That worked but it didn't keep VP8 but did keep Vorbis (I use the MediaInfo program to show the codecs).
 
Old 09-01-2019, 09:23 AM   #11
Firerat
Senior Member
 
Registered: Oct 2008
Distribution: Debian sid
Posts: 2,683

Rep: Reputation: 783Reputation: 783Reputation: 783Reputation: 783Reputation: 783Reputation: 783Reputation: 783
odd

Code:
mpv --version
mpv 0.29.1 Copyright © 2000-2018 mpv/MPlayer/mplayer2 projects
 built on UNKNOWN
ffmpeg library versions:
   libavutil       56.14.100 (runtime 56.22.100)
   libavcodec      58.18.100 (runtime 58.35.100)
   libavformat     58.12.100 (runtime 58.20.100)
   libswscale      5.1.100 (runtime 5.3.100)
   libavfilter     7.16.100 (runtime 7.40.101)
   libswresample   3.1.100 (runtime 3.3.100)
ffmpeg version: 4.1.4-1+b2
I guess you could be missing the filter package

libavfilter7 in sid
you will need libavfilter6 if you are still on stretch
 
Old 09-01-2019, 09:29 AM   #12
linustalman
LQ Guru
 
Registered: Mar 2010
Location: Ireland
Distribution: Debian 12 Bookworm
Posts: 5,725

Original Poster
Rep: Reputation: 479Reputation: 479Reputation: 479Reputation: 479Reputation: 479
Post

Quote:
Originally Posted by Firerat View Post
odd

Code:
mpv --version
mpv 0.29.1 Copyright © 2000-2018 mpv/MPlayer/mplayer2 projects
 built on UNKNOWN
ffmpeg library versions:
   libavutil       56.14.100 (runtime 56.22.100)
   libavcodec      58.18.100 (runtime 58.35.100)
   libavformat     58.12.100 (runtime 58.20.100)
   libswscale      5.1.100 (runtime 5.3.100)
   libavfilter     7.16.100 (runtime 7.40.101)
   libswresample   3.1.100 (runtime 3.3.100)
ffmpeg version: 4.1.4-1+b2
I guess you could be missing the filter package

libavfilter7 in sid
you will need libavfilter6 if you are still on stretch
Looks like I'm out of luck. No problem. At least I know your code works fine - I'll note it for future reference. :-)

Code:
mpv --version
Code:
mpv 0.23.0 (C) 2000-2016 mpv/MPlayer/mplayer2 projects
 built on UNKNOWN
ffmpeg library versions:
   libavutil       55.34.101
   libavcodec      57.64.101
   libavformat     57.56.101
   libswscale      4.2.100
   libavfilter     6.65.100
   libswresample   2.3.100
ffmpeg version: 3.2.14-1~deb9u1

Last edited by linustalman; 09-01-2019 at 09:30 AM.
 
Old 09-01-2019, 09:44 AM   #13
Firerat
Senior Member
 
Registered: Oct 2008
Distribution: Debian sid
Posts: 2,683

Rep: Reputation: 783Reputation: 783Reputation: 783Reputation: 783Reputation: 783Reputation: 783Reputation: 783
wait you can recode with the filter?

by default ffmpeg will encode to h264 and vorbis


Code:
ffmpeg -i inputfile.mkv \
   -c:v vp8 \
   -c:a copy \
   -vf "transpose=2,transpose=2" \
    outputfile.mkv
that will use whatever defaults vp8 has

to get full list of codecs
ffmpeg -codecs



personally, I do like
Code:
nice -n 19 ffmpeg \
  -hide_banner \
  -i input.mkv \
  -map 0 \
  -c:s copy \
  -c:a libopus -af aformat="channel_layouts=7.1|5.1|stereo" \
  -c:v copy \
  -c:v:0 libx265 \
  -pix_fmt yuv420p10le \
  -preset fast \
  -x265-params level=4.1:crf=20 \
   output-fast-opus-crf20-10bit.mkv
but adjust the preset and crf depending what kind of speed/quality/size I want/need

crf 20 is probably over the top
28 is the default , but I find I can see difference
take a sample

Code:
ffmpeg -ss 00:04:30.0 -t 00:03:00.0 -i input.mkv -c copy sample.mkv
that will copy a 3min sample starting at 4min 30 seconds
and try different values on the sample

you will see/hear the quality diff, and get an idea of how large the file will be and how long it will take

edit: the bold will effect both the size and quality

ultrafast, superfast, veryfast, faster, fast, medium, slow, slower, veryslow, or placebo

ultrafast is , well fastest, will make the smallest file but the least quality
veryslow , slowest , largest , best quality

the crf , higher the number the lower the quality/size

Last edited by Firerat; 09-01-2019 at 09:48 AM.
 
Old 09-07-2019, 09:43 AM   #14
linustalman
LQ Guru
 
Registered: Mar 2010
Location: Ireland
Distribution: Debian 12 Bookworm
Posts: 5,725

Original Poster
Rep: Reputation: 479Reputation: 479Reputation: 479Reputation: 479Reputation: 479
Exclamation

Quote:
Originally Posted by Firerat View Post

...

Code:
ffmpeg -ss 00:04:30.0 -t 00:03:00.0 -i input.mkv -c copy sample.mkv
...
No luck. It's still upsidedown. I made the video on a Fairphone 2 with Ubuntu Touch. It had issues with recording upside down videos but that was fixed in OTA 10. The conversion of the FP2 mp4 file to another format is the issue.
 
Old 09-07-2019, 10:41 AM   #15
Firerat
Senior Member
 
Registered: Oct 2008
Distribution: Debian sid
Posts: 2,683

Rep: Reputation: 783Reputation: 783Reputation: 783Reputation: 783Reputation: 783Reputation: 783Reputation: 783
to recap
in post 10 you said it worked BUT was no longer VP8 ( ffmpeg defaults to AVC and Vorbis)

This will keep the vp8 codec and the vorbis
Code:
ffmpeg -i inputfile.mkv \
   -c:v vp8 \
   -c:a copy \
   -vf "transpose=2,transpose=2" \
    outputfile.mkv
I only used the \ to break up the line for easier reading

Code:
ffmpeg -i inputfile.mkv -c:v vp8 -c:a copy -vf "transpose=2,transpose=2" outputfile.mkv
( \<enter> , basically we are telling the shell to ignore the <enter> )


But I don't know what the quality will be like

If you really want to keep the VP8 codec you will have to play with it to get the best quality ( or acceptable ), I don't know vp8 or vp9 settings I would ned to research them.

If the codec is not so important
Code:
ffmpeg -i inputfile.mkv \
   -c:v libx265 \
   -preset medium \
   -x265-params crf=24
   -c:a copy \
   -vf "transpose=2,transpose=2" \
    outputfile.mkv
might keep the size down and the quality high ( enough )

you could play with the crf
lower numbers will give better quality and higher filesize
higher numbers with give lesser quality and smaller filesize

The preset
ultrafast superfast veryfast faster fast medium slow slower veryslow
< - - - less quality smaller size < - - > higher quality larger size >

the HEVC codec may be more difficult to 'play' depending on device.


I hope that makes sense
 
1 members found this post helpful.
  


Reply

Tags
flip, upsidedown video



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
webcam mounted upsidedown :/ 11.10 ubuntu j0eh4x Linux - Software 1 10-17-2011 03:01 PM
Many video format (such as video/x-ms-asf and video/x-ms-wvx ) does not play? jmettova Debian 1 05-05-2009 11:22 AM
FIX---Fedora install hangs---To fix this---- jmckinzie Fedora - Installation 0 12-20-2005 12:08 AM
all attempts to fix the problem failed... can someone help me fix partition space? foreverdita Linux - Enterprise 2 05-11-2005 09:02 AM
reiserfsck --fix-fixable -> --fix-fixable ignored - why? BrianK Linux - Software 1 01-07-2005 08:45 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 11:34 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration