H264/AVC Level Editor

H264LevelEditor is a free and small tool to edit an H264/AVC encoded video stream and change IDC profile level (see here for detailed info about IDC levels).
Works both on MKV containers and raw H264 streams (*.h264, *.264, *.ts or any other file containing H264 encoded video).
It's a portable software, no need to install it, and comes in two flavours:

  • Graphical (GUI):
    Use it if you need to edit a single or few files.
  • Command line (CLI):
    It has the same features of the graphical version and can also work on multiple files.
    You could also include it into your custom conversion scripts.

Quick intro

Video stream/file is edited in-place, which means:

  • fast editing
  • no need to reencode the file (save time)
  • no need to demux, edit and remux streams (save time and HDD space)

To make a long story short, some mediaplayers (like my Samsung C6000 LED TV and Sony PS3) search the video file being played for an header info named AVC profile level; if this level is greater than the requested (supported) one they simply refuse to play it, even if they could.
BluRay specifications requires level 4.1, which is supported by all actual HD mediaplayers. Many of the video files you'll find on internet were encoded with an unnecessary high level, like 5.1.

The right way to change AVC level is to reencode the file; this is really time consuming, even if you have a recent CPU.
A quick way is to change some bytes inside the file and make it appear as being encoded with a different level; if you're lucky, changing that 5.1 to 4.1 will make the file playable on your mediaplayer.

Just to be clear: H264LevelEditor does not change video stream compression.
It only changes a value in file header, where it "declares" its level to the world.
Many of the 5.1 encoded files out there are not really 5.1, but over-leveled 4.0 or 4.1.
If the file itself is encoded using 5.1-only features, and your player is not able to decode it, well... you must reencode it, no way.

Usage help (graphical version)

Using H264LevelEditor is easy as 1-2-3:

  1. select the video file to edit by pressing then tree-dots button, or drag&drop the file directly from Windows Explorer
  2. H264LevelEditor will show actual AVC level into the "h264 level" box, choose the new level you want to set
  3. press "Change level" button
  4. click on "Donate" button (well, this is obviously optional ;) )

User BlackMIIX published a good video tutorial here, take a look.

Usage help (command line version)

Command line version can be used to edit a single file or a group of files in a shot.
Can also be called by .bat or .vbs custom scripts.

This will change level of file C:\MyFiles\test.avi to 4.1:

> H264LevelEditorCli.exe --action change --input "C:\MyFiles\test.avi" --new-level 4.1

This will change level of all file*.avi files into folder C:\MyFiles (file001.avi, file002.avi, fileabc.avi, ...) to 4.1:

> H264LevelEditorCli.exe --action change --input "C:\MyFiles\file*.avi" --new-level 4.1

See the included file H264LevelEditorCli.txt for more options, samples and exit codes.

Version history 

v.1.5.3 - 2017-04-28

  • FIX: CLI parameter "--new-level" is not required if action is "restore".

v.1.5.2 - 2014-07-17

  • NEW: Added *.avc to the list of supported file extensions.

v.1.5.1 - 2014-04-22

  • NEW: Initial support for Mono Framework. The application should now run on Linux and Mac OSX through the Mono framework.

v.1.5.0 - 2014-01-29

  • NEW: Added an option to preserve last modified date of the file being patched. The option is available in both GUI and CLI versions.
  • FIX: Runtime error when closing the GUI while search is running.

v.1.4.0 - 2013-08-29

  • NEW: Command line version of H264LevelEditor is now available (H264LevelEditorCli.exe).
    It has the same patching engine of the GUI version and can also work on multiple files.

v.1.3.0 - 2013-08-16

  • NEW: Search task now runs in a separate thread.
    This will keep the UI alive during long searches.
  • FIX: Readonly files caused a runtime error when pressing the "change level" button.
    This state is now detected and user is asked to clear the flag before level change starts (thanks to Biomech for the suggestion).

