You are not logged in.

#1 2006-12-26 21:33:44

skottish
Forum Fellow
From: Here
Registered: 2006-06-16
Posts: 7,942

x264 questions

I installed x264-svn and ffmpeg-svn on my Arch64 box. The x264 codec is amazing in quality, but it has issues. It produces gray frames at the beginning of my videos. I read on some other forums that people thought the problem may be related to AVISynth, but I'm not using that.

Also, I can't get x264 to produce videos that QuickTime will play. Does anyone have any ideas here?

Offline

#2 2006-12-26 23:04:29

predatorfreak
Member
Registered: 2006-12-08
Posts: 13

Re: x264 questions

skottish wrote:

I installed x264-svn and ffmpeg-svn on my Arch64 box. The x264 codec is amazing in quality, but it has issues. It produces gray frames at the beginning of my videos. I read on some other forums that people thought the problem may be related to AVISynth, but I'm not using that.

Also, I can't get x264 to produce videos that QuickTime will play. Does anyone have any ideas here?

I use mencoder for this, with a profile like this:

[h264]
profile-desc="H264 encoding profile."
ovc=x264=1
oac=faac=1
of=lavf=1
lavfopts=format=mp4:i_certify_that_my_video_stream_does_not_use_b_frames=1

Note that you should really tweak this in terms of encoding options and such, but it does get the job done.

I'm certain ffmpeg could output such files as well if you did ffmpeg -f mp4 and set -coder 1. Weirdly enough I've experienced that problem of grey frames at the beginning of videos too and -coder 1 seemed to fix that. Optionally you could do all this through mencoder using the lavc option and vcodec=h264.

Edit: You may find this profile helpful aswell.

[h264-lavc]
profile-desc="H264 encoding profile using libavcodec instead of X264."
ovc=lavc=1
oac=lavc=1
lavcopts=vcodec=h264:acodec=aac:abitrate=128:coder=1
of=lavf=1
lavfopts=format=mp4:i_certify_that_my_video_stream_does_not_use_b_frames=1

Offline

#3 2006-12-27 00:44:58

skottish
Forum Fellow
From: Here
Registered: 2006-06-16
Posts: 7,942

Re: x264 questions

Thanks for the detailed reply.

Sure enough '-coder 1' killed the gray frames in Ffmpeg. That's great because at the moment Ffmpeg-svn is my only known option. I tried to build MPlayer with x264 using the PKGBUILD to no avail. It's having trouble with the x264 libs. I can't get MPlayer-svn to build either. It just doesn't want to right now. On top of that, I couldn't build mp4 output in x264 without gpac, gpac won't build on x86_64 (fPIC problem with os_divers.o), and I'm not knowledgeable to fix it. So Ffmpeg-svn it is!

Onward...

EDIT

It turns out that Ffmpeg knows how to handle QuickTime after all with this codec.

Now the problem is that I'm getting linear vertical distortions along the edge of my film. If I can just fix this, I will have conquered the 2 lowest common denominators in multimedia: Microsoft and Apple.

EDIT 2

I also can't figure out with Ffmpeg or Mencoder how to fold a m4a file into a video. For MS compatible, I simply convert it to PCM in Mencoder and it still sounds great. I need a good solution for QuickTime also.

Offline

#4 2006-12-27 11:54:59

predatorfreak
Member
Registered: 2006-12-08
Posts: 13

Re: x264 questions

skottish wrote:

Thanks for the detailed reply.

Sure enough '-coder 1' killed the gray frames in Ffmpeg. That's great because at the moment Ffmpeg-svn is my only known option. I tried to build MPlayer with x264 using the PKGBUILD to no avail. It's having trouble with the x264 libs. I can't get MPlayer-svn to build either. It just doesn't want to right now. On top of that, I couldn't build mp4 output in x264 without gpac, gpac won't build on x86_64 (fPIC problem with os_divers.o), and I'm not knowledgeable to fix it. So Ffmpeg-svn it is!

Onward...

EDIT

It turns out that Ffmpeg knows how to handle QuickTime after all with this codec.

Now the problem is that I'm getting linear vertical distortions along the edge of my film. If I can just fix this, I will have conquered the 2 lowest common denominators in multimedia: Microsoft and Apple.

EDIT 2

I also can't figure out with Ffmpeg or Mencoder how to fold a m4a file into a video. For MS compatible, I simply convert it to PCM in Mencoder and it still sounds great. I need a good solution for QuickTime also.

