Converting Videos to Mpeg 4 with ffmpeg

I’m trying to convert videos over to Mpeg 4 so that I can copy them over to my PS3. The syntax that I am trying to use is:

ffmpeg -i "[AHQ] Outlaw Star -01 - Outlaw World.ogm" -mbd rd -flags +4mv+aic -trellis 2 -cmp 2 -subcmp 2 -g 300 -pass 1/2 -vcodec mpeg4 "Outlaw Star - 01 Outlaw World.mp4"

The arguments used was suggested from FFMpeg’s FAQ for a high quality Mpeg-4 output, but this is what ffmpeg prints out:

FFmpeg version SVN-r16240, Copyright (c) 2000-2008 Fabrice Bellard, et al.
configuration: --shlibdir=/usr/lib64 --prefix=/usr --mandir=/usr/share/man --libdir=/usr/lib64 --enable-shared --enable-libmp3lame --enable-libvorbis --enable-libtheora --enable-libfaad --enable-libfaac --enable-libxvid --enable-swscale --enable-postproc --enable-gpl --enable-vhook --enable-x11grab --enable-libschroedinger --enable-libdirac --enable-libgsm --enable-libx264 --enable-libamr-nb --enable-libamr-wb --enable-libdc1394 --enable-nonfree --enable-pthreads
libavutil 49.12. 0 / 49.12. 0
libavcodec 52. 7. 0 / 52. 7. 0
libavformat 52.23. 1 / 52.23. 1
libavdevice 52. 1. 0 / 52. 1. 0
libswscale 0. 6. 1 / 0. 6. 1
libpostproc 51. 2. 0 / 51. 2. 0
built on Dec 19 2008 20:18:11, gcc: 4.3.2 [gcc-4_3-branch revision 141291]
Input #0, ogg, from ‘[AHQ] Outlaw Star - 01 - Outlaw World.ogm’:
Duration: 00:24:16.12, start: 0.000000, bitrate: 1280 kb/s
Stream #0.0: Video: mpeg4, yuv420p, 576x432, 23.98 tb(r)
Stream #0.1: Audio: vorbis, 48000 Hz, stereo, s16, 128 kb/s
Stream #0.2: Audio: vorbis, 48000 Hz, stereo, s16, 192 kb/s
Output #0, mp4, to ‘Outlaw Star - 01 Outlaw World.mp4’:
Stream #0.0: Video: mpeg4 (hq), yuv420p, 576x432, q=2-31, pass 1, 200 kb/s, 23.98 tb(c)
Stream #0.1: Audio: libfaac, 48000 Hz, stereo, s16, 64 kb/s
Stream mapping:
Stream #0.0 → #0.0
Stream #0.1 → #0.1
[mpeg4 @ 0x659e20]timebase not supported by mpeg 4 standard
Error while opening codec for output stream #0.0 - maybe incorrect parameters such as bit_rate, rate, width or height

Have a look at theis
Applications - DVD Authoring Tools - openSUSE Forums

I think avidemux does this.

It does, but it does a terrible job with audio and video synchronization and I decide that it wasn’t worth the hassle and try ffmpeg.

even if you succeed in re-encoding your ogm file to mpeg 4 asp, you won’t be able to play on on your ps3 as you’re missing an important flag and that is setting the fourcc to DIVX or DX50. without it, ffmpeg will set it to FMP4 and the ps3 won’t play it… I’m no ffmpeg expert so I suggest you try out mencoder, or give my h264enc script a try which has ps3 presets… look at my sig below for link

I like microchip’s scripts.

Having said that, with avidemux it is very easy to resynchronise audio and video that has lost sync. I use it often for resynchronising audio/video in clips.

Well I tried using Avidemux to fix the problem but after trying to push the audio 250 ms and still not having the audio and video in sync with each other that is when I gave up on it.

Thanks for the suggestion downloading it now.

Seeing as more options than I really need at start up, and the fact that it encodes to avi first then to the desired final container/codec, more encoding than I think is needed I researched into my problem a bit more and found this:

