[SOLVED] Need help rotating a video file (.3gp) 90 degrees

You have a problem with Salix? Post here and we'll do what we can to help.
User avatar
Dennola4
Posts: 172
Joined: 7. Sep 2010, 18:25
Location: San Diego, CA, USA

[SOLVED] Need help rotating a video file (.3gp) 90 degrees

Post by Dennola4 »

Hey there,

I accidentally shot a video (on my android) in portrait mode rather than landscape mode, so when I view the video on my laptop it is sideways. I found a Linux blog which offers this solution:
http://www.thelinuxblog.com/rotating-videos-in-linux/

But when I use this advice I get:

Code: Select all

dennis[2012-7]$ mencoder -ovc lavc -vf rotate=1 -oac pcm ben_eat.3gp -o ben_eat2.AVI
MEncoder 20100218-4.4.3 (C) 2000-2010 MPlayer Team
success: format: 0  data: 0x0 - 0x1fe7c44
libavformat file format detected.
[mov,mp4,m4a,3gp,3g2,mj2 @ 0x8ee0920]max_analyze_duration reached
[lavf] Video stream found, -vid 0
[lavf] Audio stream found, -aid 1
VIDEO:  [MP4V]  640x480  24bpp  60.000 fps  1828.8 kbps (223.2 kbyte/s)
[V] filefmt:44  fourcc:0x5634504D  size:640x480  fps:60.000  ftime:=0.0167
==========================================================================
Opening audio decoder: [ffmpeg] FFmpeg/libavcodec audio decoders
Cannot find codec 'libopencore_amrnb' in libavcodec...
ADecoder init failed :(
ADecoder init failed :(
Cannot find codec for audio format 0x726D6173.
==========================================================================
Opening video filter: [expand osd=1]
Expand: -1 x -1, -1 ; -1, osd: 1, aspect: 0.000000, round: 1
Opening video filter: [rotate=1]
==========================================================================
Opening video decoder: [ffmpeg] FFmpeg's libavcodec codec family
Selected video codec: [ffodivx] vfm: ffmpeg (FFmpeg MPEG-4)
==========================================================================
Movie-Aspect is 1.33:1 - prescaling to correct movie aspect.
videocodec: libavcodec (480x640 fourcc=34504d46 [FMP4])
Writing header...1f ( 3%)  0.00fps Trem:   0min   0mb  A-V:0.000 [0:0]
ODML: Aspect information not (yet?) available or unspecified, not writing vprp header.
Writing header...
ODML: Aspect information not (yet?) available or unspecified, not writing vprp header.

1 duplicate frame(s)!
Pos:  18.6s   1119f (55%) 48.20fps Trem:   0min   3mb  A-V:0.000 [931:0]]
Too many audio packets in the buffer: (4096 in 131072 bytes).
Maybe you are playing a non-interleaved stream/file or the codec failed?
For AVI files, try to force non-interleaved mode with the -ni option.

Flushing video frames.
Writing index...
Writing header...
ODML: Aspect information not (yet?) available or unspecified, not writing vprp header.

Video stream:  931.837 kbit/s  (116479 B/s)  size: 2172344 bytes  18.650 secs  1119 frames
dennis[2012-7]$ 
Two problems. First problem: there is no sound. I attribute this to fact that mencoder is looking for libopencore_amrnb where as the file on this system (Salix 13.1) seems to actually be named libopencore-amrnb (with a hyphen, not an underscore). Not sure how to solve this. Obviously copying the files and renaming them is an idea, but there are soft links and my rule is "if you don't know what you are doing; don't do it." Second problem: the video after having been flipped plays very quickly and choppily, like an old Charlie Chaplin flick. I have tried every version of an output file.... .AVI, .mpeg, etc. I have also used the suggested -ni (non-interleaved) option for AVI.

Can anyone give me some help on this? Thanks.

:? :? :?
Last edited by Dennola4 on 3. Jul 2012, 06:18, edited 1 time in total.
There are no stupid questions.
User avatar
Dennola4
Posts: 172
Joined: 7. Sep 2010, 18:25
Location: San Diego, CA, USA

Re: Need help rotating a video file (.3gp) 90 degrees

Post by Dennola4 »

Solved. What I did was:

This worked for a .3gp file accidentally shot in portrait mode on my phone, where it played fine by the way, but then played sideways on my laptop and when I posted it to a social networking site.

1) Navigate to the video file, r-click and open with avidemux (available from Salix repo)
2) Under VIDEO choose M-JPEG
3) Under FILTERS choose ROTATE 90
4) Under AUDIO choose AC3 (lav)
5) FORMAT should be set to AVI
6) File > Save > Save Video...
7) Name the file whatever.AVI

