Welcome to Doom9's Forum, THE in-place to be for everyone interested in DVD conversion.

Before you start posting please read the forum rules. By posting to this forum you agree to abide by the rules.

 

Go Back   Doom9's Forum > Video Encoding > MPEG-4 AVC / H.264

Reply
 
Thread Tools Search this Thread Display Modes
Old 26th December 2008, 17:35   #1  |  Link
stpdrgstr
Registered User
 
Join Date: Oct 2008
Posts: 37
x264 Lossless question

Hi, good day.

I was wondering if is safe to use x264 lossless, and is comparable to Lagarith.

I mean, if I reencode this x264 lossless to x264 lossy, it's the same as to reencode a Lagarith to a x264 lossy?

And, should I be using CoreAVC or libavcodec to decode this lossless through DSS2()?

These question had been retaining my sleep these days, so I would be very gratefull if they could be answered

Thanks.
stpdrgstr is offline   Reply With Quote
Old 26th December 2008, 17:49   #2  |  Link
Dark Shikari
x264 developer
 
Dark Shikari's Avatar
 
Join Date: Sep 2005
Posts: 8,666
x264 lossless has pretty much strictly superior compression to Lagarith, even in intra-only mode IIRC.

Unlike Lagarith, it only supports the YV12 colorspace.