ffmpeg -i /path/to/your/video -y -vcodec libx264 -acodec libfaac -title 'your title' -f mp4 -mbd rd -flags
4mv+trell+aic+qprd+mv0 -cmp 2 -subcmp 2 -flags2 dct8x8+skiprd -level 41 -b your_video_bitrate -bf 3 -ac
your_channels -ab your_audio_bitrate -threads your_threads -pass 1|2 /path/to/your/output.mp4

but there still seems to be a problem with this.

Typically what I do, when synchonising, is create maybe 1/2 dozen different outputs in one session, calling them:

  • plus250 - where I add 250 msec
  • plus500 - where I add 500 msec
  • plus750 - where I add 750 msec
  • minus250 - where I subtract 250 msec
  • minus500 - where I subtract 500 msec
  • minus750 - where I subtract 500 msec

In avidemux that is VERY QUICK. Then I examine the above, and find out where the audio leads the video and where the video leads the audio. I then determine which two of the above have the closest to synchronised audio, and then I simply narrow it in further by very very quick trial and error.

I definitely do not give up after a single 250 msec attempt.

But I hope the scripts of microchip work better for you. My experience is a lot depends on the original file, and sometimes they convert easily with no synchronisation problems, and sometimes its a pain.

Well mircochips script worked for one of the videos, but in my option is overkill because all my videos I’m going to convert with the same settings pretty much, and the converting to avi then to the desired container is over kill especially when the video is in avi to begin with (like the other video I want to convert). The second video I want to covert is already in avi, so as I stated before overkill, and still has audio and video syncing problems.

I don’t think Avidemux is working, I figured out exactly how fast the audio is compared to the video and it is 13 seconds, if my math is correct (sorry it is early morning right now) that is 780 ms. I told avidemux to push the audio back that far no change, I told avidemux to push the audio back 900 ms (15 seconds) and still the audio is ahead of the video. Is there something else I can try or is this video determined to not work as an mpeg-4?

I don’t get what is overkill. my scripts use MEncoder as the encoder and there’s a VERY GOOD REASON why to use AVI as default. It’s because libavformat is terribly broken for MEncoder (actually, it’s not broken, but MEncoder itself doesn’t play nice with it so it needs fixing) and if you use it, you’ll end up with files that only MPlayer can play, especially if you use b-frames

The only reliable container to use with MEncoder is, currently, AVI. By using AVI, I can also assure A/V sync when using two audio tracks for DVDs in combination with frame rate altering filters

my scripts have full batch encoding support where you can encode a directory full with video files and convert them to different containers. There’s also an option in batch encoding to delete the AVI after container conversion

What I mean by overkill is mostly from my own option, I’m not a media geek and know all the best settings for videos. Once I find good settings for a purpose (like DVD, PSP, PS3, etc) I stay with it those settings, so all the config steps is to much for me. Another thing that makes me say overkill is when the original video is in AVI and converting to AVI with no change to the video.

I don’t get this last sentence. What do you mean by that? my scripts don’t convert from AVI to AVI with no change to the video, they re-encode it. They encode the input and put it in an AVI and you get to choose if you want another container after that

if you just want to remux AVIs to another container without touching the video, then use muxing tools like MP4Box, avimux or mkvmerge, not encoding scripts/apps

also there’s no perfect setting that fits them all, especially when dealing with DVDs as virtually every DVD has its own cropping values and color balances and noise :wink:

microchip8 wrote:

>
> I don’t get this last sentence. What do you mean by that? my scripts
> don’t convert from AVI to AVI with no change to the video, they
> re-encode it. They encode the input and put it in an AVI and you get to
> choose if you want another container after that
>

Its just the whole process of taking a video that is in AVI and making a new
AVI that I don’t quite get that whole process.

> if you just want to remux AVIs to another container without touching
> the video, then use muxing tools like MP4Box, avimux or mkvmerge, not
> encoding scripts/apps
>
> also there’s no perfect setting that fits them all, especially when
> dealing with DVDs as virtually every DVD has its own cropping values and
> color balances and noise :wink:
>
I know I was just using that as an example.

AVI is just a container. There’s nothing wrong with re-encoding AVIs and putting the result back in an AVI. When you re-encode, you don’t re-encode the AVI itself, but what’s in it like the video and audio. Then you get to choose if you’ll store the result back in AVI or some other container