With mplayer you need a custom x264-svn build and preferrably an mplayer-svn build aswell, x264-svn needs to be built with --enable-shared and preferrably --enable-pic (not required though). If mplayer still throws out linking errors, trying doing export LDFLAGS="$LDFLAGS -lx264" in the PKGBUILD, this will add a bit of overhead since every linking X264 will be linked it, but it fixes the link errors in most cases (I don't have to do this with the builds I use..)

For the audio issue, you could try copying the audio from the file instead of converting it, assuming it's a spec compliant format like MP3, MP2 or AAC.

Also, I believe gpac requires a patch for proper PIC support. If you'd like I could provide my x264-svn, mplayer-svn and gpac abs directories for your use.

Edit: Also, I'm not certain about the distortions, I've never experienced those myself, perhaps you could provide the video you're trying to encode?

Oh and here are my abs directories for the mentioned packages:
http://pred.dcaf-security.org/x264-svn.tar.gz
http://pred.dcaf-security.org/mplayer-svn.tar.gz
http://pred.dcaf-security.org/gpac.tar.gz

Note that the build order is gpac, x264-svn and then mplayer-svn. mplayer-svn is a combination of the official mplayer package, mplayer-svn and some tweaks and modifications I did. Also I'm lazy and forgot to add "x86_64" to the ARCH array, adding that should make them build on x86_64 without problems.

Offline

#5 2006-12-27 13:10:18

skottish
Forum Fellow
From: Here
Registered: 2006-06-16
Posts: 7,942

Re: x264 questions

Wow! Thanks.

I built a version of x264-svn with the above flags. That's how I got ffmpeg-svn working. But getting the other two working correctly is priceless. In particular Mplayer with x264 support. There's so much great documentation for Mplayer that's simply not there yet with fmpeg. Particularly on the audio side.

This is cool. I try this stuff out when I have a chance later.

Offline

#6 2006-12-27 13:14:36

predatorfreak
Member
Registered: 2006-12-08
Posts: 13

Re: x264 questions

skottish wrote:

Wow! Thanks.

I built a version of x264-svn with the above flags. That's how I got ffmpeg-svn working. But getting the other two working correctly is priceless. In particular Mplayer with x264 support. There's so much great documentation for Mplayer that's simply not there yet with fmpeg. Particularly on the audio side.

This is cool. I try this stuff out when I have a chance later.

You're welcome, always glad to be of assistance.

Offline

#7 2006-12-27 13:44:19

skottish
Forum Fellow
From: Here
Registered: 2006-06-16
Posts: 7,942

Re: x264 questions

All three packages built (with the exception of Blue being at 1.7) straight out of the box... and before work even! I'll check them out later.

You rule!

Offline

#8 2006-12-27 21:40:14

predatorfreak
Member
Registered: 2006-12-08
Posts: 13

Re: x264 questions

skottish wrote:

All three packages built (with the exception of Blue being at 1.7) straight out of the box... and before work even! I'll check them out later.

You rule!

Sorry, I never really use mplayer's GUI, so I really don't bother keeping up with that part, I'll probably just remove it soon enough.

Offline

#9 2006-12-28 18:26:53

skottish
Forum Fellow
From: Here
Registered: 2006-06-16
Posts: 7,942

Re: x264 questions

I'm trying with using copy to get the m4a files (created by Mac) either into an existing file or folding it in as I process (these are all image files). With Ffmepg, it throughs a bunch of crap out about skipping frames, and there's no music. Mencoder seems to do it, but QuickTime rejects the file. Also, when Mencoder does it, if you move to different parts of the movie, the soundtrack starts over instead of going to the proper time frame. Any ideas?

Offline

#10 2006-12-28 21:11:18

predatorfreak
Member
Registered: 2006-12-08
Posts: 13

Re: x264 questions

skottish wrote:

I'm trying with using copy to get the m4a files (created by Mac) either into an existing file or folding it in as I process (these are all image files). With Ffmepg, it throughs a bunch of crap out about skipping frames, and there's no music. Mencoder seems to do it, but QuickTime rejects the file. Also, when Mencoder does it, if you move to different parts of the movie, the soundtrack starts over instead of going to the proper time frame. Any ideas?

Sadly, this is one area where I don't spent much time with when using mencoder, I'm more focused on compression of movies myself. Perhaps you could output the fils as a raw H264 stream and then combine the audio and videousing MP4Box (note that it's capitalised even on the command line)?

Offline

#11 2007-01-13 22:23:34

skottish
Forum Fellow
From: Here
Registered: 2006-06-16
Posts: 7,942

Re: x264 questions

I finally figured out how to get Quicktime compliant video files using the above listed software. Since it was such a pain in the ass, I thought maybe others would like to know.

All that need to be done is to create the video part of the file with ffmpeg-svn. The codec needs to be h264, and the output file format needs to be mp4. This example takes all sequential PNG files that have 6 digit frame numbers (frame_000001, frame_000002, etc) in a directory, and encodes it into a good quality MP4 file with a frame rate of 25:

ffmpeg -i frame_%06d.png -r 25 -vcodec h264 -b 5000k -coder 1 video_part.mp4

Then the audio can be added with MP4Box. In this case it's a M4A file called 'audio':

MP4Box -add video_part.mp4 -add audio.m4a -new complete_video.mp4

This was tested on a Windows box with Quicktime 7.

Offline

#12 2007-01-14 06:32:01

skottish
Forum Fellow
From: Here
Registered: 2006-06-16
Posts: 7,942

Re: x264 questions

Sorry to bump, but this is useful information...

It seems that MPlayer has started using FFMPEG as its backend; Which makes sense, of course. One of the changes that I've found in both of these programs is in the way that they handle input and output. The code posted above:

ffmpeg -i frame_%06d.png -r 25 -vcodec h264 -b 5000k -coder 1 video_part.mp4

Will not work correctly outside of the default frame rate of x264 (25 fps). You need to explicitly define both the input and output fps. For instance, if you wanted your movie to be compatible with NTSC, this will do the trick:

ffmpeg -r 29.97 -i frame_%06d.png -vcodec h264 -b 5000k -coder 1 -r 29.97 video_part.mp4

The difference is that both the input:

ffmpeg -r 29.97

and the output:

-r 29.97 video_part.mp4

define the frame rate.

With my example from the last post, FFMPEG would have taken the input at 29.97 fps, then expanded it out to 25 fps. In my test case it generated 2083 more frames than I needed! Yikes!!!

Offline

#13 2007-01-14 07:06:40

predatorfreak
Member
Registered: 2006-12-08
Posts: 13

Re: x264 questions

skottish wrote:

Sorry to bump, but this is useful information...

It seems that MPlayer has started using FFMPEG as its backend; Which makes sense, of course. One of the changes that I've found in both of these programs is in the way that they handle input and output. The code posted above:

ffmpeg -i frame_%06d.png -r 25 -vcodec h264 -b 5000k -coder 1 video_part.mp4

Will not work correctly outside of the default frame rate of x264 (25 fps). You need to explicitly define both the input and output fps. For instance, if you wanted your movie to be compatible with NTSC, this will do the trick:

ffmpeg -r 29.97 -i frame_%06d.png -vcodec h264 -b 5000k -coder 1 -r 29.97 video_part.mp4

The difference is that both the input:

ffmpeg -r 29.97

and the output:

-r 29.97 video_part.mp4

define the frame rate.

With my example from the last post, FFMPEG would have taken the input at 29.97 fps, then expanded it out to 25 fps. In my test case it generated 2083 more frames than I needed! Yikes!!!

mencoder -ovc/oac lavc is like using ffmpeg, as ffpmeg uses libavcodec, which is what -ovc/oac lavc are based around. -of lavf is essentially ffmpeg format muxing with mencoder.

Offline

#14 2007-01-14 07:23:53

skottish
Forum Fellow
From: Here
Registered: 2006-06-16
Posts: 7,942

Re: x264 questions

(my current Mplayer-SVN, FFMPEG-SVN, X264-SVN, and GPAC were all built yesterday, 1/13/2007)

This is new behavior for Mencoder. If I did:

mencoder "mf://*.png" -mf fps=10 -o test.avi -ovc lavc -lavcopts vcodec=h264

a month ago, this would have produced an AVI file of 10 fps of all the PNG files in the current directory. It doesn't do that anymore. This would take in the all the PNG files of the current directory, input them at 10 fps, then would expand out the movie to fit in with h264's default of 25 fps. The output movie will grow by 250 percent. That's the point of my last post.

Offline

Board footer

Powered by FluxBB