Author Topic: Looking for comparison FFmpeg, MPEG2Enc, HCEnc  (Read 14842 times)

Offline Redsandro

  • Member
  • Posts: 82
  • Woop woop!
    • View Profile
    • REDnet
Looking for comparison FFmpeg, MPEG2Enc, HCEnc
« on: January 10, 2010, 06:31:39 PM »
Since FFmpeg and Mencoder use the same codebase for MPEG2, I left it out.

I was trying to find out which has the best quality. I made some comparisons and overlayed them in Photoshop, but apart from visible differences I couldn't say one is better than the other. This probably means I compared wrong footage.

On general, I hear that FFmpeg is faster but Mencoder MPEG2enc is better, and HCencoder is best. That last is what I hear and what is claimed on Doom9, but I've not seen it in any comparison at all. Also, HCenc is a one man closed source tool.

FFmpeg being faster is also subjective because you don't have to use the default options.

Doing more comparisons on other footage is so time consuming and I am pretty sure someone else already did it.

So there's two questions: Which do you prefer, and do you have a link to a little comparison out there?
« Last Edit: January 10, 2010, 10:56:59 PM by Redsandro »
Images are DISALLOWED

Offline Dark Shikari

  • x264 developer
  • Administrator
  • Member
  • *****
  • Posts: 650
    • View Profile
Re: Looking for comparison FFmpeg, MPEG2Enc, HCEnc
« Reply #1 on: January 10, 2010, 10:27:17 PM »
ffmpeg and mencoder are just frontends for the same MPEG-2 encoder.

Offline Redsandro

  • Member
  • Posts: 82
  • Woop woop!
    • View Profile
    • REDnet
Re: Looking for comparison FFmpeg, MPEG2Enc, HCEnc
« Reply #2 on: January 10, 2010, 10:54:44 PM »
That's sort of what I meant by using the same codebase and why I left Mencoder out.
Feel free to add other encoders, but my main interest lies with these three and the claims people make about them without me being able to find a comparison on the internet.

The only thing I've noticed is that Mpeg2enc and FFmpeg seem the same to me, while HCenc looks a bit artificially softened. And HCenc spams the stream with itself as the writing application where FFmpeg doesn't. Something about making it obvious that you didn't pay MPEG licensing fee's where a clean stream might as well has come from your legal copy of Encore for which an MPEG fee was payed.rated with

-edit-
After I wrote this, I noticed that the second time I mentioned Mencoder I actually meant MPEG2enc, I fixed this in the initial post.
« Last Edit: January 10, 2010, 10:56:25 PM by Redsandro »
Images are DISALLOWED

Offline qyot27

  • Isn't it sad?
  • Member
  • Posts: 106
    • View Profile
Re: Looking for comparison FFmpeg, MPEG2Enc, HCEnc
« Reply #3 on: January 11, 2010, 04:28:41 PM »
I'd compared ffmpeg to HCenc about a year and a half ago, but it wasn't some highly-stratified scientific test or anything.  And in a year and a half's time, much of this could have been fixed, if work was/is still going into the MPEG-2 encoder, anyway.

Most of my reason to encode in MPEG-2 is for DVD authoring, and at that point, ffmpeg had a couple disadvantages compared to HCenc - lack of 3:2 pulldown support (I dunno if that's there now, but when I did the test it was necessary to follow up with DGPulldown; either that, or the build I was using was broken or outdated, but I don't think that was the case), and there was a strange issue with the start frame where it would look as if it was compressed with a much higher quantizer than the P and B frames that followed it, and therefore looked awful, even if the bitrate was set at 6000kbps.  Using settings intended for DVD compliancy, there was no way to fix it that I can remember.

HCenc, on the other hand, can produce streams with 3:2 pulldown without an added step (meaning I only need DGPulldown for 25->29.97 [25000/1000->30000/1001] or 24->29.97 [24000/1000->30000/1001] streams), and the frame quality was consistent - and HCenc is pretty specifically vetted for DVD compliancy in the first place.  There's also something of a chance I'd use it for doing MPEG-2 for Blu-ray, although if I was encoding for Blu-ray I'd probably be using H.264 99% of the time.

Offline Redsandro

  • Member
  • Posts: 82
  • Woop woop!
    • View Profile
    • REDnet
Re: Looking for comparison FFmpeg, MPEG2Enc, HCEnc
« Reply #4 on: January 11, 2010, 09:33:32 PM »
Thanks, that's the kind of experiences I am looking for!

