# Encoding MP4 video from AVI video?



## gr1ml0ck (Aug 16, 2009)

Hi All,

Has anyone out there had any joy with encoding AVI files to MP4 files for use on mobile media players?

The only port I can see it the flv to mp4? 

Google didn't return much which surprised me for once!

I'm starting to wonder how well an encoder would work under Wine? as there are several windows packages available to do the lot with simple GUI's.

I also use Vbox running xp so there is another option.. however.. im pretty sure that encoding within Vbox may abuse my system slightly.

So... my questions to the board are:

1: Has anyone converted avi to mp4?
2: Has anyone used wine and windows encoders with bug free results?
3: Has anyone had decent results using a vm to encode?
4: Should I be bothering about this and just use a win box?


You views and opinions are.. as always.. greatly appreciated.


----------



## ale (Aug 16, 2009)

Did you tried with multimedia/ffmpeg?
With _ffmpeg -formats | less_ you can see the supported formats.


----------



## gr1ml0ck (Aug 16, 2009)

*solved i guess... im sure the command line is straight forward enough =)*

Many thanks.. I see that there are a great many formats supported by ffmpeg using this command! 

I am very new to this command line encoding as I have previously been a lazy button pusher (gui user) on other os's.

I didn't think ffmpeg was as versatile as it indeed is.. cant wait to see some results.


----------



## aragon (Aug 16, 2009)

Personally I prefer multimedia/mencoder.


----------



## gr1ml0ck (Aug 16, 2009)

*ffmpeg vs mencoder?*

Aragon? What are the differences?  Do you find it easier? or does it give you more control over the output?


Ale?  Does this look ok to you? 

```
ffmpeg -i /home/matt/private/BioDome.avi -r 20 -ar 44100 \
-aspect 4:3 -s 320x240 -croptop 0 -cropbottom 0 -cropleft 0 -cropright 0 /home/matt/BioDome.mp4
```

I'm getting this error: 

```
unsupported codec for output stream #0.1
```

Even this stripped down command gives the same error:

```
ffmpeg -i /home/matt/private/BioDome.avi /home/matt/BioDome.mp4
```


----------



## aragon (Aug 16, 2009)

Mencoder has many more options, so you have more control, but I guess the learning curve is steeper.  On the upside mencoder lets you save "profiles" so after spending hours of tweaking the settings to just how you like them, you can save them in one or more profiles.


----------



## roddierod (Aug 16, 2009)

gr1ml0ck said:
			
		

> Many thanks.. I see that there are a great many formats supported by ffmpeg using this command!
> 
> I am very new to this command line encoding as I have previously been a lazy button pusher (gui user) on other os's.
> 
> I didn't think ffmpeg was as versatile as it indeed is.. cant wait to see some results.



avidemux2 - GUI front end for ffmpeg and others. I use it to convert avi/divx file to the DX50 subformat to play on my Divx DVD player.


----------



## avilla@ (Aug 16, 2009)

it's a bit oversized for your needs, but multimedia/kdenlive has a lot of useful encoding profiles (some for mobile media players). perhaps you could just install multimedia/mlt (the framework behind kdenlive, which doesn't require kde and friends) and use it with the profiles from kdenlive (`# cd /usr/ports/multimedia/kdenlive && make extract`, then copy them), or, easier, copy the options in the profiles from kdenlive and use them with multimedia/ffmpeg (they are, more or less, ffmpeg options)


----------



## roddierod (Aug 16, 2009)

There is also arista, which is the Gnome version kdenlive. It has presets for PSP and such.


----------



## gr1ml0ck (Aug 16, 2009)

Cheers guys.. now I have more options than I can shake a stick at.  I would like to discover as to why the command line options I'm using for ffmpeg wont work for me.. as I do like to SOLVE an issue.... however..

I think I may try this avidemux2 first (thanks roddierod!)and see the results/options that the encoders provide. I will then move onto testing the other suggested methods and see what works best for me.

I will post back here any issues and feedback on the different encoding methods that I use.


EDIT: Avidemux2 is marked as broken 

As a KDE4 user, I am gonna try kdenlive. I have plenty of disk space and resources to chew so a little extra padding shouldn't hurt.  =)


----------



## avilla@ (Aug 16, 2009)

gr1ml0ck said:
			
		

> As a KDE4 user, I am gonna try kdenlive. I have plenty of disk space and resources to chew so a little extra padding shouldn't hurt.  =)



http://kdenlive.org/user-manual/dow...-compiled-packages/freebsd-ports-and-packages
have a look at the ffmpeg part


----------



## gr1ml0ck (Aug 17, 2009)

The ffmpeg section of the above guide gave me no further help as it simply points out that you must pay attention the config screen during the make process. 

Unfortunately I have already enabled all options and mp4 format IS supported by ffmpeg. 

I do not see any pre-built profiles from within kdenlive to enable mp4 encoding and fear that simply adding a cmd line (profile) to will throw out the same error as using RAW ffmpeg commands from the terminal (see couple of posts above)?