To decode it correctly, you need a libavcodec from within the past ~2-3 weeks (as that's when support was added) or CoreAVC 1.8.5.
Dark Shikari is offline   Reply With Quote
Old 26th December 2008, 18:19   #3  |  Link
Atak_Snajpera
RipBot264 author
 
Atak_Snajpera's Avatar
 
Join Date: May 2006
Location: Poland
Posts: 7,929
How to encode to lossless?
Atak_Snajpera is offline   Reply With Quote
Old 26th December 2008, 18:33   #4  |  Link
J_Darnley
Registered User
 
J_Darnley's Avatar
 
Join Date: May 2006
Posts: 957
Atak_Snajpera, huh? --qp 0 is that what you mean?

stpdrgstr, lossless is lossless, the input to "x264 lossy" in both cases should be the same.
__________________
x264 log explained || x264 deblocking how-to
preset -> tune -> user set options -> fast first pass -> profile -> level
Doom10 - Of course it's better, it's one more.

Last edited by J_Darnley; 26th December 2008 at 18:36.
J_Darnley is offline   Reply With Quote
Old 26th December 2008, 18:34   #5  |  Link
Atak_Snajpera
RipBot264 author
 
Atak_Snajpera's Avatar
 
Join Date: May 2006
Location: Poland
Posts: 7,929
Quote:
Huh? --qp 0 is that what you mean?
yep! I meant switch. Thanks
Atak_Snajpera is offline   Reply With Quote
Old 26th December 2008, 19:53   #6  |  Link
stpdrgstr
Registered User
 
Join Date: Oct 2008
Posts: 37
Thank you very much. Now I can keep encoding at ease
stpdrgstr is offline   Reply With Quote
Old 27th December 2008, 17:23   #7  |  Link
LoRd_MuldeR
Software Developer
 
LoRd_MuldeR's Avatar
 
Join Date: Jun 2005
Location: Last House on Slunk Street
Posts: 13,269
Note that for frame-accurate access to H.264 streams (lossless or not) you should use DGAVCIndex/AVCSource() instead of DirectShow.

I'm not sure whether AVCSource() already has an updated libavcodec with support for x264 lossless mode though...
__________________
Go to https://standforukraine.com/ to find legitimate Ukrainian Charities 🇺🇦✊
LoRd_MuldeR is offline   Reply With Quote
Old 27th December 2008, 17:37   #8  |  Link
Dark Shikari
x264 developer
 
Dark Shikari's Avatar
 
Join Date: Sep 2005
Posts: 8,666
Quote:
Originally Posted by LoRd_MuldeR View Post
Note that for frame-accurate access to H.264 streams (lossless or not) you should use DGAVCIndex/AVCSource() instead of DirectShow.
Frame-accurate access should never be an issue with lossless regardless of the decoder being used... since you shouldn't be using B-frames with lossless, so there is no frame delay.
Dark Shikari is offline   Reply With Quote
Old 27th December 2008, 17:45   #9  |  Link
LoRd_MuldeR
Software Developer
 
LoRd_MuldeR's Avatar
 
Join Date: Jun 2005
Location: Last House on Slunk Street
Posts: 13,269
Quote:
Originally Posted by Dark Shikari View Post
you shouldn't be using B-frames with lossless
Didn't know that. Why is it like that? And does x264 automatically set "--bframe 0" when "--qp 0" is used?

(Could check the sources, but I'm too lazy right now ^^)
__________________
Go to https://standforukraine.com/ to find legitimate Ukrainian Charities 🇺🇦✊
LoRd_MuldeR is offline   Reply With Quote
Old 27th December 2008, 17:47   #10  |  Link
Dark Shikari
x264 developer
 
Dark Shikari's Avatar
 
Join Date: Sep 2005
Posts: 8,666
Quote:
Originally Posted by LoRd_MuldeR View Post
Didn't know that. Why is it like that?
It always reduces compression.
Quote:
Originally Posted by LoRd_MuldeR View Post
And does x264 automatically set "--bframe 0" when "--qp 0" is used?
No, because x264 isn't designed to protect you from your own stupidity.

A warning might be useful though.
Dark Shikari is offline   Reply With Quote
Old 27th December 2008, 17:48   #11  |  Link
LoRd_MuldeR
Software Developer
 
LoRd_MuldeR's Avatar
 
Join Date: Jun 2005
Location: Last House on Slunk Street
Posts: 13,269
Quote:
Originally Posted by Dark Shikari View Post
It always reduces compression.
With "always" you mean "B-Frames always reduce compression in lossless mode". Not in general. Right?

Quote:
Originally Posted by Dark Shikari View Post
No, because x264 isn't designed to protect you from your own stupidity.
__________________
Go to https://standforukraine.com/ to find legitimate Ukrainian Charities 🇺🇦✊
LoRd_MuldeR is offline   Reply With Quote
Old 27th December 2008, 17:56   #12  |  Link
LoRd_MuldeR
Software Developer
 
LoRd_MuldeR's Avatar
 
Join Date: Jun 2005
Location: Last House on Slunk Street
Posts: 13,269
I created streams with x264's mode "predictive lossless" mode using P-Frames and even B-Frames (didn't know b-frames are bad for lossless) and CoreAVC as well as recent ffdshow do handle it properly.
__________________
Go to https://standforukraine.com/ to find legitimate Ukrainian Charities 🇺🇦✊
LoRd_MuldeR is offline   Reply With Quote
Old 28th December 2008, 14:49   #13  |  Link
vmrsss
Registered User
 
Join Date: Mar 2008
Posts: 144
so what's a sensible command line for lossless?
vmrsss is offline   Reply With Quote
Old 28th December 2008, 14:55   #14  |  Link
Dark Shikari
x264 developer
 
Dark Shikari's Avatar
 
Join Date: Sep 2005
Posts: 8,666
Quote:
Originally Posted by vmrsss View Post
so what's a sensible command line for lossless?
Ultra-fast: --subme 1 --no-cabac --partitions none --me dia

Normal: --subme 5 --partitions all

Slow: --subme 6 --8x8dct --partitions all --ref 2

Slower: --subme 8 --8x8dct --partitions all --ref 4 --me umh --mixed-refs

Slowest: --subme 8 --8x8dct --partitions all --ref 16 --me esa --mixed-refs

Note that no-cabac loses about 10-15% compression but massively speeds up playback. Other things that hurt compression the most are subme=0 (vs other values) and partitions=none.
Dark Shikari is offline   Reply With Quote
Old 10th April 2024, 14:21   #15  |  Link
damian101
Registered User
 
damian101's Avatar
 
Join Date: Feb 2021
Location: Germany
Posts: 21
Quote:
Originally Posted by Dark Shikari View Post
Ultra-fast: --subme 1 --no-cabac --partitions none --me dia

Normal: --subme 5 --partitions all

Slow: --subme 6 --8x8dct --partitions all --ref 2

Slower: --subme 8 --8x8dct --partitions all --ref 4 --me umh --mixed-refs

Slowest: --subme 8 --8x8dct --partitions all --ref 16 --me esa --mixed-refs

Note that no-cabac loses about 10-15% compression but massively speeds up playback. Other things that hurt compression the most are subme=0 (vs other values) and partitions=none.
Code:
--partitions all
is usually harmful on noisy camera content, especially with subme < 6

Also,
Code:
--8x8dct
should be default anyway with all presets except ultrafast.
damian101 is offline   Reply With Quote
Old 28th December 2008, 16:20   #16  |  Link
vucloutr
Registered User
 
vucloutr's Avatar
 
Join Date: Nov 2008
Posts: 64
no --subme 9 for Slowest ?
typo or is there actually something to it ?
vucloutr is offline   Reply With Quote
Old 28th December 2008, 16:22   #17  |  Link
Dark Shikari
x264 developer
 
Dark Shikari's Avatar
 
Join Date: Sep 2005
Posts: 8,666
Quote:
Originally Posted by vucloutr View Post
no --subme 9 for Slowest ?
typo or is there actually something to it ?
No B-frames, so it isn't as if there's any difference between 8 and 9...
Dark Shikari is offline   Reply With Quote
Old 28th December 2008, 20:34   #18  |  Link
Daiz
Registered User
 
Join Date: Jan 2008
Location: Finland
Posts: 68
I've made some of my own tests regarding various lossless video formats, and found out that not only does lossless H.264 compress the best, it also provides the fastest playback speeds.

In the test I made a while back, I encoded the same 2000-frame clip from a DVD source to various lossless formats and then made a 2-pass encode with x264 from the various lossless files using simple AviSynth inputs. Processor used was Intel C2Q Q6600 @ 2.4 GHz.

These were the x264 encoding settings used for the lossless -> lossy encode:
Code:
x264.exe --pass 1 --stats ".stats" --progress -B 768 -b 16 -r 1 --me dia --progress --subme 1 --no-dct-decimate --partitions none --threads 6
x264.exe --pass 2 --stats ".stats" --progress -B 768 -b 16 -r 6 --mixed-refs --b-pyramid --weightb --me umh --subme 7 --merange 24 --bime --b-rdo -A all --8x8dct --threads 6 --trellis 2 --aq-strength 1.0
And these were the results:
Quote:
Lossless H.264 (encoded with --no-cabac) - average 47.587 fps - DSS2() with CoreAVC
1st pass: 143.07 fps, 790.41 kb/s
2nd pass: 28.54 fps, 778.01 kb/s

Lossless H.264 (encoded with --no-cabac) - average 47.014 fps - DSS2() with CCCP 2008-01-24's ffdshow
1st pass: 136.90 fps, 790.41 kb/s
2nd pass: 28.38 fps, 778.01 kb/s

Lossless H.264 (encoded with --no-cabac) - average 45.901 fps - FFMPEGSource()
1st pass: 133.39 fps, 790.41 kb/s
2nd pass: 27.72 fps, 778.01 kb/s

Lossless H.264 (encoded with --no-cabac) - average 45.250 fps - DirectShowSource() with CoreAVC
1st pass: 128.94 fps, 790.41 kb/s
2nd pass: 27.44 fps, 778.01 kb/s

FFVHuffy - average 42.722 fps - AVISource()
1st pass: 109.81 fps, 789.82 kb/s
2nd pass: 26.52 fps, 777.78 kb/s

Lossless H.264 - average 40.713 fps - DirectShowSource() with CoreAVC
1st pass: 92.26 fps, 793.68 kb/s
2nd pass: 26.12 fps, 778.26 kb/s

HuffYUV - average 27.449 fps - AVISource()
1st pass: 35.19 fps, 792.69 kb/s
2nd pass: 22.50 fps, 779.06 kb/s

Lagarith - average 15.130 fps - AVISource()
1st pass: 12.61 fps, 792.69 kb/s
2nd pass: 18.91 fps, 779.06 kb/s
I've been using x264 for my lossless needs ever since

Edit: Fixed the averages.
__________________
Where did neuron1 go? | Doom10

Last edited by Daiz; 28th December 2008 at 22:25.
Daiz is offline   Reply With Quote
Old 28th December 2008, 20:41   #19  |  Link
Dark Shikari
x264 developer
 
Dark Shikari's Avatar
 
Join Date: Sep 2005
Posts: 8,666
Note the proper way to average "20fps" and "100fps" is to do 2/(((1/20)+(1/100))), not just average the FPS (since the computer spends more time doing the 20fps encoding than the 100fps, so the average has to be weighted).
Dark Shikari is offline   Reply With Quote
Old 29th December 2008, 01:38   #20  |  Link
Selur
Registered User
 
Selur's Avatar
 
Join Date: Oct 2001
Location: Germany
Posts: 7,632
Just to be on the save side I ask: (otherwise I know there would be a thread in a not to distant future where Dark Shikari writes something like: "How people come to such assumtions ..."

Are there any other options aside form b-frame related once and "-nr" that should be (need to be) disabled when aiming for a lossless encode?

Cu Selur
__________________
Hybrid here in the forum, homepage, its own forum
Selur is offline   Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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

Forum Jump


All times are GMT +1. The time now is 18:05.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.