You are not logged in.

#1 2010-11-06 12:20:26

lynix
Member
From: Karlsruhe, Germany
Registered: 2008-04-23
Posts: 230

[solved] x264 encoding problems: stuttering

I'm having strange problems encoding x264 video with avidemux:

http://www.youtube.com/watch?v=615_f6NAM1s

I used the default settings for "MPEG4 AVC" except an average video btitrate of 3659 kbps. Any suggestions what could be wrong?


Thanks,

lynix

Last edited by lynix (2010-11-09 19:12:58)

Offline

#2 2010-11-06 12:30:47

Army
Member
Registered: 2007-12-07
Posts: 1,784

Re: [solved] x264 encoding problems: stuttering

Jesus Christ that looks horrible! Does it look okay with any other codec???

Offline

#3 2010-11-06 12:43:20

lynix
Member
From: Karlsruhe, Germany
Registered: 2008-04-23
Posts: 230

Re: [solved] x264 encoding problems: stuttering

Indeed it does smile Yes, with DivX for example everything is fine.

Offline

#4 2010-11-06 13:34:57

graysky
Wiki Maintainer
From: :wq
Registered: 2008-12-01
Posts: 10,604
Website

Re: [solved] x264 encoding problems: stuttering

Have you tried handbrake-svn (in AUR) for encoding?


CPU-optimized Linux-ck packages @ Repo-ck  • AUR packagesZsh and other configs

Offline

#5 2010-11-06 15:49:59

lynix
Member
From: Karlsruhe, Germany
Registered: 2008-04-23
Posts: 230

Re: [solved] x264 encoding problems: stuttering

No I didn't, because handbrake can only take DVD as input as far as I know.

I wanted to take a 1080p full-HD .mkv and scale it down to 720p for my HTPC.

Offline

#6 2010-11-06 15:52:52

Dogmeat
Member
From: Slovak Republic
Registered: 2009-02-24
Posts: 193

Re: [solved] x264 encoding problems: stuttering

lynix wrote:

I wanted to take a 1080p full-HD .mkv and scale it down to 720p for my HTPC.

Handbrake can do it. I recommend handbrake-svn as well as graysky.

Offline

#7 2010-11-06 15:56:11

lynix
Member
From: Karlsruhe, Germany
Registered: 2008-04-23
Posts: 230

Re: [solved] x264 encoding problems: stuttering

The current handbrake-svn doesn't build, I'm trying to fix the PKGBUILD and give it a chance.

Thanks for the tip, you two smile

Offline

#8 2010-11-06 16:12:47

graysky
Wiki Maintainer
From: :wq
Registered: 2008-12-01
Posts: 10,604
Website

Re: [solved] x264 encoding problems: stuttering

lynix wrote:

The current handbrake-svn doesn't build, I'm trying to fix the PKGBUILD and give it a chance.

Thanks for the tip, you two smile

You can always default to the "handbrake" package in [extra] but what problems are you experiencing with the svn package?  Builds fine for me.


CPU-optimized Linux-ck packages @ Repo-ck  • AUR packagesZsh and other configs

Offline

#9 2010-11-07 00:24:19

DrZaius
Member
Registered: 2008-01-02
Posts: 193

Re: [solved] x264 encoding problems: stuttering

Just use FFmpeg:

ffmpeg -i input.foo -vcodec libx264 -vpre medium -crf 22 -acodec copy -vf scale=1280:-1 -map_meta_data 0:0 -threads 0 output.mkv

Required reading: FFmpeg x264 encoding guide.

You could use x264 directly too, but I recommend compiling it with lavf or ffms support first.

Offline

#10 2010-11-07 09:20:59

lynix
Member
From: Karlsruhe, Germany
Registered: 2008-04-23
Posts: 230

Re: [solved] x264 encoding problems: stuttering

graysky wrote:

You can always default to the "handbrake" package in [extra] but what problems are you experiencing with the svn package?  Builds fine for me.

I tried handbrake from [extra], biut didn't find any way to select a file as input, instead of a disc. handbrake-svn fails like this:

