LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware
User Name
Password
Slackware This Forum is for the discussion of Slackware Linux.

Notices


Reply
  Search this Thread
Old 04-08-2017, 07:30 PM   #1
upnort
Senior Member
 
Registered: Oct 2014
Distribution: Slackware
Posts: 1,893

Rep: Reputation: 1162Reputation: 1162Reputation: 1162Reputation: 1162Reputation: 1162Reputation: 1162Reputation: 1162Reputation: 1162Reputation: 1162
Convert camera AVI to 3GP


I want to convert default camera AVI videos to 3GP. Seems the latter is better supported with smart phones.

I found an old thread about the topic.

On my 14.2 system running ffmpeg 2.8.7, ffmpeg -formats shows 3GP and 3GPP-amr support.

Is this built-in amr support sufficient? Or do I need to build amrwb, amrnb, or opencore-amr from slackbuilds.org and then rebuild ffmpeg?

Camera: Canon Powershot A590 IS.

Default Camera AVI format:

Code:
Stream #0:0: Video: mjpeg (MJPG / 0x47504A4D), yuvj422p(pc, bt470bg/unknown/unknown), 640x480, 10147 kb/s, 20 fps, 20 tbr, 20 tbn, 20 tbc
Stream #0:1: Audio: pcm_u8 ([1][0][0][0] / 0x0001), 11024 Hz, 1 channels, u8, 88 kb/s
Typical phone 3GP format:

Code:
Stream #0:0(und): Audio: amr_nb (samr / 0x726D6173), 8000 Hz, mono, flt, 12 kb/s (default)
Stream #0:1(und): Video: h264 (Baseline) (avc1 / 0x31637661), yuv420p(tv, bt709), 320x240, 133 kb/s, 15 fps, 15 tbr, 600 tbn, 1200 tbc
I would like to get this down to a simple script wrapper or shell function.

Thanks much.
 
Old 04-08-2017, 07:36 PM   #2
Emerson
LQ Sage
 
Registered: Nov 2004
Location: Saint Amant, Acadiana
Distribution: Gentoo ~amd64
Posts: 7,661

Rep: Reputation: Disabled
See gpac, this may be just what you need.
 
Old 04-08-2017, 09:21 PM   #3
bassmadrigal
LQ Guru
 
Registered: Nov 2003
Location: West Jordan, UT, USA
Distribution: Slackware
Posts: 8,792

Rep: Reputation: 6656Reputation: 6656Reputation: 6656Reputation: 6656Reputation: 6656Reputation: 6656Reputation: 6656Reputation: 6656Reputation: 6656Reputation: 6656Reputation: 6656
In regards to ffmpeg, you need to make sure you have the "E" next to amr, because that is for the encoding. ffmpeg can decode quite a bit out of the box, but for encoding, many need external codecs.

As far as 3GP, it likely is only needed if you're not using a smartphone. Both Android and iOS have players that can play almost anything (although, I don't believe either has them included in the base install -- you'd have to get them from their respective app stores). VLC is available on both platforms and I use MXPlayer on my Android phones. Although, with MXPlayer, you do need to install an AC3 and DTS codec pack due to licensing issues (I don't think it was allowed to be on the Play Store if it included support for those two formats, so the developer made it available on this xda-developers post. I don't know if VLC has that same limitation.
 
Old 04-09-2017, 11:13 AM   #4
upnort
Senior Member
 
Registered: Oct 2014
Distribution: Slackware
Posts: 1,893

Original Poster
Rep: Reputation: 1162Reputation: 1162Reputation: 1162Reputation: 1162Reputation: 1162Reputation: 1162Reputation: 1162Reputation: 1162Reputation: 1162
Quote:
See gpac, this may be just what you need.
Thanks. I will investigate.

Quote:
As far as 3GP, it likely is only needed if you're not using a smartphone.
That is the point of this thread -- I am using a camera and not a smart phone. Regarding the remainder of your post, I am the one sending the videos, thus the burden is on me to send in a format the phone users can use. They are not computer people.

To ensure I have encoding support I installed opencore-amr and rebuilt ffmpeg. After many trial runs I found the following seems to succeed:

Code:
ffmpeg -i video.avi -vcodec h264 -acodec amr_nb -ac 1 -ar 8000 -r 16 -ab 12200 -s 320x240 -y video.3gp
A 3:50 minute AVI takes about 1:40 to convert. The file size change is from 27MB to 8.7 MB.

Next is sending a converted video to a phone user and see if they complain or smile.

Edit: For a humorous twist with the videos:

Code:
-vf "setpts=0.5*PTS" -af atempo=2.0
This doubles the speed of the video.

Last edited by upnort; 04-09-2017 at 01:39 PM.
 
Old 04-09-2017, 02:15 PM   #5
bassmadrigal
LQ Guru
 
Registered: Nov 2003
Location: West Jordan, UT, USA
Distribution: Slackware
Posts: 8,792

Rep: Reputation: 6656Reputation: 6656Reputation: 6656Reputation: 6656Reputation: 6656Reputation: 6656Reputation: 6656Reputation: 6656Reputation: 6656Reputation: 6656Reputation: 6656
Quote:
Originally Posted by upnort View Post
That is the point of this thread -- I am using a camera and not a smart phone.
What I meant, is unless you're sending it to non-smartphone users, most should be able to play many of the common formats out there. 3GP seems to have mostly gone away as a default video format for phones... unless they're using the old "dumb phones". For example, my Nexus 6 will record it's videos in an mp4 container using h264 for video and AAC for audio. I imagine most, if not all, smartphones can play back these formats with the default video player.

But I'm glad you were able to convert it. Hopefully your recipients can open it easily.
 
Old 04-09-2017, 09:08 PM   #6
upnort
Senior Member
 
Registered: Oct 2014
Distribution: Slackware
Posts: 1,893

Original Poster
Rep: Reputation: 1162Reputation: 1162Reputation: 1162Reputation: 1162Reputation: 1162Reputation: 1162Reputation: 1162Reputation: 1162Reputation: 1162
Quote:
Hopefully your recipients can open it easily.
Nope. This is turning into a fine mess, Olly.

Originally I thought I needed to convert my camera avi to 3gp. Hence the original post and thread title.

Not a wasted effort. Converting to 3gp reduces the original camera AVI file by about 3x. And I wrote a nice shell script for this.

Turns out though that isn't the actual problem. The problem is iPhone design.

Recently a friend sends me a video from an iPhone 7 to my email address. The video is in 3gp format. Wanting to reciprocate with a video in return and being unfamiliar with iPhones, I presume I need to send videos in the same 3gp format. Wrong guess.

Snooping around the web indicates iPhones are limited to a sliver of video formats.

Currently I am trying to learn how to use ffmpeg to create an iPhone compatible video. Seems there are about 10,000 opinions on how to accomplish this and most don't work. Worse, I am not an ffmpeg guru and do not play one on TV.

I am wondering whether something like Handbrake might be easier. Something that has a simple straightforward option called "Convert to iPhone format." Anything out there like that?
 
Old 04-09-2017, 09:26 PM   #7
bassmadrigal
LQ Guru
 
Registered: Nov 2003
Location: West Jordan, UT, USA
Distribution: Slackware
Posts: 8,792

Rep: Reputation: 6656Reputation: 6656Reputation: 6656Reputation: 6656Reputation: 6656Reputation: 6656Reputation: 6656Reputation: 6656Reputation: 6656Reputation: 6656Reputation: 6656
According to a quick google search, this askubuntu answer suggests that handbrake should be able to handle converting to an iphone compatible format easily.
 
Old 04-10-2017, 12:45 AM   #8
upnort
Senior Member
 
Registered: Oct 2014
Distribution: Slackware
Posts: 1,893

Original Poster
Rep: Reputation: 1162Reputation: 1162Reputation: 1162Reputation: 1162Reputation: 1162Reputation: 1162Reputation: 1162Reputation: 1162Reputation: 1162
Quote:
According to a quick google search, this askubuntu answer suggests that handbrake should be able to handle converting to an iphone compatible format easily.
I have been meaning to look at handbrake for a long time. I'm overdue.

That said, I received a short email that (at least) one of the videos I reconverted finally was compatible with the iPhone. I have to wait until tomorrow to learn which one.

Computers. Meh.
 