My main use is also for DVD. I pretty much use AVC for anything else. A dvd-player is almost as common as a faucet these days so it's a good way to distribute presentations for the livingroom.

But it's clear that your experience is much worse than mine. I don't know for the pulldown because I do processing like that in AviSynth anyway, but the compression itself looks different but similar (as in no obvious blockiness and other artifacts).

I hope HCenc goes open source some time so anything good can be merged with libavcodec, but I don't think so.
Images are DISALLOWED

Offline Quarkboy

  • Member
  • Posts: 33
    • View Profile
Re: Looking for comparison FFmpeg, MPEG2Enc, HCEnc
« Reply #5 on: January 12, 2010, 12:32:09 PM »
I recently tried using mencoder for DVD encoding, and found that the rate control was total crap at the moment.

It would do a lot of really weird things, like make I frames quant 8 which b frames were 4, etc... Producing a spec complaint DVD stream that actually used bitrate efficiently seemed darn nigh impossible despite me fiddling with the settings and even experimenting with custom rate control equations...

Maybe there's some way to get it to have decent rate control but I couldn't find it.

On the other hand I installed henc (actually a batch gui for it), set the options and bitrate, and found myself with a very nicely rate controled, fully spec compliant, exactly the bitrate I wanted stream that looked really excellent (note: I was using bitrates near DVD's limit on a 23.976 source so the quality was only compared at high bitrates).

I compared it to tmpeg, and it looks to me like it beats that in quality by a bit to my eye.

So I'd have to say go with henc all the way unless you want precise control over the exact encoding method and have your own rate control scheme you want to implement for some reason.

Offline Redsandro

  • Member
  • Posts: 82
  • Woop woop!
    • View Profile
    • REDnet
Re: Looking for comparison FFmpeg, MPEG2Enc, HCEnc
« Reply #6 on: January 13, 2010, 01:06:34 AM »
Interesting!

I must say, I've heard nothing but positive stuff about HCenc. So that's a big plus.

My only problem is that it's a one man show. If he decides to get another hobby or get an accident... we're gonna have sync issues with new technology. ;)

About close to the DVD limits, what do you think are the safe DVD limits?

I did some research. It's a total (all the streams combined) of:
11,1 Mbit according to Wikipedia
10,08 Mbit According to some forums
9,8 Mbit According to some books
9,2 Mbit According to Apple
Images are DISALLOWED

Offline Dark Shikari

  • x264 developer
  • Administrator
  • Member
  • *****
  • Posts: 650
    • View Profile
Re: Looking for comparison FFmpeg, MPEG2Enc, HCEnc
« Reply #7 on: January 13, 2010, 01:28:38 AM »
Bonus points: HCEnc is written in FORTRAN.

So even if he open sourced it, nobody would be able to understand it anyways ;)

Offline Redsandro

  • Member
  • Posts: 82
  • Woop woop!
    • View Profile
    • REDnet
Re: Looking for comparison FFmpeg, MPEG2Enc, HCEnc
« Reply #8 on: January 13, 2010, 01:50:13 AM »
Oeh :P Exotic!

Fortran seems to have come a long way.
But reading code is easier than writing code, grammar seems doable and semantics are the same (sort of?). So I think it's doable to port. Just makes it slower, since Fortran is apparently a performance language!

Note: I do php, python, some java. So I can't really tell!
Images are DISALLOWED

Offline txporter

  • Member
  • Posts: 5
    • View Profile
Re: Looking for comparison FFmpeg, MPEG2Enc, HCEnc
« Reply #9 on: January 14, 2010, 02:08:57 PM »
I have also been using HCenc for MPEG2 encoding and have no issues with it to note.  I have used ffmpeg in the past and was always frustrated when it decided to simply ignore a target bitrate that I gave it.  At any rate, Hank has been working on HCenc for years.  And it accepts .avs input, so it doesn't seem likely that it will be broken that easily going forward.  If that is the only thing holding you back, I would say give it a try.

Offline Redsandro

  • Member
  • Posts: 82
  • Woop woop!
    • View Profile
    • REDnet