libtool: link: ranlib .libs/libmp4v2.a
libtool: link: ( cd ".libs" && rm -f "libmp4v2.la" && ln -s "../libmp4v2.la" "libmp4v2.la" )
make[1]: Leaving directory `/tmp/yaourt-tmp-alex/aur-handbrake-svn/src/hb-trunk-build/build/contrib/mp4v2/mp4v2-trunk-r355'
touch contrib/mp4v2/.stamp.build
    Aborting...
==> ERROR: Makepkg was unable to build handbrake-svn.
DrZaius wrote:

Just use FFmpeg:

ffmpeg -i input.foo -vcodec libx264 -vpre medium -crf 22 -acodec copy -vf scale=1280:-1 -map_meta_data 0:0 -threads 0 output.mkv

Thanks, will try that too smile

Last edited by lynix (2010-11-07 09:21:18)

Offline

#11 2010-11-09 07:39:48

buzzqw
Member
Registered: 2010-08-18
Posts: 59

Re: [solved] x264 encoding problems: stuttering

@lynix
the problem is due do bad decoding of original file, not to encoding

try x264 alone like this

x264  myfile.mkv   --pass 1 --bitrate 3659 --preset medium  --tune film --video-filter crop:2,0,18,90/resize:640,416,method=spline --no-interlaced  --output output.mkv
x264  myfile.mkv   --pass 2 --bitrate 3659 --preset medium  --tune film --video-filter crop:2,0,18,90/resize:640,416,method=spline --no-interlaced  --output output.mkv

or decode using ffmpeg and pipe to x264 (use mkfifo or whatever...)

ffmpeg -i myfile.mkv -croptop 0 -cropbottom 90 -cropleft 2 -cropright 18 -s 640x416  -an -v 0 -pix_fmt yuv420p -f rawvideo - | x264  --pass 1 --bitrate 3659 --preset medium  --tune film  --output output.mkv - --input-res 640x416
ffmpeg -i myfile.mkv -croptop 0 -cropbottom 90 -cropleft 2 -cropright 18 -s 640x416  -an -v 0 -pix_fmt yuv420p -f rawvideo - | x264  --pass 2 --bitrate 3659 --preset medium  --tune film  --output output.mkv - --input-res 640x416

just pay attention to crop filter and output resolution

or use one of my gui wink (.. maybe i will post on aur )

BHH


HDConvertToX, AutoMen, AutoMKV author

Offline

#12 2010-11-09 13:41:02

windscape
Member
Registered: 2010-04-30
Posts: 69

Re: [solved] x264 encoding problems: stuttering

I personally recommend using h264enc from AUR. It can take a DVD or any file as input and encode to H.264. I use it to encode DVDs or Blu-Rays to smaller H.264 files. The output files don't stutter, the only issue they have is if the input audio is DTS, then the output A/V sync is generally off. I work around that by re-encoding the DTS into AC3. People say that re-encoding degrades quality, but my eyes and ears can't tell the difference. h264enc uses mencoder to do the encoding, which I believe uses libx264 for the H.264 heavy lifting.

Offline

#13 2010-11-09 19:12:35

lynix
Member
From: Karlsruhe, Germany
Registered: 2008-04-23
Posts: 230

Re: [solved] x264 encoding problems: stuttering

Thanks for all the replies smile

I finally re-encoded my file using ffmpeg:

ffmpeg -i infile.mkv -an -sn -vcodec libx264 -vpre slow_firstpass -b 5000k -pass 1 -vf scale=1280:-1 -threads 0 outfile.mkv
ffmpeg -i infile.mkv -an -scodec copy -vcodec libx264 -vpre slow -b 5000k -pass 2 -vf scale=1280:-1 -threads 0 -y outfile.mkv

Then I merged audio back in with mkvmerge. The remaining question is whether en- or decoding went wrong, and if the former is the case, why Avidemux failed while ffmpeg succeeded. I'll try the method buzzqw mentioned.

Also I wonder if there is no "easier" method of just changing the resolution (1080p -> 720p) without a completely new analysis. I mean, is there no shortcut when you keep the codec and just scale down the pictures? ^^

Anyway, I'll mark the thread as solved because the troubles are gone with ffmpeg. Thanks again smile

Offline

#14 2010-11-09 20:39:19

DrZaius
Member
Registered: 2008-01-02
Posts: 193

Re: [solved] x264 encoding problems: stuttering

lynix wrote:

Thanks for all the replies smile

I finally re-encoded my file using ffmpeg:

ffmpeg -i infile.mkv -an -sn -vcodec libx264 -vpre slow_firstpass -b 5000k -pass 1 -vf scale=1280:-1 -threads 0 outfile.mkv
ffmpeg -i infile.mkv -an -scodec copy -vcodec libx264 -vpre slow -b 5000k -pass 2 -vf scale=1280:-1 -threads 0 -y outfile.mkv

Unless you targeting a specific output file size you should use single-pass CRF in most cases as shown in my previous example.

lynix wrote:

Also I wonder if there is no "easier" method of just changing the resolution (1080p -> 720p) without a completely new analysis. I mean, is there no shortcut when you keep the codec and just scale down the pictures? ^^)

You could simply tell your player to scale the video upon decoding.  Otherwise, you must re-encode the video if you want to scale the output.

Offline

#15 2010-11-09 20:54:12

lynix
Member
From: Karlsruhe, Germany
Registered: 2008-04-23
Posts: 230

Re: [solved] x264 encoding problems: stuttering

DrZaius wrote:

Unless you targeting a specific output file size you should use single-pass CRF in most cases as shown in my previous example.

File size is the thing I was interested in: in my opinion disk capacities have not grown as fast as movie file sizes of recent quality. So I only keep 1080p for my favourite movies and prefer 720p for the rest, to save disk space.

I tried CRF but either the result quality or the file size was not satisfying, maybe I chose the wrong factor? ~10 - ~15?

Last edited by lynix (2010-11-09 20:55:41)

Offline

#16 2010-11-09 21:47:10

Darksoul71
Member
Registered: 2010-04-12
Posts: 319

Re: [solved] x264 encoding problems: stuttering

Hi lynix,

you should listen to buzzqw. Esp since he wrote AutoMKV smile

Personally I never had big success with Avidemux and h264-based sources.

Examples:
The captures from my HD camcorder are h264 plus AAC audio in AVI container. Avidemux (both under Ubuntu 9.10 as well as under arch) give me either green screen when I open the video or tend to be async.
After conversion of the audio to PCM I mainly use VirtualDub under WinXP to cut framebased. After this I reencode audio to MP3 and store the resulting video inside an MKV container.

Using Avidemux for shrinking oversized HD material also failed because the resulting MKV showed either strange image corruption during playback or became async after a while.

I used ffmpeg with big success and without any issues for shrinking those HD material. I´ve heared that peoples swear on h264 being much better than using ffmpeg for h264. I did some experiments and hardly can tell the difference between a 1080p video shrinked with both ffmpeg and h264.

Also I wonder if there is no "easier" method of just changing the resolution (1080p -> 720p) without a completely new analysis. I mean, is there no shortcut when you keep the codec and just scale down the pictures?

 
No, this is technically not possible. For MPEG2 there are compressed domain transcoders (e.g. requant / DVD Shrink) which can "compress" the video without full decoding and (re)encoding. I guess when not touching resolution then something similar might be possible to build a compressed domain transcoder for h264 stuff but I am not aware of one.
For 1080p->720p the simplest approach to speed up things is using a decoder which uses the acceleration features of your GPU. For Windows this is possible by using DGAVCIndex and an NVidia card. For Linux I can not tell what is possible.

Best regards,
D$


My archlinux x86_64 host:
AMD E350 (2x1.6GHz) / 8GB DDR3 RAM / GeForce 9500GT (passive) / Arch running from 16GB USB Stick

Offline

Board footer

Powered by FluxBB