View Full Version : Easy way to create Blu-ray/AVCHD using the X264 encoder


Phil Lee
December 17th, 2011, 02:04 PM
Hi

Please check the pre-requisites below as it will not work without a couple of other programs (all free).

I've now uploaded for anyone who would like it an easy application that uses the very good x264 encoder to create Blu-ray/AVCHD compliant video from Sony Vegas (my main use but can be used with any editor that can output to the Lagarith codec). This isn't a commercial application, and no advertising, no nag screens, just an application I did for myself that other's may benefit from.

Download from my SkyDrive here Download (https://skydrive.live.com/redir.aspx?cid=5b9b443765162c29&resid=5B9B443765162C29!107&parid=5B9B443765162C29!105&authkey=!AITRuFrlnz0hUgs)

Please note I haven't gone to the trouble or expense of digitally signing the install file, so on Windows Vista/7 you will get an "are you sure" alert when installing. Feel free to pre-scan with a virus scanner if you wish. The application uses .NET 3.5.

What it does?

Takes Lagarith uncompressed HD video AVI's and an AC3 audio file and encodes to H264 with the audio mux'd in.
Optionally converts 1920x1080/50p/60p to: 1280x720/50p/60p using a good resizer, or to 1920x1080/50i/60i interlacing the footage, or to 1920x1080/25p/30p by using every other frame.
Enforces a valid output to AVCHD/AVCHD 2.0 and Blu-ray.
Supports 64bit encoding for compatible set-ups for a bit of extra speed on 64bit computers (see below).
Does RGB studio/computer level conversions as required and encodes using the correct colour matrix (BT709).

Pre-requisites:

Lagarith lossless codec required, download link http://lags.leetcode.net/LagarithSetup_1327.exe
AVISynth needs to be installed, the 32bit version is here Avisynth rev. 2 (http://sourceforge.net/projects/avisynth2/files/AviSynth%202.5/AviSynth%202.5.8/Avisynth_258.exe/download)
For 64bit encoding the 64bit version of Avisynth needs installing alongside the 32bit, instructions here
The 64bit port of everyone's favorite script based video editor (http://code.google.com/p/avisynth64/wiki/InstallationInstructions)



To use from Vegas:

Choose to output your project as Windows AVI file type, then click Custom, select the frame size of your source, all these are supported by the encoder 1920x1080, 1440x1080, 1280x720
Frame rate: set the same as the source, 60p, 50p, 30p, 25p, 60i, 50i are supported by the encoder.
Field order: set as appropriate to your footage (interlaced HD is usually upper field).
Pixel aspect ratio: should be 1.000 or 1.33333 for 1440x1080 HD.
Video format: select Lagarith Lossless Codec then click Configure, make sure mode is RGB (Default), out of the other check box options, have 'Use Multithreading' as the only option ticked, click OK
Leave other video settings at the default.
Audio tab: don't include audio, we'll render out AC3 separately.
Project tab: Video rendering quality select Best
Recommend to save this as template for next time.
...Render your Video
Create the audio AC3 by rendering to Dolby Digital AC-3 by selecting that in the Save as type


Note: if you play the Lagarith file back it may look washed out, don't worry, after encoding all will be okay

Encoding


Start Easy Blu-ray encoder program, if encoding is going to be using the 64bit X264 encoder it will say in the title of the form.
Browse to the AVI file, the file details and a confirmation it is a supported input file type is shown.
Browse to the AC3 audio file.
The Lagarith codec doesn't know if it holds interlaced or progressive footage, so check/uncheck the Interlaced Video option as appropriate as this setting can't be set automatically.
If your timeline is at studio level, usually the default, leave "Video is 0-255 RGB" unchecked. If the timeline is at computer levels, then check this box. This will ensure the encoding is made with the levels correct.
Under Output settings, decide your resolution, not all will be supported, for example you can't output 720p if the input is interlaced. If the output resolution isn't supported, it will flick you back to a supported one.
Select the frame or field rate, again not all will be supported by all inputs, for example you can't input 50i and select 50p as an output.
Select the destination format, again you will only be able to select options that the format supports, for example you can't select AVCHD if you are outputting 1080/60p/50p, you must select AVCHD 2.0.

H264 Output settings

Browse to a location and enter a file name for the finished output.
Select the encoding quality. I recommend always using 'excellent', but feel free to try the other options.
Select the bit-rate, you will only be able to use a bit-rate upto the maximum supported by the format type, for example AVCHD will only allow a maximum of 24,000.
Select to use or not use 2 pass encoding. For better compliance and better quality output, use 2 pass. Note that the second pass is slower than the first pass, this is normal.
Click Start to start the encoding and wait for it to finish. Once finished you will have an .mts file with your video and audio mux'd into it.


Let me know of any problems, hope it is of use to someone.

Credit to: This application uses the free libraries from MediaInfo and TSMuxer, and of course the open-source X264 encoder, these are included in the installation. The x264 encoder is the latest version as of todays date.

Regards

Phil

Tom Roper
December 22nd, 2011, 12:34 PM
Great work Phil. Let's bump this thread up.

Mike Kujbida
December 22nd, 2011, 02:15 PM
Phil, you really should put this in the Sony Vegas Tutorials sticky so it doesn't get buried in a few days.

Jon Shohet
December 22nd, 2011, 05:43 PM
I would also put it as a sticky in the Non-Linear Editing on the PC forum, as it will be really helpful for all users on Windows, not just Vegas.

Great work, thanks for sharing!

As this is something you created for yourself, I assume there's not much point in making "feature requests", but for what it's worth:

- A no-installer version would be great
- With CineForm and DNxHD both available for free, what is the reason you prefer to still use Lagarith? (I know CF and DNxHD aren't lossless, but do you actually notice a difference that justifies the monstrous file sizes?)

Phil Lee
December 23rd, 2011, 02:09 AM
Hi

Preference for Lagarith is just that it's free and lossless, other methods are frame serving from Vegas but I've found that a bit of a hassle and not always reliable. Given most of us have huge hard-disks with tons of space working with big files isn't too much of an issue hopefully.

Also using Lagarith it will accept and store the video in the RGB colour space, which is what Vegas works in on the timeline, so it's avoiding colour space conversions, leaving AVISynth to sort that out with the correct colour matrix for Blu-ray/AVCHD, and that seems to keep things very true to the original. My main goal was not to introduce any extra conversions or losses just because encoding was happening by x264 outside of Vegas, so Lagarith is essentially the raw output from Sony Vegas.

I can look at supporting other inputs, I'll have a go with Cineform, in theory any codec supported by the PC should work via AVISynth, just the application doesn't let it as some of the AVISynth colour conversions might not be correct.

A no installer version I can put together easily, I'll upload this as an option shortly.

Regards

Phil

Slava Alekseev
December 28th, 2011, 02:46 AM
Hi Phil,
May I ask you, why your "Easy Blu-ray encoder" doesn't support 23.976 frame rate for blu-ray encoding (1920x1080)?

Phil Lee
December 28th, 2011, 03:01 AM
Hi

An oversight on my part, I'll add support in the next update, which also includes the ability to use CineForm files as well.

Regards

Phil

Phil Lee
December 28th, 2011, 06:42 AM
Hi

A new version is here:

Windows Installer or Download Files only (https://skydrive.live.com/redir.aspx?cid=5b9b443765162c29&resid=5B9B443765162C29!111&parid=5B9B443765162C29!105&authkey=!ABcKtpLueuOqkW8)

Please see first post for pre-requisites and usage.

Changes:

Added support for CineForm AVI files
Added support for 24fps AVI files
Added option to set the tuning for x264 (film/video, grain, animation, still images)
Added Maximum Quality option for x264
Added support for Lagarith YUV, it is recommended to output to Lagarith using RGB but it will now encode Lagarith YUV.

Regards

Phil

Jon Shohet
December 28th, 2011, 09:41 AM
Thanks again for all the effort!

Slava Alekseev
December 28th, 2011, 10:08 AM
Nice! Thank you very much, Phil! We appreciate your hard work Well done!

Slava Alekseev
December 28th, 2011, 01:12 PM
Hi Phil,
It's me again. I am sorry, but I have another question: why is output color space YUV? I rendered from Vegas 11 to LAG with RGB color space. After encoding in "Easy Blu-ray Encoder" the color space now is YUV. Take a look at this pictures, please. First pic is input info, second is output info and last pic is interface of "Easy Blu-ray Encoder". Anyway, thanks again.

Phil Lee
December 28th, 2011, 03:56 PM
Hi

H264 for Blu-ray/AVCHD files are always YUV, so it is correct the final encoding is YUV 4.2.0.

The output from Sony Vegas being RGB to Lagarith is a convenient way of avoiding any extra colour space conversions and so stops any small rounding errors that might be introduce with multiple colour space changes. Sony Vegas works internally with RGB, so outputting as RGB to Lagarith is essentially the raw output from Sony Vegas. AVISynth is then used by the Easy encoder to convert RGB into YUV 4.2.0 for the x264 encoder. This method seems to provide the most accurate final output with no shifts in colours due to colour space conversions.

I don't think H264 supports RGB colour space, it has to be YUV regardless.

Hope that helps explain.

Regards

Phil

Slava Alekseev
December 28th, 2011, 04:24 PM
Thanks a lot, Phil! :-)

Norris Combs
July 30th, 2012, 05:54 PM
Question answered. Thank you Phil for this tutorial.

Norris Combs
July 31st, 2012, 05:57 PM
I've encountered a little problem, when encoding with x264, I selected the bit rate at the maximum value allowable for bluray, which is 40,000. Now I'm trying to have DVD Architect author it, and it can't. There's an error message stating that the overall bitrate is above 28,000. So apparently, DVD Architect cannot author anything that has a bit rate above 28,000. Am I misunderstanding what DVD Architect is telling me? FYI, I'm trying to have DVD Architect author this 5.5 GB .m2ts file as a BD, to a 8.5 GB double-layer DVD+R.

I've been able to author a BD this way before, but have never used a bitrate this high.
Thanks for any help,

Phil Lee
August 2nd, 2012, 02:57 PM
Hi

On DVD you can't go higher than around 18Mbits/sec, this is because DVD's can't be read faster than that in Blu-ray players to guarantee they will work without stuttering and stopping.

Not sure where DVD Architect gets it 28MBit/sec from?

Blu-ray is only Blu-ray when on a Blu-ray disc.

There is a bug with DVD Architect anyway where it crashes on preparing the footage when it is interlaced and produced by x264.

I'd recommend using MultiAVCHD (a google will find it) which is free and and is more accepting of video without wanting to re-encode it.

Hope that helps.

Regards

Phil

Norris Combs
August 6th, 2012, 12:09 PM
Hi

On DVD you can't go higher than around 18Mbits/sec, this is because DVD's can't be read faster than that in Blu-ray players to guarantee they will work without stuttering and stopping.

Not sure where DVD Architect gets it 28MBit/sec from?

Blu-ray is only Blu-ray when on a Blu-ray disc.

There is a bug with DVD Architect anyway where it crashes on preparing the footage when it is interlaced and produced by x264.

I'd recommend using MultiAVCHD (a google will find it) which is free and and is more accepting of video without wanting to re-encode it.

Hope that helps.

Regards

Phil

Thanks for your help. I will look into MultiAVCHD. In the past I have burned BD projects onto a standard DVD-R. The resulting disc contains a BDMV file structure, same as on a "real" BD, and my set top bluray player can play it. I used DVD Architect to author and burn. As you stated, it is very possible that the bitrate is 18 or below, therefore DVD Architect was able to author it.

Ron Cooper
August 7th, 2012, 07:16 AM
Phil, I may be over-cautious but when I tried to download your first link I got this message :

"This item might not exist or is no longer available
This item might have been deleted, expired, or you might not have permission to view it. Contact the owner of this item for more information."

After a bit more fiddling around it appeared to be hijacked by "sendspace.com" - Is this legit ?

RonC.

Eric Olson
August 7th, 2012, 12:25 PM
it appeared to be hijacked by "sendspace.com" - Is this legit?

The correct site for multiAVCHD is

::: multiAVCHD home ::: (http://multiavchd.deanbg.com/)

This program is a free but closed source work of a single author that has not been updated for more than two years. The author apparently wrote the program by reverse engineering the AVCHD file catalogue. MultiAVCHD makes use of the multiplexing program tsMuxeR which was also released as free but closed source by smartlabs.

SmartLabs (http://www.smlabs.net/)

Smartlabs removed tsMuxeR from their public downloads a couple years ago, about the same time that multiAVCHD stopped being updated.

The main advantage of x264 is its professional quality and efficiency. While multiAVCHD can be used to master an AVCHD or blu-ray disk from x264 output, I would not recommend it for professional use. Moreover, for casual use I would recommend the standard Vegas encoders and DVD Architect. It is surprising that open source blu-ray mastering tools don't exist which are similar in quality to the open source x264 encoder. I think this thread is an important one, because there is a great need to come up with a good way to master AVCHD and blu-ray disks from x264 output.

Norris Combs
August 7th, 2012, 07:05 PM
for casual use I would recommend the standard Vegas encoders and DVD Architect.

Under Custom Template, Field Order: should I select: None (progressive scan), or Upper Field First, or Lower Field First? My source is 1920 x 1080i, 29.xx fps.
Thank you,

Eric Olson
August 7th, 2012, 08:02 PM
Under Custom Template, Field Order: should I select: None (progressive scan), or Upper Field First, or Lower Field First? My source is 1920 x 1080i, 29.xx fps.

Almost always 1080i is upper field first.

Tom Roper
August 9th, 2012, 01:46 PM
Smartlabs removed tsMuxeR from their public downloads a couple years ago, about the same time that multiAVCHD stopped being updated.

The main advantage of x264 is its professional quality and efficiency. While multiAVCHD can be used to master an AVCHD or blu-ray disk from x264 output, I would not recommend it for professional use. Moreover, for casual use I would recommend the standard Vegas encoders and DVD Architect. It is surprising that open source blu-ray mastering tools don't exist which are similar in quality to the open source x264 encoder. I think this thread is an important one, because there is a great need to come up with a good way to master AVCHD and blu-ray disks from x264 output.

Any Blu-ray project that you burn yourself onto BD-R/RE media, cannot be reproduced or added by you the Blu-ray logo except the one already on the media. Technically, that's enough argument that no project you burn onto writable media is Blu-ray video just because the media is. You don't get a license to call it that. You are licensed to call it Blu-ray playable or Blu-ray data, or to indicate that it is playable on Blu-ray equipment. With that in mind, there is no reason to avoid using multiAVCHD and TSmuxeR in your professional collaborations burned onto Blu-ray writable disks.

The reason even the casual user benefits by using multiAVCHD and TSmuxeR is the output quality of the video far exceeds what you can get from the AVC encoders included with Vegas Pro 11. x264 at about 2.5Mb/s is equal quality to Sony/Main Concept AVC at 16Mb/s. TSmuxeR is available for download from Digital Digest tsMuxeR 1.10.6 | Software - Digital Digest (http://www.digital-digest.com/software/tsMuxeR.html)

TSmuxeR alone is a highly useful utility for muxing/demuxing streams, and simple authoring of a Blu-ray playable disk with chapter stops, just not menus. And it works with AC3 5.1 audio and 1080/60p.

multiAVCHD just completes the project by allowing you to have menus.

Used in conjunction with Phil Lee's GUI with AVI Synth scripts and Lagarith lossless codec, or the free Avid DNxHD plugin for Vegas and x264,or multiAVCHD and TSmuxeR, the tools remain highly relevant and available for free.

If you shoot native AVCHD, using a workflow that includes x264, TSmuxeR and a lossless or nearly lossless intermediate codec like Lagarith or DNxHD, is going to be the only way to maintain the native quality end to end.

TSMuxeR remains available for download from Digital Digest here. V.1.10.6 is the latest. Development has ceased but this version is bug free and completed.

Doom9 is another valuable souce through the HD authoring forums. DeanK is the author of multiAVCHD and if you're lucky he may answer your questions to him.

I've been burning Blu-ray playable, AVCHD and even HD-DVD disks with menus and chapters onto all manner of media including USB flash drives, red laser DVD and dual layer, and BD-R/RE for years.

These are the pc tools I recommend at a minimum:

Vegas Pro 11.0 64 bit -the only to pay for, the others all free.
Quicktime V.7
Avid DNxHD plugin
x264
TSmuxeR
Imgburn V.1.10.6 is the latest. Development has ceased but this version is bug free and completed. tsMuxeR 1.10.6 | Software - Digital Digest (http://www.digital-digest.com/software/tsMuxeR.html)


Doom9 is another valuable souce through the HD authoring forums. DeanK is the author of multiAVCHD and if you're lucky he may answer your questions to him.

I've been burning Blu-ray playable, AVCHD and even HD-DVD disks with menus and chapters onto all manner of media including USB flas drives, red laser DVD and dual layer, and BD-R/RE for years.

These are the pc tools I recommend at a minimum:

Vegas Pro 11.0 64 bit -the only to pay for, the others all free.
Quicktime V.7
Avid DNxHD plugin
x264
TSmuxeR
Imgburn

Norris Combs
August 9th, 2012, 04:28 PM
Tom,

Thanks for your detailed response. I'm still a little unclear on the exact steps to follow, please help a newbie. So I used Phil's tutorial to obtain an .avi file. DVD Architect would not touch this file, saying the bitrate is too high. Since you've been burning bluray quality videos to all kinds of media, obviously I don't have to burn my project to a bluray disc, I can burn it to a DVD, while keeping the high bluray quality of that .avi file.

What should be my next step? Assuming I don't need a menu, I can use TSmuxeR to burn my video to a DVD, and it will have BDMV folder structure and thus playable on a standalone bluray player? Do I even need to Avid DNxHD plug in?

Thank you!

Eric Olson
August 10th, 2012, 01:30 AM
I can use TSmuxeR to burn my video to a DVD

I have two blu-ray players: The Panasonic only plays AVCHD catalogues from DVD, the Magnavox only plays blu-ray catalogues from DVD. These two catalogues are identical except for a flag in the movieobject.bdmv file. This has greatly diminished my enthusiasm for burning HD material on DVDs. However, here is an outline of what to do:

1. Start with some sort of HD video file.
2. Encode the audio as an elementary AC3 audio stream using FFmpeg or Aften.
3. Encode the video as an elementary H264 video stream using x264.
4. Multiplex the video and audio to a blu-ray or AVCHD catalogue using tsMuxeR.
5. Burn the resulting catalogue on a DVD using ImgBurn.

The result will be a DVD with HD content that plays in some blu-ray players. There are online guides which explain the details better than I can here. In addition to the technical discussions on Doom9 you may prefer to start with the howto guides on VideoHelp.

Guide, How To, Tutorial and Article list - VideoHelp.com (http://www.videohelp.com/guides?searchtext=&tools=&madeby=&formatconversionselect=&howtoselect=3%3B68&orderby=Date&listall=1&hits=25&archive=0&search=Search+or+List+Guides)

Tom Roper
August 10th, 2012, 09:36 AM
Tom,

Thanks for your detailed response. I'm still a little unclear on the exact steps to follow, please help a newbie. So I used Phil's tutorial to obtain an .avi file. DVD Architect would not touch this file, saying the bitrate is too high. Since you've been burning bluray quality videos to all kinds of media, obviously I don't have to burn my project to a bluray disc, I can burn it to a DVD, while keeping the high bluray quality of that .avi file.

What should be my next step? Assuming I don't need a menu, I can use TSmuxeR to burn my video to a DVD, and it will have BDMV folder structure and thus playable on a standalone bluray player? Do I even need to Avid DNxHD plug in?

Thank you!

You have to output an h.264 file from your AVI, and use it as the source file input to TSmuxeR.
Correct you can burn an AVCHD disk to a DVD, but as Eric says you can't guarantee compatibility, will play on some but not all. Burning to Blu-ray media is more compatible generally but even a few Blu-ray players won't read Blu-ray writable media.

Eric's guide above is very good.

Phil Lee
August 10th, 2012, 10:39 AM
Hi

You have to output an h.264 file from your AVI, and use it as the source file input to TSmuxeR.
Correct you can burn an AVCHD disk to a DVD, but as Eric says you can't guarantee compatibility, will play on some but not all. Burning to Blu-ray media is more compatible generally but even a few Blu-ray players won't read Blu-ray writable media.

Eric's guide above is very good.

Just to point out that all Blu-ray players should play BD-R and BD-RW single and dual layer. Unlike DVD and CD where recordable media appeared much later and so was designed to look like a standard CD/DVD to fool the player, often unsuccessfully, the Blu-ray specification always included rewritable and write once media in the specification.

If a player doesn't play BD-R or BD-RW, it will either be an authoring issue, for example using the wrong file format or not create the file structure correctly, or the media, player or writer is faulty.

Regards

Phil

Tom Roper
August 10th, 2012, 11:49 AM
Hi



Just to point out that all Blu-ray players should play BD-R and BD-RW single and dual layer. Unlike DVD and CD where recordable media appeared much later and so was designed to look like a standard CD/DVD to fool the player, often unsuccessfully, the Blu-ray specification always included rewritable and write once media in the specification.

If a player doesn't play BD-R or BD-RW, it will either be an authoring issue, for example using the wrong file format or not create the file structure correctly, or the media, player or writer is faulty.

Regards

Phil

Agreed, I've never found one that didn't but there were early reports some would not, but we can only speculate as to the reasons.