Using VLC (my preferred media player) the video played with no noticeable effect on the picture quality or sound quality. On my system this combination was the only one which gave me good results and didn't crash the AviDemux program somewhere in the process.

Hope this is useful to someone else.

8-)
Last edited by Dennola4 on 3. Jul 2012, 15:46, edited 1 time in total.
There are no stupid questions.
Shador
Posts: 1295
Joined: 11. Jun 2009, 14:04
Location: Bavaria

Re: [SOLVED] Need help rotating a video file (.3gp) 90 degre

Post by Shador »

This could also be an option:

Code: Select all

ffmpeg -i <in> -vf "transpose=1" <out>
Image
User avatar
Dennola4
Posts: 172
Joined: 7. Sep 2010, 18:25
Location: San Diego, CA, USA

Re: [SOLVED] Need help rotating a video file (.3gp) 90 degre

Post by Dennola4 »

Hi Shador.

I tried that actually. First I tried:

Code: Select all

ffmpeg -i ben_eat.3gp -vf vflip ben_eat2.3gp
...then I tried:

Code: Select all

ffmpeg -i ben_eat.3gp -vf "transpose=1" ben_eat2.AVI
...and in both cases got:

Code: Select all

FFmpeg version UNKNOWN, Copyright (c) 2000-2010 the FFmpeg developers
  built on Mar 26 2010 11:25:03 with gcc 4.4.3
  configuration: --prefix=/usr --mandir=/usr/man --enable-shared --disable-static --enable-pthreads --enable-x11grab --disable-libfaac --enable-libmp3lame --enable-libspeex --enable-libtheora --enable-libvorbis --enable-libx264 --enable-libxvid --disable-libdirac --enable-libschroedinger --enable-gpl --enable-postproc --disable-ssse3 --enable-libfaad --enable-libfaadbin --arch=i686 --cpu=i686
  libavutil     50.13. 0 / 50.13. 0
  libavcodec    52.61. 0 / 52.61. 0
  libavformat   52.57. 1 / 52.57. 1
  libavdevice   52. 2. 0 / 52. 2. 0
  libswscale     0.10. 0 /  0.10. 0
  libpostproc   51. 2. 0 / 51. 2. 0
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'ben_eat.3gp':
  Metadata:
    major_brand     : 3gp4
    minor_version   : 768
    compatible_brands: 3gp4mp413gp6
    copyright       : 
    copyright-eng   : 
  Duration: 00:02:25.26, start: 0.000000, bitrate: 1842 kb/s
    Stream #0.0(eng): Video: mpeg4, yuv420p, 640x480 [PAR 1:1 DAR 4:3], 1828 kb/s, 13.59 fps, 60 tbr, 1k tbn, 60 tbc
    Stream #0.1(eng): Audio: amrnb, 8000 Hz, 1 channels, flt, 12 kb/s
Unrecognized option 'vf'
There are no stupid questions.
Shador
Posts: 1295
Joined: 11. Jun 2009, 14:04
Location: Bavaria

Re: [SOLVED] Need help rotating a video file (.3gp) 90 degre

Post by Shador »