Re: Looking for comparison FFmpeg, MPEG2Enc, HCEnc
« Reply #10 on: January 14, 2010, 02:32:16 PM »
Yeah why not. I see either a GUI or INI based CLI though. Can you just pass commands on the command line?
Will you tell me how to do something similar like:
Code: [Select]
ffmpeg -i "%1" -target pal-dvd -aspect 16:9 -b 8000k -maxrate 8812k -ab 384k -flags mv0 -mbd rd -cmp dct -precmp dct -subcmp dct -trellis 2 -dc 10 -pass 1 -passlogfile "%1" "%1.vob" \
& ffmpeg -i "%1" -target pal-dvd -aspect 16:9 -b 8000k -maxrate 8812k -ab 384k -flags mv0 -mbd rd -cmp dct -precmp dct -subcmp dct -trellis 2 -dc 10 -pass 2 -passlogfile "%1" "%1.vob"
It's handy to have something like that sitting in your registry like so:
Code: [Select]
HKEY_CLASSES_ROOT\SystemFileAssociations\.avs\Shell\FFdvdLow\
@=Create VOB
HKEY_CLASSES_ROOT\SystemFileAssociations\.avs\Shell\FFdvdLow\Command
@=cmd /c ffmpeg -i "%1" -target pal-dvd -aspect 16:9 -b 8000k -maxrate 8812k -ab 384k -flags mv0 -mbd rd -cmp dct -precmp dct -subcmp dct -trellis 2 -dc 10 -pass 1 -passlogfile "%1" "%1.vob" & ffmpeg -i "%1" -target pal-dvd -aspect 16:9 -b 8000k -maxrate 8812k -ab 384k -flags mv0 -mbd rd -cmp dct -precmp dct -subcmp dct -trellis 2 -dc 10 -pass 2 -passlogfile "%1" "%1.vob"

In exchange I give you my script to batch encode a folder:
Code: [Select]
'' RED MpegBatcher script 0.3b6
'' Convert all .AVI files without an .MPG counterpart to .MPG using either FFMPEG or TMPGEnc
''
'' By Redsandro
'' 2008-09-07 - 2009-11-11
'' http://www.REDnet.nl/en/

' Usage:
'
' Copy this script to a folder full of .AVI's, or, add this command to your folder context-menu like so:
' Installation for Windows XP/Vista/7:
' HKEY_CLASSES_ROOT\Directory\shell\DGIndexFolder\Command
' @ = cscript.exe D:\Software\bin\FFMPEGFolder.vbs "%1"
'
' Edit a bunch of vars (Dim) below (the ones before the Subroutine starts) to suit your needs and make sure they are correct and existing. (!)
' TMPGEnc only:
' Copy a random video file to P:\Temp\TMPGEncBatcher.avi (with same specs as the files you are going to convert)
' Open TMPGEnc, load P:\Temp\TMPGEncBatcher.avi, apply your favorite settings, press ctrl+alt+M (Add project to Batch List), use P:\Temp\TMPGEncBatcher.avi as name, exit TMPGEnc.
'
' Notes:
'
' Depending on the parent app that calls this script (cscript.exe, command, registry shell extension, or some explorer replacement) the system32 folder from Windows will either be mapped to SysWOW64 or not.
' Make sure required commands are available from both (for example ffmpeg.exe)
'
' FFMPEG requires you to have installed AviSynth.

Option Explicit
'On Error Resume Next



' GLOBAL
'

' Set this to your encoding preference
' FFMPEG/TMPGEnc/AFTEREFFECTS
Dim encoder: encoder = "FFMPEG"
' Set this to trailing text in your .AVI name that's not in your .MPEG files.
' For example, my lagarith avifiles are named as "Shot 02.01.03 Morning.Laggy.avi" while the mpegs are called "Shot 02.01.03 Morning.mpg"
Dim aviTrail: aviTrail = ".Laggy"
' Similar for the mpegfile, if you want to do something crazy like appending a date.
' Note that this is included in the search for already mpegged files.
Dim mpgTrail: mpgTrail = ""

' TMPGEnc
'

' Set this to your TMPGEnc path INCLUDING END SLASH.
Dim TMPGEncPath: TMPGEncPath = "D:\Software\Video\TMPGEnc Plus\"
' Set this to your TMPGEnc executable.
Dim TMPGEnc: TMPGEnc = "TMPGEnc.exe"
' Set this to your temporary video folder. INCLUDE END SLASH.
Dim TempDir: TempDir = "P:\Temp\"
' Set this to your temporary video name. NO EXTENSION.
Dim TempFile: TempFile = "TMPGEncBatcher"

' FFMPEG
'