I would rather rectify this issue as ffmpeg appears to used successfully by a great many at the cmd line..  I'm at a loss as to what is wrong with my previous cmd's.


----------



## fronclynne (Aug 17, 2009)

gr1ml0ck said:
			
		

> The ffmpeg section of the above guide gave me no further help as it simply points out that you must pay attention the config screen during the make process.
> 
> Unfortunately I have already enabled all options and mp4 format IS supported by ffmpeg.
> 
> ...



From the output here, mp4 requires libfaac.  You might try rebuilding via something like `# portupgrade -uvfR ffmpeg\*` after making sure that audio/faac is all up to snuff.
My rather spammy output:

```
> ffmpeg -i Video/MowerFire.mp2 MowerFire2.mp4
FFmpeg version 0.5, Copyright (c) 2000-2009 Fabrice Bellard, et al.
  configuration: --prefix=/usr/local --mandir=/usr/local/man --enable-shared --enable-gpl --enable-swscale --enable-postproc --enable-avfilter --enable-avfilter-lavf --enable-pthreads --enable-x11grab --enable-memalign-hack --cc=cc --extra-cflags=-msse -I/usr/local/include/vorbis -I/usr/local/include --extra-ldflags=-L/usr/local/lib  --extra-libs=-pthread --disable-debug --enable-libamr-nb --enable-nonfree --enable-libamr-wb --enable-nonfree --enable-libdirac --enable-libfaac --enable-libfaad --enable-libfaadbin --disable-libgsm --disable-vhook --enable-ipv6 --enable-libmp3lame --enable-libopenjpeg --enable-libschroedinger --enable-libspeex --enable-libtheora --enable-libvorbis --enable-libx264 --enable-libxvid
  libavutil     49.15. 0 / 49.15. 0
  libavcodec    52.20. 0 / 52.20. 0
  libavformat   52.31. 0 / 52.31. 0
  libavdevice   52. 1. 0 / 52. 1. 0
  libavfilter    0. 4. 0 /  0. 4. 0
  libswscale     0. 7. 1 /  0. 7. 1
  libpostproc   51. 2. 0 / 51. 2. 0
  built on Aug 15 2009 16:45:20, gcc: 4.2.1 20070719  [FreeBSD]
Input #0, mpeg, from 'Video/MowerFire.mp2':
  Duration: 00:00:06.88, start: 0.220000, bitrate: 293 kb/s
    Stream #0.0[0x1e0]: Video: mpeg1video, yuv420p, 240x180 [PAR 178:163 DAR 712:489], 250 kb/s, 25 tbr, 90k tbn, 25 tbc
    Stream #0.1[0x1c0]: Audio: mp2, 32000 Hz, mono, s16, 32 kb/s
Output #0, mp4, to 'MowerFire2.mp4':
    Stream #0.0: Video: mpeg4, yuv420p, 240x180 [PAR 178:163 DAR 712:489], q=2-31, 200 kb/s, 90k tbn, 25 tbc
    Stream #0.1: Audio: libfaac, 32000 Hz, mono, s16, 64 kb/s
Stream mapping:
  Stream #0.0 -> #0.0
  Stream #0.1 -> #0.1
Press [q] to stop encoding
frame=  175 fps=  0 q=17.0 Lsize=     293kB time=6.88 bitrate= 348.7kbits/s    
video:243kB audio:46kB global headers:0kB muxing overhead 1.477854%
```


----------



## roddierod (Aug 17, 2009)

gr1ml0ck said:
			
		

> EDIT: Avidemux2 is marked as broken
> 
> As a KDE4 user, I am gonna try kdenlive. I have plenty of disk space and resources to chew so a little extra padding shouldn't hurt.  =)



Ahh. Looks like it doesn't compile with QT 4.5 yet, which you would be using a a KDE4 user. I didn't know that, being I don't use KDE4 or any of it's parts.


----------



## gr1ml0ck (Aug 18, 2009)

lol.. ok.  I managed to fix it and get it working (or seemingly so far anyway)

I found that the command "ffmpeg --enable-faac"... although giving an error saying it was an incorrect command... did the trick and got the faac encoder working.

I am yet to see the results from this first attempt.. im seeing such errors appearing as "Error at MB: 616" and such.. but i'm sure i can iron these out eventually.

Thanks all.


----------



## Koberman (May 3, 2011)

While several good options have been suggested in this thread, I'd also suggest that you give multimedia/handbrake a try. Simple command line (unless someone gets around to porting the Linux GUI to FreeBSD) and, while providing less fine-grained control for special cases, is dead simple to use for normal operations.

It includes a large number of standard profiles to give you output that will run on most popular devices. For example, to transcode an AVI to an MP4 for the iPhone:
`handbrake -Z "iPhone & iPod Touch" -i in-file -o out-file`

You can add quite a few options like cropping and deinterlacing and even x.264 options. It pretty much just works and provide good results.


----------