Old 04-10-2017, 04:29 PM   #9
SW64
Member
 
Registered: May 2014
Distribution: Slackware
Posts: 262

Rep: Reputation: 123Reputation: 123
When you're sending videos to people that doesn't know anything about videos, using the H.264 codec in a MP4 container is a very good bet. Handbrake is a good start for that, seeing how it'll export only one codec: H.264 in M4V, MP4, and MKV containers.

Exported correctly, H.264/MP4 should be readable by iPhones, other iOS devices, or any other modern media players/devices/computers. I still find devices that would struggle with 1080p materials but not with 720p materials. On a Linux machine, Handbrake, FFMPEG, avconv, VLC, aavidemux, kdenlive, flowblade, basically any program that uses the x264 and AAC libraries will be able to export to H.264/AAC/MP4 format.

From iPhone v5 to iPhone v7, that I am aware of, can handle a decently-quality 720p H264/MP4 natively very well. I think (but I'm not sure) iPhone v4S or lower struggles with 720p media but will handle better with videos at 640x360 or lower.

I get that you probably no longer have a need for the 3GP format, but if you still want to squeeze your H.264/MP4 file size down to an equivalent 3GP file size, then experiment with bitrate. Something like 300kbps (in your first post, the 3GP format is at 133kb\s and the MJPEG/AVI format is 10147kb\s) Reducing screen size to 360x240 or even 128x96 will also reduce the total file size. With FFMPEG (also in Handbrake as 'Quality'), experiment with the '-q:v' flag. '0' is the highest/lossless quality where '31' is the lowest quality. The total size of the audio track are usually insignificant when compared to its video track's total file size, so I often leave it at original or better (128kbps or better; usually at 320kbps). Sometime, I just copy it straight over with '-c:a copy' so it won't re-encode the audio track and thus degrade it further.

Basically, set your desired resolution/screen size, and then bump up (or down) the bitrate/'-q:v' options until you like what you see. Sometime it's necessary to bump up or down the resolution/screen size to preserve the video's quality at the expense of total file size.

Using FFMPEG is an easier task for me. Basically type, enter, done. Occasionally, between the 'type' stage and 'done' stage, there will be three-days worth of online research in finding the right syntax to export a certain codec correctly.

I've found a sample from a Canon G9 and its video format is almost exactly the same as yours.

This command gave me a tiny but decent output:
Code:
ffmpeg -i input.AVI -b:v 1000K -strict -2 output.mp4
This command gave me pretty much an exact H264 copy of the original AVI file but with its file size still smaller than original:
Code:
ffmpeg -i input.AVI -b:v 1000K -q:v 0 -strict -2 output.mp4
Here's a good read if you want to go deeper still.
http://blog.superuser.com/2012/02/24...pulation-tool/

Good luck! :-)
 
Old 04-11-2017, 09:41 AM   #10
upnort
Senior Member
 
Registered: Oct 2014
Distribution: Slackware
Posts: 1,893

Original Poster
Rep: Reputation: 1162Reputation: 1162Reputation: 1162Reputation: 1162Reputation: 1162Reputation: 1162Reputation: 1162Reputation: 1162Reputation: 1162
Thanks SW64.

The good news is the other person finally can see the videos. Previously I had used my new script to create the 3gp and convert to mp4. I manually created mov and m4v from those. No problem with any of those. As I no longer actually need 3gp any more, I plan to update the script to create the same file types directly. I still need the ffmpeg parameters I included in the script because the final file size gets shrunk considerably and converted to 320x240.

Still need to look at handbrake and gpac.

Let's mark this solved.
 
  


Reply



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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
How to Convert a video (mp4 or avi etc) to 3gp in ubuntu amritpalpathak Linux - Software 3 01-05-2011 02:45 AM
3GP Video Converter, Convert AVI to 3GP, MPEG to 3GP, 3gp co kcilioek Linux - Hardware 1 01-06-2010 03:07 AM
How to convert avi to 3gp? yuchankit Slackware 16 01-07-2009 04:17 PM
How to convert .mov (digital camera) to .avi?? trainpic Linux - General 1 06-07-2006 11:18 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware

All times are GMT -5. The time now is 09:19 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