' Command
Dim FFavs: FFavs = "MpegBatcherFFMPEG.avs"
Dim FFmpg: FFmpg = "MpegBatcherFFMPEG.mpg"
Dim FFcmd: FFcmd = "ffmpeg -i " & FFavs & " -s hd1080 -aspect 16:9 -r 25 -vcodec mpeg2video -f vob -b 25M -mbd rd -trellis 2 -cmp 2 -subcmp 2 -g 13 -bf 2 -ab 384k " & FFmpg & ""
'Dim FFcmd: FFcmd = "ffmpeg -i " & FFavs & " -s hd1080 -aspect 16:9 -r 25 -vcodec mpeg2video -f vob -b 25M -qmin 1 -qmax 31 -bufsize 35M -mbd rd -trellis 2 -cmp 2 -subcmp 2 -g 13 -bf 2 -ab 384k " & FFmpg & "" ' fail blocky
'-qmin 1 -qmax 31 -vb 25000k -minrate 800k -maxrate 35000k -bufsize $[(512)*8]k -flags +ildct+ilme -f mpegts -y output--mpeg2hd.ts






' Private GLOBALs
Dim fso: Set fso = CreateObject("Scripting.FileSystemObject")
Dim currentFolder, fileDone, fileSkip, fsoFile, fileMpeg, pauseExit
Dim args, arg, tmp
Dim argVerbose: argVerbose = False



' Begin
Main

Sub Main

' set globals
Set currentFolder = fso.GetFolder(".")
fileDone = 0: fileSkip = 0
pauseExit = False

' Get arguments
Set args = WScript.Arguments
For Each arg in args
If arg = "-v" Then
argVerbose = True
Elseif fso.FolderExists(arg) Then
Set currentFolder = fso.GetFolder(arg)
parseCommand(arg)
Elseif fso.FileExists(arg) Then
' Single file encoding is a SHORTCUT, not severely tested.
currentFolder = fso.GetAbsolutePathName(arg)
currentFolder = fso.GetParentFolderName(currentFolder)
'WScript.Echo currentFolder
Set currentFolder = fso.GetFolder(currentFolder)
parseCommand currentFolder.Path
' Immediately do conversion and exit Main()
Dim File: Set File = fso.getFile(arg)
Dim fileBase: fileBase = fso.getBaseName(File.Name)
Dim fileExt: fileExt = fso.getExtensionName(File.Name)
If UCase(fileExt) = "AVI" Then
fileMpeg = Replace(fileBase, aviTrail, mpgTrail, 1, -1, 1) & ".mpg"
doFFMPEG File
End If
Exit Sub
End If
Next

' Begin output
WScript.Echo "**************************"
WScript.Echo "* RED MpegBatcher script *"
WScript.Echo "**************************"
WScript.Echo ""
WScript.Echo "Encoder: " & encoder
WScript.Echo ""

Select Case UCase(encoder)
Case "TMPGENC"

If Not dialogStart("TMPGEnc Free 2.5") Then Exit Sub

' Start the process if there's a batch project
If fso.FileExists(TMPGEncPath & "CurrentBatch.tbe") Then
' Make template copy of CurrentBatch.tbe to reset finished state again and again
WScript.Echo "Backing up CurrentBatch.tbe ..."
Set fsoFile = fso.GetFile(TMPGEncPath & "CurrentBatch.tbe")
fsoFile.Copy(TMPGEncPath & "CurrentBatch.tbe.bak")
Else
WScript.Echo "You did not save your project as a Batch List in TMPGEnc!"
WScript.Echo "Save a phoney single file '" & TempDir & TempFile & ".avi' to '" & TempDir & TempFile & ".mpg' conversion batch in TMPGEnc using your preferred settings, and this file will be used for all batch conversions."
pauseExit = True
End If

Case "FFMPEG"
If Not dialogStart("FFMPEG") Then Exit Sub
Case "AFTEREFFECTS"
WScript.Echo "This encoder is not explicitly added yet. Just edit the FFMPEG command line and you're off!"
pauseExit = True
Case Else
WScript.Echo "Invalid encoding option: " & encoder
pauseExit = True
End Select

If pauseExit = False Then
' Parse folder
parseFolder currentFolder

' Ergo Conclusio
WScript.Echo fileDone & " files encoded; " & fileSkip & " files were already encoded."
End If

WScript.Echo "Press ENTER to exit."
' Pause so the promt doesn't close immediately
Do While Not WScript.StdIn.AtEndOfLine
Dim Input: Input = WScript.StdIn.Read(1)
Loop
WScript.Echo "Done."

End Sub



Sub parseCommand(ByVal strPath)
' Replace %VAR%s in command line with actual values
tmp = Chr(34) & strPath & "\" & FFavs & Chr(34)
FFcmd = Replace(FFcmd, FFavs, tmp, 1, -1, 1)
tmp = Chr(34) & strPath & "\" & FFmpg & Chr(34)
FFcmd = Replace(FFcmd, FFmpg, tmp, 1, -1, 1)
End Sub