Sorry, my fault. I totally forgot that I was on my Arch laptop when trying this which obviously has a much more recent and different version of ffmpeg. Either Salix' version is too old or lacks some required compile-time switch for that functionality to be available.
Image
User avatar
Dennola4
Posts: 172
Joined: 7. Sep 2010, 18:25
Location: San Diego, CA, USA

Re: [SOLVED] Need help rotating a video file (.3gp) 90 degre

Post by Dennola4 »

Too old. The Salix repo version doesn't support video filters (-vf). So just for the experiment I updated my ffmpeg using:
http://taper.alienbase.nl/mirrors/peopl ... ds/ffmpeg/

I then ran the command:

Code: Select all

ffmpeg -i ben_eat.3gp -b 5000k -vf "transpose=1" ben_eat2.AVI
....which worked perfectly. Amazing tool, ffmpeg. But if you don't feel like compiling, avidemux works as well for this task (simple video rotation), though ffmpeg is notably faster and can be used for bulk edits.

Again, hope someone else finds this useful.

:idea:
There are no stupid questions.
User avatar
gapan
Salix Wizard
Posts: 6244
Joined: 6. Jun 2009, 17:40

Re: [SOLVED] Need help rotating a video file (.3gp) 90 degre

Post by gapan »

Careful with that ffmpeg upgrading. If you replaced the stock salix ffmpeg package, you just broke every single package in the repos that depends on ffmpeg.
Image
Image
User avatar
Dennola4
Posts: 172
Joined: 7. Sep 2010, 18:25
Location: San Diego, CA, USA

Re: [SOLVED] Need help rotating a video file (.3gp) 90 degre

Post by Dennola4 »

Hey Gapan.

Actually I did a test to see what would be affected by removing ffmpeg r22692-1686-1gv, and I realized I would be affecting the following programs:

guvcview 1.4.1-1gv
libquicktime 1.1.5-1485-1gv
mjpegtools 1.9.0-1486-3gv
gst-plugins-bad 0.10.18-1486-2gv
vlc 1.1.4-1486-2tm

....so instead I downloaded ffmpeg-0.11.tar.bz2 to a build directory and did ./configure, make, #make install. I have tested all of the associated programs and there seem to be no conflicts. I admit it isn't exactly the shining example of the Slack way (one tool for one task), but it gives me the needed functionality of the newer ffmpeg without negatively affecting the functionality of the previous version. But of course, you're the Salix Wizard, so if you have a better way to do this I am all ears.

:?:
There are no stupid questions.
User avatar
gapan
Salix Wizard
Posts: 6244
Joined: 6. Jun 2009, 17:40

Re: [SOLVED] Need help rotating a video file (.3gp) 90 degre

Post by gapan »

Since you kept the stock salix package and you installed the new version in /usr/local, you have two separate ffmpeg installations. So, all packages should be working fine. And since /usr/local/bin takes precedence in PATH over /usr/bin, whenever you're running ffmpeg, you're calling the newer version. So, you just have to remember that you have an ffmpeg installation that is not being tracked by the package manager in /usr/local.
Image
Image
User avatar
Dennola4
Posts: 172
Joined: 7. Sep 2010, 18:25
Location: San Diego, CA, USA

Re: [SOLVED] Need help rotating a video file (.3gp) 90 degre

Post by Dennola4 »

Rule number one is that I never make serious system changes unless my bootable, full-system backup is up to date.... so I wasn't too worried about trying this. That said, while I knew it worked I didn't fully understand why, so I very much appreciate your explanation. A couple questions:

1) how do you know ahead of time where a compiled package installs? I have scrolled through all docs (makefile, etc) and I can't find it.
2) how would I know, for the future, which of any two locations takes precedence in PATH?
3) may I assume that removal of this package is done by cd'ing to the build environment and running #make uninstall?

Also, regarding the PM not tracking the newer ffmpeg, I have a directory called /Downloads/Packages which is exactly for itemizing self-installed packages and briefly describing their functionality and useful commands, so no problems there.

Thanks in advance for your help Gapan.

:)
There are no stupid questions.
Post Reply