v.1.2.0 - 2012-01-24

  • NEW: Search limit can now be extended up to first 100MB of the file (default is 1MB). This adds better support for MP4 files.
  • NEW: initial (and really experimental) support for H264 encoded AVI files. Please remember that AVI is not a good container for H264/AVC stream.
  • NEW: added automatic software update checking feature, can be set into Options dialog
  • FIX: fixed search algorithm to avoid @n.k profiles detection
    please see comments here for further details:
    http://coolsoft.altervista.org/comment/363#comment-363

v.1.1.0 - 2011-08-05

  • NEW: backup feature, allows to undo any changes to input file
  • NEW: improved search algorithm, now changes the muxing tag too
  • NEW: fix to recognize mislabeled profiles, such the ones produced with very old encoders
 

Download

H264LevelEditor it's a portable software (single EXE), no need to install it.

WARNING: .NET Framework 2.0 or newer is required: 2.0 (x86) - 2.0 (x64) - 4.0 (client profile)
(Windows Vista comes with .NET Framework 3.0 preinstalled, Windows 7 comes with .NET Framework 3.5 preinstalled.)

H264LevelEditor_1.5.3.zip
Description Latest version, includes both GUI and CLI
Release date 2017-Apr-28 Size 256,566 bytes
MD5 3ae92b7b79df9a3acbff8bdcb699bb5b
SHA1 ac5af720ee64b0babf1ec44af4272dbf5d26c8e4
SHA256 a087600d0265da5481c3e480542e8f05eb06b1dfcf284921cdd7a79424ae4797
H264LevelEditor_1.5.2.zip
Description Previous version
Release date 2014-Jul-17 Size 264,834 bytes
MD5 d9998f523f0ee21de338da472f8610a1
SHA1 1d4b0fa4cfa48195b61a8d0ce248b1ef85c1fe02
SHA256 32fbf98a6f7811c3a42a9aa25237f9fd272acc04c484089ec6e39b3f800d267f

Comments

Pages

Great tool! Super fast and lightweight. 

When can a batch processing mode be expected?

Well, I already have this feature on my todo list.
But I work on my projects on spare time, and it reduces day by day, so it's difficult to give them the right priority.

PS: H264LevelEditor is the 2nd of my most downloaded tools (Drupal-SQLite is the top one), but it never had any donation, not even a buck!
Would someone fund this feature ;) ?

you can run this program on Mac OS X using CrossOver. I ve tried it. perfect. thanx

Thank you very much for your feedback.
I'm sure it'll be usefull for other users.

I have created several test files with AVS Editor, AVS Remaker (cut, join tool), video redo as you can see. All files are playable (!) on PC, but only 3 (with 2, or 02 and 31 name extension) work off USB stick/port on Sony BDPS-770 player. I discovered with help of Mediainfo that playable ones (on Sony) are Profile 4.1 or lower (4.1, 4.0 and 3.1). Found your tool to correct AVC Profiles and got these errors.

Mediainfo has no trouble reading profile. See this:

Complete name                    : Preview_1cut-cut videoredo (02).mp4
Format                           : MPEG-4
Format profile                   : Base Media ([email protected])
Codec ID                         : isom

file works on PC not on Sony... but after transcoding it with Handbrake:

Preview_1cut-cut videoredo (02handbrake).m4v
Format                           : MPEG-4
Format profile                   : Base Media / Version 2 ([email protected] (CABAC 4Ref Frms)
Codec ID                         : mp42 

it works on Sony... yet your tool will not report AVC profile. The only profile it read is from unplayable file (on PC and Sony!!!) and this one I could change. After correction file is still unplayable. What's the problem? Why your Level editor can not read the profile yet mediainfo has no trouble with it?

Here are the error msgs:

Selected file: G:\Preview_1.mp4
ERROR: Can't find AVC profile
Selected file: G:\Preview_1cut-cut videoredo (02).mp4
ERROR: Can't find AVC profile
Selected file: G:\Preview_1cut-cut videoredo (02handbrake).m4v
ERROR: Can't find AVC profile
Selected file: G:\Preview_2.mp4
ERROR: Can't find AVC profile
Selected file: G:\Preview_3 (2).mp4
AVC level pattern found at file offset 658: @4.1
AVC level pattern found at file offset 666: @4.1
AVC level pattern found at file offset 2590: @n.k
WARNING: Warning: different levels found, proceed at your own risk!
Selected file: G:\Preview_3.mp4
ERROR: Can't find AVC profile
Selected file: G:\Preview_3avs.avi
ERROR: Can't find AVC profile
Selected file: G:\Preview_3iso.mp4
ERROR: Can't find AVC profile
Selected file: G:\Preview_31.mp4
ERROR: Can't find AVC profile
Selected file: G:\Preview_1 (2).mp4
AVC level pattern found at file offset 658: @4.1
AVC level pattern found at file offset 666: @4.1
AVC level pattern found at file offset 14722: @n.k
WARNING: Warning: different levels found, proceed at your own risk!
Selected file: G:\Preview_31.mp4
ERROR: Can't find AVC profile
Selected file: G:\New TESTS\AVC Intel and mp3.avi
ERROR: Can't find AVC profile
Selected file: G:\New TESTS\Coding test 1 AVC MP3.avi
AVC level pattern found at file offset 13447: @5.1
Backup file created: G:\New TESTS\Coding test 1 AVC MP3.avi.hle-bak
AVC level pattern found at file offset 13447: @4.0
Level changed successfully to [email protected]
Selected file: G:\New TESTS\Preview_1cut-cut_remaker_avi_mp3.avi.mp4
ERROR: Can't find AVC profile
Selected file: G:\New TESTS\Preview_1cut-cut-remaker avi pcm.avi
ERROR: Can't find AVC profile
Selected file: G:\New TESTS\Preview_cut_cut1 mp4 divx.avi
ERROR: Can't find AVC profile
Selected file: G:\New TESTS\same test 720p avs edit.avi
ERROR: Can't find AVC profile
Selected file: G:\New TESTS\Video0013i14remaker avi mp3.avi
ERROR: Can't find AVC profile
Selected file: G:\Preview_3.mkv
ERROR: Can't find AVC profile

Well, my software doesn't do a complete stream analysis on input file as MediaInfo does.
It only tries to find profile tags by searching a corresponding byte pattern; that's why patching process could be done in-place and really quick.
The counterpart of this method is that it could detect "false positives" or found nothing at all.

That said, "AVC level pattern found at file offset 2590: @n.k" is a strange log message, just because the list of supported tag patterns doesn't include it, so there should be something wrong.

I see you're an experienced user, could you please extract a 4-5 seconds sample from 2 files (one with undetected profile and one with @n.k one), check if they have the same issue and send them to me?
I'll send you an email with my personal mail address...

Thanks for your detailed feedback.

 

Hello There,

 

Am also facing the "n.k" profile detection issue.

Claimingly the tool detects 2 profiles. 5.1 and n.k (in many of my files).

Then whatever level I change the profile to, it won't be playable back in VLC or anything else either, the video goes blank.

EVEN if I change it to 3.1 and then back to 5.1 with the tool.

So messing up something in it.

Any idea would be greatly appreciated :)

Thank you

 

I faced the same problem. The issue resolved firstly remuxing the MP4 file into a MKV file using mkvmerge. 

http://www.bunkus.org/videotools/mkvtoolnix/win32/mkvtoolnix-unicode-3.0...

Then change the profile using the program. The problem seems to be caused by:

a) There is NO h264 encoded stream in the file (containing divx, xvid, or any other codec)

b) The file is encoded to MP4. The tool is not very friendly with the iso MP4 file container.

c) an AVI file container is used (.AVI) containing the h264 stream. I am an owner of a Sony Blu-Ray Player and using this trick the files become playable.