Function dialogStart(ByVal encoder)
WScript.Echo "Sending unprocessed .AVI files to " & encoder & " from this directory: "
WScript.Echo ""
WScript.Echo currentFolder.Path
WScript.Echo ""
WScript.Echo "Search for: *" & aviTrail & ".avi"
WScript.Echo "Without:    *" & mpgTrail & ".mpg"
WScript.Echo ""
If Not promptYesNo("Continue? (y/n): ") Then dialogStart = False: Exit Function
WScript.Echo ""
dialogStart = True
End Function



Sub parseFolder (ByVal Folder)
' Prepare vars
Dim Files: Set Files = Folder.Files
Dim File

' Loop through dir
For Each File In Files
Dim fileBase: fileBase = fso.getBaseName(File.Name)
Dim fileExt: fileExt = fso.getExtensionName(File.Name)
If UCase(fileExt) = "AVI" Then
fileMpeg = Replace(fileBase, aviTrail, mpgTrail, 1, -1, 1) & ".mpg"
'fileMpeg = Replace(File.Name, aviTrail & ".avi", mpgTrail & ".mpg")
If Not fso.FileExists(currentFolder.Path & "\" & fileMpeg) Then
' Check for specified file trailing
If UCase(Right(fileBase,Len(aviTrail))) = UCase(aviTrail) Then
WScript.Echo File.Name & " FOUND"
WScript.Echo fileMpeg & " MISSING"
Select Case UCase(encoder)
Case "TMPGENC"
doTMPGEnc File
Case "FFMPEG"
doFFMPEG File
End Select
Else
fileSkip = fileSkip + 1
End If
Else
fileSkip = fileSkip + 1
End If
End If
Next
End Sub



' TMPGEnc functions
'
Sub doTMPGEnc (ByVal File)
' Dim vars
Dim tmpAvi: tmpAvi = TempDir & TempFile & ".avi"
Dim tmpMpeg: tmpMpeg = TempDir & TempFile & ".mpg"

' Check if temp files exists, delete..
If fso.FileExists(tmpAvi) Then
WScript.Echo "Deleting " & tmpAvi & " ..."
fso.DeleteFile(tmpAvi)
End If
If fso.FileExists(tmpMpeg) Then
WScript.Echo "Deleting " & tmpMpeg & " ..."
fso.DeleteFile(tmpMpeg)
End If

' Copy target file to temp file
Set fsoFile = fso.GetFile(File)
WScript.Echo "Copying " & File.Name & " to " & TempDir & "..."
fsoFile.copy(TempDir)
WScript.Echo "Renaming " & File.Name & " to " & TempFile & ".avi" & "..."
Set fsoFile = fso.GetFile(TempDir & File.Name)
fsoFile.Move(TempDir & TempFile & ".avi")

' Reset Batch List template
resetBatchList

' Run TMPGEnc in batch + autoclose mode
WScript.Echo "Starting " & TMPGEnc & "..."
WScript.Echo ""
run chr(34) & TMPGEncPath & TMPGEnc & chr(34) & " /batch /close"
fileDone = fileDone + 1

' Reset Batch List template again, (You'd understand why if you was debugging this script)
resetBatchList

' Successful? Delete .avi
If fso.FileExists(tmpAvi) Then
WScript.Echo "Deleting " & tmpAvi & " ..."
fso.DeleteFile(tmpAvi)
End If

' and move .mpg
WScript.Echo "Moving '" & tmpMpeg & "' to " & currentFolder.Path
Set fsoFile = fso.GetFile(tmpMpeg)
fsoFile.Move(currentFolder.Path & "\" & fileMpeg)
WScript.Echo ""
End Sub

Function resetBatchList()
WScript.Echo "Resetting CurrentBatch.tbe ..."
If fso.FileExists(TMPGEncPath & "CurrentBatch.tbe") Then
fso.DeleteFile(TMPGEncPath & "CurrentBatch.tbe")
End If
Set fsoFile = fso.GetFile(TMPGEncPath & "CurrentBatch.tbe.bak")
fsoFile.Copy(TMPGEncPath & "CurrentBatch.tbe")
End Function






' FFMPEG
'
Sub doFFMPEG (ByVal File)

' Create AVS file
WScript.Echo "Creating '" & FFavs & "'"
Dim avsFile: Set avsFile = fso.OpenTextFile (currentFolder.Path & "\" & FFavs, 2, True)
avsFile.WriteLine("AVISource(""" & File.Name & """)")
avsFile.WriteLine("ConvertToYV12(matrix=""Rec709"")")
avsFile.WriteLine("")
avsFile.Close

' Run FFMPEG
WScript.Echo "Starting ffmpeg.exe..."
WScript.Echo FFcmd
WScript.Echo ""
run FFcmd
' Alternate execution to run command from script dir:
'run "cmd /K CD """ & currentFolder.Path & "\"" & " & FFcmd
fileDone = fileDone + 1

' Rename MPEG
WScript.Echo "Renaming '" & FFmpg & "' to '" & fileMpeg & "'"
Set fsoFile = fso.GetFile(currentFolder.Path & "\" & FFmpg)
fsoFile.Move(currentFolder.Path & "\" & fileMpeg)

' Remove AVS file
WScript.Echo "Removing '" & FFavs & "'"
fso.DeleteFile(currentFolder.Path & "\" & FFavs)
WScript.Echo ""
End Sub






Function promptYesNo(ByVal strMsg)
   Do
WScript.Echo strMsg
Dim key: key = WScript.StdIn.ReadLine()
Select Case LCase(Trim(key))
Case "n","no"  promptYesNo = False: Exit Function
Case "y","yes" promptYesNo = True:  Exit Function
End Select
WScript.StdOut.WriteLine "Just enter 'y' or 'n'..."
Loop
End Function

Sub run(ByVal executable)
Dim shell: Set shell = CreateObject("WScript.Shell")
shell.Run executable, 1, true
Set shell = Nothing
End Sub
Images are DISALLOWED

Offline qyot27

  • Isn't it sad?
  • Member
  • Posts: 106
    • View Profile
Re: Looking for comparison FFmpeg, MPEG2Enc, HCEnc
« Reply #11 on: January 14, 2010, 05:25:55 PM »
Yeah why not. I see either a GUI or INI based CLI though. Can you just pass commands on the command line?
Will you tell me how to do something similar like:
Code: [Select]
ffmpeg -i "%1" -target pal-dvd -aspect 16:9 -b 8000k -maxrate 8812k -ab 384k -flags mv0 -mbd rd -cmp dct -precmp dct -subcmp dct -trellis 2 -dc 10 -pass 1 -passlogfile "%1" "%1.vob" \
& ffmpeg -i "%1" -target pal-dvd -aspect 16:9 -b 8000k -maxrate 8812k -ab 384k -flags mv0 -mbd rd -cmp dct -precmp dct -subcmp dct -trellis 2 -dc 10 -pass 2 -passlogfile "%1" "%1.vob"
It's handy to have something like that sitting in your registry like so:
Code: [Select]
HKEY_CLASSES_ROOT\SystemFileAssociations\.avs\Shell\FFdvdLow\
@=Create VOB
HKEY_CLASSES_ROOT\SystemFileAssociations\.avs\Shell\FFdvdLow\Command
@=cmd /c ffmpeg -i "%1" -target pal-dvd -aspect 16:9 -b 8000k -maxrate 8812k -ab 384k -flags mv0 -mbd rd -cmp dct -precmp dct -subcmp dct -trellis 2 -dc 10 -pass 1 -passlogfile "%1" "%1.vob" & ffmpeg -i "%1" -target pal-dvd -aspect 16:9 -b 8000k -maxrate 8812k -ab 384k -flags mv0 -mbd rd -cmp dct -precmp dct -subcmp dct -trellis 2 -dc 10 -pass 2 -passlogfile "%1" "%1.vob"

Included with HCenc is the PDF manual.  There's an entire section on what parameters the CLI accepts - the INI system is more robust, though.  I have all my common profiles residing in HCenc's directory and if I need to do an uncommon encode that differs from them, I simply copy the closest match, modify the new copy a little, and use that.  For the ffmpeg command you posted, the INI profile would look something like (HCenc does auto-2pass, you don't have to run pass 1 and then run pass 2 separately, although I'm sure there's a way to do separate passes if you want to):
Code: [Select]
*BITRATE          8000
*MAXBITRATE          8812
*2PASS
*PROFILE          best
*ASPECT          16:9
*GOP              12 2
*DC_PREC          10
*PROGRESSIVE
*INTRAVLC          2
*CLOSEDGOPS
*LASTIFRAME
*MPEGLEVEL        MP@ML
*MATRIX           mpeg
*WAIT             0

The only things about that I would suggest changing to your liking are:
  • You can add the *NOSMP option if your machine isn't multithreaded or you don't want to use multithreading.
  • You can change the *MATRIX parameter to whichever one you would prefer.  FOX1 is one that tends to get higher SSIM ratings, for instance.
  • You can use *1PASS to perform a faster encode where there's a very fast sample pass and then the actual 1st and final pass.
  • As of the newest or second-newest beta of 0.24, adaptive quantization is set on 2 by default; you could set it down to 1 or off with the *AQ parameter if you want, or raise it to 3 or 4 for that matter.
Some other things to remember:
  • HCenc only does video encoding; you'll need to use twolame or ffmpeg to do encoding to MP2, aften or ffmpeg to do AC3 - wavi can be used to read the audio stream straight from AviSynth, and then pipe over to twolame or aften.  Also, you'll need to use a multiplexer to combine them; my suggestions would be mplex1 or mplex from the MJPEGTools project.
  • For mplex1, all that's required is mplex1 invideo inaudio outmpeg; for mplex, you'll want mplex -f8 -V invideo inaudio -o outmpeg
  • HCenc doesn't have specific commands to specify PAL vs. NTSC; make sure that the files are 720x576/25 or 720x480/29.97 (or 23.976; HCenc will apply the pulldown flags if you use the *PULLDOWN option), unless you want to do custom pulldown of 23.976fps or 24fps to 25fps using DGPulldown.
To finally pull all of that together, the CLI would look like (I declare AR, framerate, and bitrate in the INI filenames):
Quote
wavi test.avs - | aften -b 192 - "test.ac3"
hcenc_024 -i "test.avs" -o "test.m2v" -ini "C:\Program Files\HC024\16-9_29fps-6000.ini"
mplex1 test.m2v test.ac3 finaloutput.mpg or mplex -f8 -V test.m2v test.ac3 -o finaloutput.mpg

If I'm doing custom pulldown, then:
Quote
wavi test.avs - | aften -b 192 - "test.ac3"
hcenc_024 -i "test.avs" -o "test.m2v" -ini "C:\Program Files\HC024\16-9_25fps-6000.ini"
dgpulldown test.m2v -inplace -srcfps 25 -destfps 29.97
mplex -f8 -V test.m2v test.ac3 -o finaloutput.mpg

mplex from MJPEGTools is the only multiplexer I've found that can treat custom pulldown correctly.  Be aware that for these custom pulldown situations, the framerate is the only thing that should differ from your area's specs - 23.976->25 content should still be 720x576, not 720x480.


It probably wouldn't be hard to adapt such a workflow to a predetermined script or the Registry, hopefully that provides a starting point.
« Last Edit: January 14, 2010, 05:28:26 PM by qyot27 »

Offline Redsandro

  • Member
  • Posts: 82
  • Woop woop!
    • View Profile
    • REDnet
Re: Looking for comparison FFmpeg, MPEG2Enc, HCEnc
« Reply #12 on: January 14, 2010, 07:56:21 PM »
Thanks for the great post! From my short clip tests it looks very promising; I think I'll use it for my next project!

I just need to get rid of the HCenc metadata in the stream. There was a tool for that but I forgot the name. StreamSomething was it.

Why do I care? It's a long shot. But I have my licensed copy of Adobe Media Encoder, and the price you pay includes a license for using mpeg.
If my clients find the metadata about free tools they might want to make a deal out of it. Freeware tools obviously exclude a license for publishing mpeg. Without the freeware branding I might as well have used the media encoder, although it uses the MainConcept mpeg encoder and it's just not the best. Even ffmpeg produces better quality imo.
Images are DISALLOWED

Offline Emulgator

  • Member
  • Posts: 6
    • View Profile
Re: Looking for comparison FFmpeg, MPEG2Enc, HCEnc
« Reply #13 on: February 19, 2010, 04:59:26 AM »
ReStream can empty the metadata field.

Offline Redsandro

  • Member
  • Posts: 82
  • Woop woop!
    • View Profile
    • REDnet
Re: Looking for comparison FFmpeg, MPEG2Enc, HCEnc
« Reply #14 on: February 19, 2010, 05:26:36 AM »
Ah yes that was it, and I think StreamClip can also do it.
But I am looking for a command line way, to be able to automate. Do you know a command line utility for that?
Images are DISALLOWED

Offline hank315

  • Member
  • Posts: 3
    • View Profile
Re: Looking for comparison FFmpeg, MPEG2Enc, HCEnc
« Reply #15 on: February 20, 2010, 01:36:26 AM »
To disable the user data in HCenc, use the latest beta (16-02-2010) and add the next command in the ini file: *NOUSERDATA

Offline Redsandro

  • Member
  • Posts: 82
  • Woop woop!
    • View Profile
    • REDnet
Re: Looking for comparison FFmpeg, MPEG2Enc, HCEnc
« Reply #16 on: February 20, 2010, 02:24:48 AM »
Thank you I'll check it out.
Images are DISALLOWED

Offline plonk420

  • Member
  • Posts: 18
    • View Profile
Re: Looking for comparison FFmpeg, MPEG2Enc, HCEnc
« Reply #17 on: November 27, 2010, 04:31:05 AM »
sorry to necropost, but the maxbitrate (audio AND video) a replication house i used didn't want over 9mbit (IIRC... possibly less)... :S

Offline ar

  • Member
  • Posts: 1
    • View Profile
Re: Looking for comparison FFmpeg, MPEG2Enc, HCEnc
« Reply #18 on: November 05, 2011, 08:11:24 AM »

Offline Redsandro

  • Member
  • Posts: 82
  • Woop woop!
    • View Profile
    • REDnet
Re: Looking for comparison FFmpeg, MPEG2Enc, HCEnc
« Reply #19 on: April 04, 2012, 04:43:52 PM »
Am I too old to do a proper duckduckgo/google, or hasn't there been a final version for Hank315's HCenc yet?
Latest version I can find is the .26 beta from 13 months ago.

Also, I've noticed this strange behavior where I can have 3 simultaneous encodes; ffmpeg, mencoder, and hcenc, all crunching numbers, and my machine is only using about 25% of it's processor capacity. I can almost play Battlefield in the background.

However, when I launch an instance of Adobe Media Encoder making an mpeg (I think the plugin is still from MainConcept), THEN suddenly all my 4 CPU cores go up to 100% and I can't even play minesweeper in the background.

I don't get this. Can't those 3 other encodes (I wanted to do 1 at a time, but since they seem lazy, I thought I'd do all at once to get the queue done faster) just make my computer be unusable for one hour at 100% and be done 4 times as fast?
Images are DISALLOWED

Offline qyot27

  • Isn't it sad?
  • Member
  • Posts: 106
    • View Profile
Re: Looking for comparison FFmpeg, MPEG2Enc, HCEnc
« Reply #20 on: April 04, 2012, 09:45:49 PM »
Am I too old to do a proper duckduckgo/google, or hasn't there been a final version for Hank315's HCenc yet?
Latest version I can find is the .26 beta from 13 months ago.
As far as I know, yes.  The 16-06-2011 beta is the newest one.

Quote
Also, I've noticed this strange behavior where I can have 3 simultaneous encodes; ffmpeg, mencoder, and hcenc, all crunching numbers, and my machine is only using about 25% of it's processor capacity. I can almost play Battlefield in the background.

However, when I launch an instance of Adobe Media Encoder making an mpeg (I think the plugin is still from MainConcept), THEN suddenly all my 4 CPU cores go up to 100% and I can't even play minesweeper in the background.

I don't get this. Can't those 3 other encodes (I wanted to do 1 at a time, but since they seem lazy, I thought I'd do all at once to get the queue done faster) just make my computer be unusable for one hour at 100% and be done 4 times as fast?
Do you have HCenc set to multithread?  Is your source filter multithreaded (and are you telling it to multithread, if it doesn't do so automatically)?

And HCenc won't hit 100%.  At best it'll be 75% (if I remember what hank315 said correctly).  It had something to do with overhead or thread priority or dedicating one core to the script decoding or something.

Ultimately, though, what matters is the fps the encoder is hitting, not how much CPU it consumes.  Yes, there is a correlation between them, but it's not accurate to do so when comparing to a completely different program.  The Adobe encoder might be able to take more CPU cycles, but is it really encoding 4x faster than HCenc does on 1x?  A proper comparison would be to compare the same program at 25% load vs. 100% load (or as close to 100% as you can manage).

Offline Redsandro

  • Member
  • Posts: 82
  • Woop woop!
    • View Profile
    • REDnet
Re: Looking for comparison FFmpeg, MPEG2Enc, HCEnc
« Reply #21 on: April 05, 2012, 04:04:40 AM »
The source is probably not multithreaded, but when I do 3 encodes specifically for that problem, I thought I'd get 3 cores at ~ max.

3 encodes from 3 different sources, I'd think 3 cores would be at ~ max.
Watch as I start Adobe Media Encoder (halfway through CPU graph)
Images are DISALLOWED