Revert your files ASAP. then use the trick. As the developer said, send him the file. I was going to contact him to discuss this issue anyway.

@b wings: thanks for your replies.
@Joe7 and @b wings: As I already said, please send me a sample file (please cut it to be less than 10MB) and I'll have a look.

I'm thinking to add the possibility to discard some of the found levels and change only some, i.e.:
- found 5.1 profile at offset 1323
- found 5.1 profile at offset 3455
- found n.k profile at offset 17823

Now the user could choose to only patch the first two and discard the latter.
What dou you think about it?

But before I need to know why it detects n.k profile, which is not an expected one, so I'm waiting for a sample file.

I just uploaded a 1.2.0_beta1 version here:
H264LevelEditor_1.2.0_beta1.zip

  • fixed search algorithm causing @n.k profile issues
  • larger search buffer
  • initial support for AVI files

Regarding AVI files there are some things to highlight.
First: AVI is the worst container for H264/AVC encoded streams. Despite this, it could be the only way for some players to read H264 files.
Avi file is basically composed by RIFF chunks, a sort of data block (see Wikipedia for details).
That said, each video block has its own profile header. Into a 100MB file the profile information is repeated hundreds of times, once for each data chunk.

H264LevelEditor limits its search to the first 3 patterns found (avoiding false positives into audio/video data stream); this works well for MKV and MP4 containers.
Since I don't have an AVI/H264 capable player available, please let me know if I should increase that limit.

New version 1.2.0 released, see version history for details.

Thanx Guys you've saved me a lot of time!!!

 

This is really wonderful! I do hope you add a batch feature though.

Thank you very much for this wonderful application

Just a quick note to say thankyou, this software is brilliant, I had 6 MKV's that would not play on my sony bdpS380 but played perfectly on my pc. After much messing around I came across this little program and it works great, so simple and now all my MKV's play perfectly. Again many thanks for taking the time to produce such a great piece of software.

@anonymous, @Happy Chappy,
thanks for your feedback and... help me spread the word (FB, Google+, Technical blogs, forums, ...)

Thank for your great tool. Hope to see next update.

hi tanQ for this tool but A few days this tool cant change level 5.1 to 4.9 and other levels. and saved level 5.1 in the orginale file why? all of my file is mkv whit Level 5.1

It's really difficult for me to understand your question, anyway I'll try to.

4.9 is not an existing H264 level, so I suppose it's a typo in your comment.
Do you mean you aren't able to change level now but you were in the past?

If yes, please check:

  1. MKV files are not write protected or read-only (even if the tool should give an error...)
  2. you can still change level of a file you successfully changed in the past

After that, if you still have issues, please cut and paste me the log messages outputted by the tool using this site contact form.
 

hi dear friend
sorry for last questions , because my english writing is very bad :D

but, when change level dont show error and type successfull but in Orginal file Dont change level

This log for me

Selected file: F:\Film90\Into the Abyss (2011) LiMiTED BluRay 720p.mkv
AVC level pattern found at file offset 4358: [email protected]
AVC level pattern found at file offset 4366: [email protected]
Backup file created: F:\Film90\Into the Abyss (2011) LiMiTED BluRay 720p.mkv.hle-bak
AVC level pattern found at file offset 4358: [email protected]
AVC level pattern found at file offset 4366: [email protected]
Level changed successfully to [email protected]

and this .hle-back

0x1104|0x640033
0x110C|0x640033

and original file write with

Writing application : mkvmerge v5.2.1 ('A Far Off Place') built on Jan 2 2012 23:21:10
Writing library : libebml v1.2.3 + libmatroska v1.3.0

Ok, but Dont Change level in orginal File :-s
in few day ago don't have this problem.

How did you noticed that the code was not changed? The file itself was changed, because of these lines:

AVC level pattern found at file offset 4358: [email protected]
AVC level pattern found at file offset 4366: [email protected]
Level changed successfully to [email protected]

H264LevelEditor, after the change, rescan the file, and those are the log lines confirming that it found the new level set.

So when you say "the level is not written" I suppose you mean "when I play the file on my player it does not work" or "when I scan the file with another tool it still reports the original level".

In this case, press "Options" and increase search limit by 5MB at a time up to 100MB; remember that with a largest limit H264LevelEditor could find more false positives, so the less the better.
You could also increase pattern count limit, but the default 2 is always a good choice.

Actually it finds only 2 occurrences in your file, see if increasing the limits makes it found some other pattern.

I think the user is trying to play the file on a tv, blu-ray player or anything that plays, let’s say, "standard" AVC files. In order to play the files, change the file’s profile UP TO LEVEL 4.1, because LEVEL 4.2 is NOT supported on such players. If the file is still unplayable, remux it using any version UP TO v3xx of mkvmerge, you mention  your file is muxed by "Writing application : mkvmerge v5.2.1 ('A Far Off Place') built on Jan 2 2012 23:21:10" That version of mkvmerge makes the file unplayable due to the header stripping problem and not because of the level of the file. Please reply if you’ve resolved the issue

Thanks for your detailed help.

Hi!

First of all want to say congrats! you made a beautiful peace of software.

I was able to change the levels of the profile AVC/H264 perfectly-. I'm just having trouble with Itunes and Ipad2. The thing is that itunes don't allow copy of video files with High profile it only allows Main profiles. Do you know a way to change the profile (no level) from High to Main Without econde again?

 

I have a movie like this:

1050 kbps, 1280*688 at 23.976 fps, AVC ([email protected]) (cabac / 6 Ref Frames)

The level editor can change the "level" but no the "high" stream.

Excelent soft Mate!!!

Changing profile is a completely different thing.
I mean changing the profile could be done the same way we do for level (it's only a byte), but after changing it most of the time the file becomes unplayable.
Maybe because decoders find unexpected data blocks or miss expected ones.
First versions of H264LevelEditor had this feature; after a lot of issues I removed it.

You could try with other remuxing tools...

Thanks for the reply!

Solved! The problem wasn't the profile on the video it was the audio (ac3 instead acc).

With the release of the "new Ipad" apple now allow high and main profiles with 3.1, 4.0, 4.1, 5.5 levels. Because the new Retina display and movies 1080p.

You should look here: https://discussions.apple.com/thread/2391597?start=15&tstart=0

Thanks again! 

 

 

In that case I recommend you to reencode the audio stream only by using xmedia recode. Just copy the video stream and then recode the audio to aac. 

Hello, I can tell you that your software is great and really worked for me. I have an Android phone Samsung Galaxy Plus ( Adreno 205 GPU ) that can not play 720p mkv files with h264 level equal and higher than 4 with hardware decoding (with software no problem but very slow), so I changed some files to level 3 with your software and now hardware decoding works !! But after changing the level in some mkv files your software tells me that the level has been changed from 4 to 3 although when I check with mediainfo software in Windows it tells me that the level still at 4. When I now try to play this "new" file, Android crashes... some idea why it can not fully change the mkv file to level 3 ?

By the way, if you could integrate a batch function (being able to select and patch more than 1 file at the time) would be really helpful.

Thanks !!

Martin

Thanks for your feedback.

> when I check with mediainfo software in Windows it tells me that the level still at 4
Try to increase the pattern count limit from 2 (the default value) to 3 or more.
Beware that higher values could lead to more possible "false positives".

Pages

warning

Warning, JavaScript is disabled!

JavaScript is not available, maybe because you disabled it globally into your browser settings or you are using an addon like NoScript.

We do not have any dangerous JavaScript running here.
Please enable JavaScript; if you're using NoScript this image will help you adding CoolSoft to your whitelist.

Thanks for your comprehension and enjoy CoolSoft.