Log in

View Full Version : h264enc for Linux


Pages : 1 2 3 4 5 6 [7] 8 9 10 11 12 13 14 15

microchip8
9th June 2009, 22:57
ChangeLog for version 8.8.3
* Added support for adding jpeg/png cover art files to MKV/MP4
* Added audio language meta-info for MP4 and TS files
* Improved audio language meta-info for MKV files. This also adds metadata info for the second audio track
* Fixed a small bug: the --aac-is-sbr mkvmerge parameter should be set to 0:1 for the second
audio track when using aacplusenc as encoder

microchip8
12th June 2009, 19:41
ChangeLog for version 8.8.4
* Replaced the --noaudio mkvmerge option with -A due to recent options changes in mkvmerge version 2.9.5.
-A also works for older versions so nothing breaks here
* Removed the check_outfile_func() function as its code has been added to the set_output_filename_func() function,
which also has been improved
* Added support for FLAC audio in MKV
* Removed some code duplication in the MKV metadata tagging code

microchip8
15th June 2009, 10:26
ChangeLog for version 8.8.5
* Update to the video_subtitles_func() function: for DVD encodings, added support for importing up to
three external subtitles into MKV/MP4/OGM. Also added support for hardcoding an external subtitle into the movie
* Updated the MKV/MP4/OGM muxing code to support imports of external subtitles
* Increased Psy RD from 0.5 to 0.6 for some presets
* If dumping of the second and/or third DVD subtitle fails and user has selected to import the subs into MKV/MP4,
force an exit since container conversion will fail as the muxing programs will complain about the missing subs. If no
container conversion is chosen or user has chosen not to import the subs and dumping of subs fails, just continue
since there's nothing critical in this case
* Use mplayer -really-quiet option instead of redirection to /dev/null when dumping audio to a named pipe for
neroAAC/Vorbis/AAC+ encoding
* Some small updates to the man page
* Updated the AUTHORS file

microchip8
17th June 2009, 20:50
ChangeLog for version 8.8.6
* Added support for per track audio bitrate for DVD encodings
* Added support for per track audio normalization and volume adjustments for DVD encodings. Updated functions
audio_volnorm_func() and audio_volume_func()
* Added support for per track audio resampling for DVD encodings. Updated functions audio_resample_filters_func()
and audio_resample_func()
* Updated the video bitrate calculation code to support the above audio changes
* Bugfix for the qt/bd/avchd presets: audio filters were not called for these presets
* Added support for per track AAC profile settings (LC/HE/HEv2) when using the neroAacEnc audio encoder
* Small modifications to the MKV/MP4 tagging and muxing code to support the per track neroAacEnc AAC profiles.
This also includes optimizations to the way the tagging code handles different AAC profiles. If LC profile is chosen,
audio will be tagged as LC-AAC (along with channels info). For HE and HEv2, audio will be tagged as HE-AACv1 and
HE-AACv2 (along with channels info) respectively
* Moved the MKV tagging code inside the MKV muxing code
* Converted the EXTSUB1, EXTSUB2 and EXTSUB3 variables, used to import external DVD subs, to arrays so we
can easily check different files for their file extensions
* Only allow SRT subs as import into OGM. If another subs format is provided, the subs will be skipped. For MP4, do not
allow ASS/SSA subs since it's not supported yet by MP4Box. For MKV, do not allow SUP and TTXT subs

microchip8
18th June 2009, 11:04
Packages for Fedora 11 are now available from my repo - http://download.opensuse.org/repositories/home:/microchip8/

:)

microchip8
19th June 2009, 11:08
ChangeLog for version 8.8.7
* Simplifications to the MKV tagging code which reduces some code duplication
* Bugfix: FAAC acodec2 variable has wrong mpeg value. Must be mpeg=4 instead of mpeg4. This results in failure in
encoding of the second audio track when one selects FAAC as encoder
* Bugfix: FLAC audio was ignored for the second track due to missing value in the selection of the case statement
* Added support for tagging of MKV files when doing a directory batch encoding
* Replaced the IMPSUB1, IMPSUB2 and IMPSUB3 variables, used to import subs when input type is file/directory/vcd,
by array variables EXTSUB[1], EXTSUB[2] and EXTSUB[3]. This allows for less code duplication as these array variables
are shared by all input types (including DVD) and thus we only need to do a small loop and add their values if not empty
to the MKVSUBS, MP4SUBS and OGMSUBS variables
* Use as temp directory $HOME/.h264enc/job<PID>
* Added new function audio_stream_copy_func() which will print a warning that audio stream copy in directory batch encoding
mode is not recommended unless the user is certain that the files have a supported audio codec by the MKV/MP4/OGM/TS containers
* Group audio filters under a submenu similar to how the video filters are grouped
* Some small cleanups

cooool
21st June 2009, 03:40
Hi

I was trying to convert dvd's into mkv files.
I used h264enc 8.8.5. I used the COPY option in the audio settings. Both the dvd's have DTS audio.

The sample file was alright. The avi also has no problems. But in the mkv file, the audio is out of sync. I still have the avi file with me. Any idea how i can fix this?

I actually encoded 4 dvd's. Two with DTS audio and two with AC3 audio. AC3 does not have any problems. But DTS goes out of sync in mkv files.

Thanks.

microchip8
21st June 2009, 08:03
Hi

I was trying to convert dvd's into mkv files.
I used h264enc 8.8.5. I used the COPY option in the audio settings. Both the dvd's have DTS audio.

The sample file was alright. The avi also has no problems. But in the mkv file, the audio is out of sync. I still have the avi file with me. Any idea how i can fix this?

I actually encoded 4 dvd's. Two with DTS audio and two with AC3 audio. AC3 does not have any problems. But DTS goes out of sync in mkv files.

Thanks.

DTS copy for both tracks is currently a bit problematic and I can't really fix it unless I rewrite a lot of the audio code (currently underway). You may want to manually dump the tracks and then mux into mkv. I also have noticed that sometimes mencoder can behave a bit weird when copying DTS audio. You can recompile mplayer with libdca support (if you don't have it already - install devel packages of libdca too) and this may fix some stuff

.... Honestly, I don't know why you bother with DTS audio but it's your choice ;)

microchip8
22nd June 2009, 11:46
ChangeLog for version 8.9.0
* Small improvement to the MKV/MP4 tagging code: support audio tagging of single file encodes with audio stream copy
* Use array variables ${SUBFILE[2]} and ${SUBFILE[3]} instead of ${OUTPUT%.*}_sub2 and ${OUTPUT%.*}_sub3 when dumping
the second/third DVD subtitles
* Simplified the MKV cover art importing code
* Small improvements to video bitrate calculation with audio stream copy
* Use only one named pipe for all tracks when encoding to neroAAC/AAC+/Vorbis/FLAC
* Major audio code restructuring and partial rewrite. Converted virtually all audio code variables to array variables. This allows for easy
extensibility and much less code duplication. It's very easy now to add as much audio tracks as one may want to the code with very
little changes/updates needed to the containers code. Also the current changes may allow very easily to support different audio
codecs per track in the future
* Added support for a third DVD audio track
* Updated the video bitrate calculation for target size to support the above audio changes
* Converted most of the variables in the video_subtitles_func() function to arrays. This moderately reduces some code duplication
* Updated the container muxing/tagging code to support the above audio changes
* Use external flac encoder to encode to FLAC audio as doing it through mencoder is terribly broken. This updates the config file
to version 8 and adds the 'flac' encoder as dependency
* Set the default resampling filter to lavcresample as the other one gives problems when encoding to FLAC audio and resampling

shortkud
24th June 2009, 02:08
Thanks for this script, I am trying to run it on gentoo but having issues with it detecting bc being installed. I ran 'emerge bc' multiple times.

This is what happens:

h264enc -2p -p cp hq-slow.cfg
-> Checking for utility 'bc'... FAILED!

I'm sure you will ask for this so here you go ;)
# which bc
/usr/bin/bc

# /usr/bin/bc -v
bc 1.06.95
Copyright 1991-1994, 1997, 1998, 2000, 2004, 2006 Free Software Foundation, Inc.

microchip8
24th June 2009, 10:14
Thanks for this script, I am trying to run it on gentoo but having issues with it detecting bc being installed. I ran 'emerge bc' multiple times.

This is what happens:

h264enc -2p -p cp hq-slow.cfg
-> Checking for utility 'bc'... FAILED!

I'm sure you will ask for this so here you go ;)
# which bc
/usr/bin/bc

# /usr/bin/bc -v
bc 1.06.95
Copyright 1991-1994, 1997, 1998, 2000, 2004, 2006 Free Software Foundation, Inc.

Have a look at the -r option which resets the config file... if you have installed any required programs *after* the script has generated its config file, the config file won't have them so you have to reset it.

microchip8
24th June 2009, 18:54
ChangeLog for version 8.9.1
* Removed audio filters for the 1st pass in 2-pass encoding and for the 1st & 2nd pass of a 3-pass encoding.
They are useless here and it's something I've overlooked for a long time. Thanks to Mat Kanner for noticing and reporting
* Some small changes to the way we pass FPS to MP4Box
* Added support for MP4 hinting for RTP/RTSP sessions
* Simplifications to the external subs importing code. Also fixed a bug in the MP4 subs importing code; missing -add
option in the MP4SUBS variable will make MP4Box fail
* Merged the MKV tagging code with the muxing one
* Added support for detection of WMA audio for stream copy
* Added support for per track audio codecs for DVD encodings. The user can now select if he wishes for each track a
different audio codec. Mixing audio stream copy with compression codecs is also possible
* Updated all relevant audio functions to support per track audio codecs
* Updated the bitrate calculation code to support per track audio codecs
* Updated the containers muxing code to support the above audio changes

microchip8
26th June 2009, 11:11
ChangeLog for version 8.9.2
* Set default audio codec for the Blu-ray/AVCHD presets to AC3
* Bugfix to the OGM muxing code. Second/third track were ignored when one selects AC3 audio
* Added keyint, keyint_min, nr and interlaced variables to the custom preset skeleton file 'preset.cfg'
* Moved the AACTYPE variable to the neroaac_audio_func() function and updated the specific parts
that use it in the MKV/MP4 muxing code
* Do not automatically detect audio sample rate in directory batch encoding mode. Only do it for single
file/dvd/vcd encodings as in batch mode, detection will only print the sample rate of the first file but not
the other files in the directory so this can mislead the user in thinking that all files in the directory have
the sample rate reported by the script. It is possible to implement sample rate detection for all files but
since we don't know how many files are in the directory, I do not want the user to see a full screen with
sample rate info of each file if he deals with a directory with a few hundreds or more files in it
* Disallow autocropping, if enabled in the config file, for directory batch encodings
* Small reordering to the MP4 muxing code
* Small update to the install script
* Updated the man page

microchip8
1st July 2009, 13:15
ChangeLog for version 8.9.3
* Fallback to undefined audio language in the AUDLANG[$i] variables if we detect unknown language from MPlayer's output
* Added support for bitrate-based ABR Vorbis encoding in addition to quality-based VBR. ABR mode in Vorbis resembles
quality-based VBR except the encoder averages a given nominal bitrate
* Updated the Vorbis part of the video bitrate calculation code
* Added new function ratio_and_pixels_func() which calculates and displays the Storage Aspect Ratio (SAR), Pixel Aspect
Ratio (PAR) and total pixels from resolution
* Bugfix for track 1 in the internal audio encoding code. If using aacplusenc to encode audio, the case statement had a wrong
selection value (aac++ instead of aac+) resulting in displaying a failed message and forcing an exit even though the encoding
may have succeeded
* Simplifications to the internal audio encoding code which reduce code duplication
* Small fixes to the video bitrate calculation code
* Small tuning to the Blu-ray/AVCHD presets
* Small cleanups

microchip8
8th July 2009, 12:24
ChangeLog for version 8.9.4
* Added detection for E-AC3 audio for stream copy and updated the MKV/TS muxing code to support it
* Added new option -spr which calculates the Storage and Pixel Aspect Ratios (SAR/PAR) for various resolutions
* Display the amount of chapters each DVD title has when scanning for titles
* Display total pixels, SAR and PAR when scanning a file/vcd with the -scan option
* Added --no-chapters mkvmerge option for audio files encoded by neroAacEnc so that chapters won't be
copied over to the MKVs from these files
* Small update to the install script
* Updated the man page. Fix some small cosmetic issues, patch by Alessio Treglia

Rasi
19th July 2009, 20:19
Hi.. just converted a dvd with the new version.... it seems the luminace filter does something terribly wrong...
top image is the original dvd, bottom the result

http://omploader.org/vMjAyag

Automatic Brightness/Contrast Control
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
0 -> Luminance-only control
1 -> Chrominance-only control
2 -> Luminance & Chrominance control
3 -> Skip automatic brightness/contrast

Select the Automatic brightness/contrast control [default is 2]:

this is what i selected

microchip8
19th July 2009, 20:23
It does nothing wrong, it auto-adjusts luminance & chrominance levels so you'll get darker parts to appear lighter ;)
This is what you asked for :p

elektronaut
19th July 2009, 20:47
Hi,

first I want to say thank you for this great tool!

I have to propose one advancement: In some cases, it would be better to be able to repeat a certain step, e.g. when it comes to cropping. How are you supposed to correctly guess the crop values? The automatically determined ones never seem to be correct. So I added a little loop expecting a final user input in video_crop_func(). Plain simple. Now I can retry setting the crop values until I'm satisfied.
I think there are also other steps where a retry possibility would be good. In order not to get on the nerves of experienced users, it could be a solution to run h264enc either with or without second checking the user's choices. For example by adding a start parameter or by asking the user in a first question which mode he wants.

Another thing is typing in the path for the input file/folder. Is there no way to use tab-completion? Would also be simple to use zenity for this, but then you have a dependency on Gnome.

Just my two cents.

microchip8
19th July 2009, 21:00
Hi,

first I want to say thank you for this great tool!

I have to propose one advancement: In some cases, it would be better to be able to repeat a certain step, e.g. when it comes to cropping. How are you supposed to correctly guess the crop values? The automatically determined ones never seem to be correct. So I added a little loop expecting a final user input in video_crop_func(). Plain simple. Now I can retry setting the crop values until I'm satisfied.

Not sure I understand what you mean. Do you want me to add a small loop that keeps asking the user for correct cropping value? I don't think that's such a good idea. If you have patches, send them over. I'll look at it and decide ;)

As for "guessing the crop values", if the crop filter is for some reason incorrect, you can always run in another console mplayer dvd:// -vf cropdetect, get the values and pass it to h264enc. The crop detection is certainly not perfect but it will work for 98% of the cases

I think there are also other steps where a retry possibility would be good. In order not to get on the nerves of experienced users, it could be a solution to run h264enc either with or without second checking the user's choices. For example by adding a start parameter or by asking the user in a first question which mode he wants.

Don't really get it either. Which steps and which start parameter? if you want the script to accept files in the form of "h264enc /path/to/file" and then ask for encoding modes and presets, this won't happen. Too much depends on the current way of doing things and I personally don't see a need for changing it

Another thing is typing in the path for the input file/folder. Is there no way to use tab-completion? Would also be simple to use zenity for this, but then you have a dependency on Gnome.

Of course there is and I use it all the time. Each question asked that requires user input in the form of specifying a path, supports bash completion. So for example, if you want to encode a file called "foobar.avi" which is in your home directory, when asked for input, just type

/h<TAB>/u<TAB>/fo<TAB> (where "u" here (username) is used as example for the actual user name)

Rasi
19th July 2009, 22:14
ok another question: h264enc does not find my mkvmerge binary and i have no clue why...


Would you like to convert the final encode from AVI to MKV? [y/n]: y

-> Utility 'mkvmerge' is missing!
-> Skipping AVI to MKV conversion!



1 carnager@freebox ~ % whereis mkvmerge
mkvmerge: /usr/bin/mkvmerge /usr/share/man/man1/mkvmerge.1.gz


same for ogmmerge and mp4box...

elektronaut
19th July 2009, 22:15
Not sure I understand what you mean. Do you want me to add a small loop that keeps asking the user for correct cropping value? I don't think that's such a good idea. If you have patches, send them over. I'll look at it and decide ;)

In video_crop_func() I inserted this before the line "read cropvalues":
CROPDETERMINED="n"
while [ "$CROPDETERMINED" != y ]
do
if [ -z "$cropvalues" ]; then
printf "Specify the crop values [default is $GETCROP]: "
else
printf "Specify the crop values [last try: "$cropvalues" ]: "
fi
read cropvalues
and at the end of the function I appended printf "Are you satisfied with the crop area? [y/n]: "
read CROPDETERMINED
done
As for "guessing the crop values", if the crop filter is for some reason incorrect, you can always run in another console mplayer dvd:// -vf cropdetect, get the values and pass it to h264enc. The crop detection is certainly not perfect but it will work for 98% of the cases
You are certainly right about running mplayer in another console. Didn't think about this (I'm not a media decrypting guru). But my addition doesn't hurt, does it?
Don't really get it either. Which steps and which start parameter? if you want the script to accept files in the form of "h264enc /path/to/file" and then ask for encoding modes and presets, this won't happen.
I don't have any particular step in my mind right now. I just think that it would generally be more user friendly, at least for beginners, to double check their choices, like in the code I pasted above. This could also be done for audio codec selection, bit rate, ... whatever.
The start parameter I suggested would be used for setting the variable "DOUBLECHECK" to TRUE or FALSE, so that the program would run either in "beginner" mode or normal mode. In the latter case the while-loops would be avoided.
/h<TAB>/u<TAB>/fo<TAB> (where "u" here (username) is used as example for the actual user name)
Strange. I could swear that it didn't work when I tried, but now it works. Sorry, maybe I was just a bit too tired.

microchip8
19th July 2009, 22:59
Sorry for late reply. Was watching a movie here, hehe :p

For your crop stuff, I think the CROPDETERMINED variable will fit better in the config file where a user can enable or disable this functionality. Personally, I wouldn't' need it but those who do, can enable it. Patch welcome :p

For the other things, I think it isn't such a good idea as in "beginner mode" it will increase the amount of questions asked when doublecheck is enabled and I certainly want to avoid too many questions being asked. This was my primary reason for adding variables to the config file where users can enable or disable certain audio/video filters and container muxing. For example, I've disabled here the interlace, brightness, sharpening, scanning for multiple video/audio tracks in files and volume normalization since I virtually never use these filters or options. For me (and for others I guess) it reduces the amount of questions asked (and thus saves a bit of time) and of course gets rid of stuff I never use ;)

Further, as with most interactive scripts, you need to pay attention to what you give. Remember, h264enc is just a script I write primarily for me (though share it with others too) and I can't please everybody and there are some things that either will require a lot of rewriting or are just not important for my needs. There are other more simple scripts out there like undvd and ANDREW which are semi-interactive and require little configuration but also offer less functionality than h264enc. So yes, the script is not for everyone and I've mentioned this already in the FAQ pros/cons section of its website

microchip8
19th July 2009, 23:20
ok another question: h264enc does not find my mkvmerge binary and i have no clue why...


Would you like to convert the final encode from AVI to MKV? [y/n]: y

-> Utility 'mkvmerge' is missing!
-> Skipping AVI to MKV conversion!



1 carnager@freebox ~ % whereis mkvmerge
mkvmerge: /usr/bin/mkvmerge /usr/share/man/man1/mkvmerge.1.gz


same for ogmmerge and mp4box...

Did you reset its config file with h264enc -r ?

I use "which" instead of "whereis" to find progs on a user's system. It should work on most, if not all, systems but if it doesn't (and I'll be surprised) you can manually set the path to those in the config file (or edit it directly by running h264enc -e (defaults to using the nano editor))

About your brightness "problem", if you want more control (and not autmomatic adjustment) of these levels, use the software equalizer (eq2) filter which offers a lot of params for adjusting the levels - read man page of mplayer to understand its params ;)

elektronaut
20th July 2009, 11:17
For your crop stuff, I think the CROPDETERMINED variable will fit better in the config file where a user can enable or disable this functionality. Personally, I wouldn't' need it but those who do, can enable it. Patch welcome :p
OK, I have no idea how to make a patch. I simply did a diff like this:
diff h264enc.backup h264enc
Here's the result:
2468,2519c2468,2529
< case "$source" in
< dir|DIR|Dir)
< echo
< error "-> Cropping in directory batch encoding mode is not"
< error " recommended unless you know what you're doing!"
< ;;
< esac
< echo
< green "-> Detecting crop values with 'cropdetect'..."
< $MPLAYER "$sourcetype" $device $vid $MPLAYEROPTS -identify -vo null -ao null -frames 1 -nocache 2>/dev/null > $CONFIGDIR/cropdetect
< VLENGTH=$(grep "^ID_LENGTH" $CONFIGDIR/cropdetect | cut -f '2' -d '=' | cut -f '1' -d '.')
< case "$source" in
< dvd|DVD|Dvd) CROPOPTS="-vc mpeg12 -frames 30 -sstep $(($VLENGTH/30))" ;;
< *) CROPOPTS="-frames 500 -ss $(($VLENGTH/2))" ;;
< esac
< GETCROP=$($MPLAYER "$sourcetype" $device $vid $MPLAYEROPTS -vf cropdetect -nosound -vo null $CROPOPTS -nocache 2>/dev/null | tr '\r' '\n' | grep "crop=" | tail -n 1 | awk '{print $9}' | sed 's/crop=//g; s/).//g')
< rm -f $CONFIGDIR/cropdetect
< if [ ! -z "$GETCROP" ]; then
< green "-> Found crop values: $GETCROP"
< else
< green "-> Failed to get the crop values!"
< green "-> You have to specify them yourself!"
< green "-> The format is as follows: width:height:x:y"
< GETCROP="??"
< fi
< echo
< printf "Specify the crop values [default is $GETCROP]: "
< read cropvalues
< if [ -z "$cropvalues" -a "$GETCROP" = "??" ]; then
< cropfilter=
< else
< if [ -z "$cropvalues" ]; then
< cropfilter="crop=$GETCROP,"
< crop_preview="$GETCROP"
< else
< cropfilter="crop=$cropvalues,"
< crop_preview="$cropvalues"
< fi
< printf "Preview the crop values for 15 seconds? [y/n]: "
< read precrop
< if [ "$precrop" = "y" -o "$precrop" = "Y" ]; then
< printf "Specify the start position in hour:min:sec [default is 0:02:00]: "
< read timepos
< if [ -z "$timepos" ]; then
< startpos="0:02:00"
< else
< startpos="$timepos"
< fi
< #$MPLAYER "$sourcetype" $device $vid $MPLAYEROPTS -vf rectangle=$crop_preview -nocache -nosound -ss $startpos >/dev/null 2>&1 & PID=$!; sleep 15; kill -KILL $PID;
< $MPLAYER "$sourcetype" $device $vid $MPLAYEROPTS -vf rectangle=$crop_preview -nocache -nosound -ss $startpos -endpos 15 >/dev/null 2>&1
< fi
< fi
---
> case "$source" in
> dir|DIR|Dir)
> echo
> error "-> Cropping in directory batch encoding mode is not"
> error " recommended unless you know what you're doing!"
> ;;
> esac
> echo
> green "-> Detecting crop values with 'cropdetect'..."
> $MPLAYER "$sourcetype" $device $vid $MPLAYEROPTS -identify -vo null -ao null -frames 1 -nocache 2>/dev/null > $CONFIGDIR/cropdetect
> VLENGTH=$(grep "^ID_LENGTH" $CONFIGDIR/cropdetect | cut -f '2' -d '=' | cut -f '1' -d '.')
> case "$source" in
> dvd|DVD|Dvd) CROPOPTS="-vc mpeg12 -frames 30 -sstep $(($VLENGTH/30))" ;;
> *) CROPOPTS="-frames 500 -ss $(($VLENGTH/2))" ;;
> esac
> GETCROP=$($MPLAYER "$sourcetype" $device $vid $MPLAYEROPTS -vf cropdetect -nosound -vo null $CROPOPTS -nocache 2>/dev/null | tr '\r' '\n' | grep "crop=" | tail -n 1 | awk '{print $9}' | sed 's/crop=//g; s/).//g')
> rm -f $CONFIGDIR/cropdetect
> if [ ! -z "$GETCROP" ]; then
> green "-> Found crop values: $GETCROP"
> else
> green "-> Failed to get the crop values!"
> green "-> You have to specify them yourself!"
> green "-> The format is as follows: width:height:x:y"
> GETCROP="??"
> fi
> echo
> CROPDETERMINED="n"
> while [ "$CROPDETERMINED" != y ]
> do
> if [ -z "$cropvalues" ]; then
> printf "Specify the crop values [default is $GETCROP]: "
> else
> printf "Specify the crop values [last try: "$cropvalues" ]: "
> fi
> read cropvalues
> if [ -z "$cropvalues" -a "$GETCROP" = "??" ]; then
> cropfilter=
> else
> if [ -z "$cropvalues" ]; then
> cropfilter="crop=$GETCROP,"
> crop_preview="$GETCROP"
> else
> cropfilter="crop=$cropvalues,"
> crop_preview="$cropvalues"
> fi
> printf "Preview the crop values for 15 seconds? [y/n]: "
> read precrop
> if [ "$precrop" = "y" -o "$precrop" = "Y" ]; then
> printf "Specify the start position in hour:min:sec [default is 0:02:00]: "
> read timepos
> if [ -z "$timepos" ]; then
> startpos="0:02:00"
> else
> startpos="$timepos"
> fi
> #$MPLAYER "$sourcetype" $device $vid $MPLAYEROPTS -vf rectangle=$crop_preview -nocache -nosound -ss $startpos >/dev/null 2>&1 & PID=$!; sleep 15; kill -KILL $PID;
> $MPLAYER "$sourcetype" $device $vid $MPLAYEROPTS -vf rectangle=$crop_preview -nocache -nosound -ss $startpos -endpos 15 >/dev/null 2>&1
> fi
> fi
> printf "Are you satisfied with the crop area? [y/n]: "
> read CROPDETERMINED
> done
Hope you can do something with this.

nm
20th July 2009, 11:38
OK, I have no idea how to make a patch. I simply did a diff like this:
diff h264enc.backup h264encYou only need to add option -u in this case to create a unified diff supported by the patch tool. For projects with many changed files in different subdirectories, use diff -Naur

elektronaut
20th July 2009, 13:19
I see. Here's the output using the "-u" parameter:
--- h264enc.backup 2009-07-19 15:12:34.000000000 +0200
+++ h264enc 2009-07-19 16:33:35.000000000 +0200
@@ -2465,58 +2465,68 @@

# Video cropping
video_crop_func() {
- case "$source" in
- dir|DIR|Dir)
- echo
- error "-> Cropping in directory batch encoding mode is not"
- error " recommended unless you know what you're doing!"
- ;;
- esac
- echo
- green "-> Detecting crop values with 'cropdetect'..."
- $MPLAYER "$sourcetype" $device $vid $MPLAYEROPTS -identify -vo null -ao null -frames 1 -nocache 2>/dev/null > $CONFIGDIR/cropdetect
- VLENGTH=$(grep "^ID_LENGTH" $CONFIGDIR/cropdetect | cut -f '2' -d '=' | cut -f '1' -d '.')
- case "$source" in
- dvd|DVD|Dvd) CROPOPTS="-vc mpeg12 -frames 30 -sstep $(($VLENGTH/30))" ;;
- *) CROPOPTS="-frames 500 -ss $(($VLENGTH/2))" ;;
- esac
- GETCROP=$($MPLAYER "$sourcetype" $device $vid $MPLAYEROPTS -vf cropdetect -nosound -vo null $CROPOPTS -nocache 2>/dev/null | tr '\r' '\n' | grep "crop=" | tail -n 1 | awk '{print $9}' | sed 's/crop=//g; s/).//g')
- rm -f $CONFIGDIR/cropdetect
- if [ ! -z "$GETCROP" ]; then
- green "-> Found crop values: $GETCROP"
- else
- green "-> Failed to get the crop values!"
- green "-> You have to specify them yourself!"
- green "-> The format is as follows: width:height:x:y"
- GETCROP="??"
- fi
- echo
- printf "Specify the crop values [default is $GETCROP]: "
- read cropvalues
- if [ -z "$cropvalues" -a "$GETCROP" = "??" ]; then
- cropfilter=
- else
- if [ -z "$cropvalues" ]; then
- cropfilter="crop=$GETCROP,"
- crop_preview="$GETCROP"
- else
- cropfilter="crop=$cropvalues,"
- crop_preview="$cropvalues"
- fi
- printf "Preview the crop values for 15 seconds? [y/n]: "
- read precrop
- if [ "$precrop" = "y" -o "$precrop" = "Y" ]; then
- printf "Specify the start position in hour:min:sec [default is 0:02:00]: "
- read timepos
- if [ -z "$timepos" ]; then
- startpos="0:02:00"
- else
- startpos="$timepos"
- fi
- #$MPLAYER "$sourcetype" $device $vid $MPLAYEROPTS -vf rectangle=$crop_preview -nocache -nosound -ss $startpos >/dev/null 2>&1 & PID=$!; sleep 15; kill -KILL $PID;
- $MPLAYER "$sourcetype" $device $vid $MPLAYEROPTS -vf rectangle=$crop_preview -nocache -nosound -ss $startpos -endpos 15 >/dev/null 2>&1
- fi
- fi
+ case "$source" in
+ dir|DIR|Dir)
+ echo
+ error "-> Cropping in directory batch encoding mode is not"
+ error " recommended unless you know what you're doing!"
+ ;;
+ esac
+ echo
+ green "-> Detecting crop values with 'cropdetect'..."
+ $MPLAYER "$sourcetype" $device $vid $MPLAYEROPTS -identify -vo null -ao null -frames 1 -nocache 2>/dev/null > $CONFIGDIR/cropdetect
+ VLENGTH=$(grep "^ID_LENGTH" $CONFIGDIR/cropdetect | cut -f '2' -d '=' | cut -f '1' -d '.')
+ case "$source" in
+ dvd|DVD|Dvd) CROPOPTS="-vc mpeg12 -frames 30 -sstep $(($VLENGTH/30))" ;;
+ *) CROPOPTS="-frames 500 -ss $(($VLENGTH/2))" ;;
+ esac
+ GETCROP=$($MPLAYER "$sourcetype" $device $vid $MPLAYEROPTS -vf cropdetect -nosound -vo null $CROPOPTS -nocache 2>/dev/null | tr '\r' '\n' | grep "crop=" | tail -n 1 | awk '{print $9}' | sed 's/crop=//g; s/).//g')
+ rm -f $CONFIGDIR/cropdetect
+ if [ ! -z "$GETCROP" ]; then
+ green "-> Found crop values: $GETCROP"
+ else
+ green "-> Failed to get the crop values!"
+ green "-> You have to specify them yourself!"
+ green "-> The format is as follows: width:height:x:y"
+ GETCROP="??"
+ fi
+ echo
+ CROPDETERMINED="n"
+ while [ "$CROPDETERMINED" != y ]
+ do
+ if [ -z "$cropvalues" ]; then
+ printf "Specify the crop values [default is $GETCROP]: "
+ else
+ printf "Specify the crop values [last try: "$cropvalues" ]: "
+ fi
+ read cropvalues
+ if [ -z "$cropvalues" -a "$GETCROP" = "??" ]; then
+ cropfilter=
+ else
+ if [ -z "$cropvalues" ]; then
+ cropfilter="crop=$GETCROP,"
+ crop_preview="$GETCROP"
+ else
+ cropfilter="crop=$cropvalues,"
+ crop_preview="$cropvalues"
+ fi
+ printf "Preview the crop values for 15 seconds? [y/n]: "
+ read precrop
+ if [ "$precrop" = "y" -o "$precrop" = "Y" ]; then
+ printf "Specify the start position in hour:min:sec [default is 0:02:00]: "
+ read timepos
+ if [ -z "$timepos" ]; then
+ startpos="0:02:00"
+ else
+ startpos="$timepos"
+ fi
+ #$MPLAYER "$sourcetype" $device $vid $MPLAYEROPTS -vf rectangle=$crop_preview -nocache -nosound -ss $startpos >/dev/null 2>&1 & PID=$!; sleep 15; kill -KILL $PID;
+ $MPLAYER "$sourcetype" $device $vid $MPLAYEROPTS -vf rectangle=$crop_preview -nocache -nosound -ss $startpos -endpos 15 >/dev/null 2>&1
+ fi
+ fi
+ printf "Are you satisfied with the crop area? [y/n]: "
+ read CROPDETERMINED
+ done
}

calcbits() {

microchip8
20th July 2009, 13:24
I've already manually added it. Also your patch is inconsistent with the coding standard of the script. Always use tabs instead of spaces ;)

microchip8
24th July 2009, 09:42
ChangeLog for version 8.9.5
* Switched to the new Auto-variance AQ (aq_mode=2) for all presets. This requires latest x264 revision
from git so please upgrade!
* Decreased frame references for all iPod presets to 1 and increased subq to 8 for the HQ iPod presets
* Minor improvments to the set_output_filename_func() function
* Merged the audio code of the portable device presets. Moderately reduces code duplication in the audio functions calling code
* Added two new presets (ag1 and ag1hq) for Android G1 devices. This brings the total presets count to 60
* Added support for the new gradfun debanding video filter. Although mostly recommended for playback due to the fact that
encoding tends to bring back banding, it can be useful to deband input sources which show pretty bad and very noticable
banding effects before passing the content to the encoder. The gradfun filter is only available in MPlayer SVN. This also
adds a new variable ALLOW_DEBAND to the config file where one can enable or disable this filter
* Added a small while loop to the video_crop_func() function which will keep asking the user for new crop values until he's
satisfied with them. Patch by elektronaut from Doom9.org
* Added a new variable PRIORITY to the config file which can be used to set a global priority nice value for the encoding
process. The values one can use are between (and including) -20 and 19. However, if the script detects that the variable
has a negative nice value set and the script is being executed with regular user privileges, it will print a notice and exit.
This change updates the config file to version 9
* Updated the man page

microchip8
30th July 2009, 13:01
ChangeLog for version 8.9.6 - small update
* Increased subq to 10 (QP-RD) for the IHQ preset. Requires latest x264 from git.
Also lowered frameref from 16 to 8 and bframes from 10 to 7
* Add example on how to encode only specific DVD chapters. Some people keep bugging
me about this while it's actually very simple

microchip8
1st August 2009, 11:56
ChangeLog for version 8.9.7
* Added new option -mfr which calculates the maximum allowed frame references within DPB (Decoded Picture Buffer)
limits for different H.264 levels and resolutions
* Call the track_echo_func() function inside the select_audio_codec_func() one. Removes pointless duplication
* Don't call mplayer twice in the 2nd/3rd audio track code just to get the audio codec. Also removed a pointless case statement
* Allow users to set the H.264 level when using the standard PC presets
* Fixed a few typos in the preset.cfg file
* Updated the man page

microchip8
7th August 2009, 11:07
ChangeLog for version 8.9.8
* Added support for the audio panning filter. This change also updates the config file to version 10
* Simplifications to the audio_filters_func() and audio_filters_var_func() functions
* Moved the audio filters functions after the audio codec ones
* Fixed a bug in the audio_channels_func() function for the AAC codec. If user just hits return to accept the
default AAC codec, the channels function was not called due to missing "" in the first case statement of that function
* Enabled MB tree (macroblock tree ratecontrol) for the high quality presets and disabled b_pyramid for presets that
have mbtree enabled as it currently doesn't support it. Note that mbtree produces a large passlog file when ran in 2-pass
mode but can increase quality anywhere between 2-70%, depending on the content. mbtree is only available in latest
x264 git so please upgrade
* Added new options mbtree, rc_lookahead and nopsy to the preset.cfg file

microchip8
11th August 2009, 09:26
ChangeLog for version 8.9.9
* Reduced the amount of if conditional iterations for setting the scaler interlace variable
* Print full path of the output file(s) at the end of encoding
* 10L: forgot to enable MB tree for the anihq preset
* Replaced variable CONFIGDIR with TEMPDIR. This change updates the config file to version 11
* Fixed some spacings issues by moving around some echo's
* Simplified the sample encoding code. Reduced some code duplication
* Upped psy_rd from 0.6 to 0.8

microchip8
15th August 2009, 11:46
ChangeLog for version 9.0.0
* Renamed presets f9 and f9hq to fl and flhq
* Added new preset 'fghq' specifically optimized for preserving film grain
* Removed duplicate videofilters variable. This removes the check for the tfields filter as now deinterlacing
will always be done after cropping (which also speeds up things a bit) so the crop filter will never complain
about crop area being outside of the original if tfields is used. It also reduces filters maintenance a bit
* Turn soft-clipping on in the volume audio filter
* Use aq_mode=1 for presets that have mbtree enabled as it usually does better on fades than aq_mode=2
* Updated the man page

WalterK
25th August 2009, 18:16
I am having random failures when trying to create a mkv and mp4 file from a specific chapter rip of a dvd.

This is the latest one

-> Converting AVI file to the MKV container, please wait...
-> Failed!

-> Converting AVI file to the MP4 container, please wait...
*** buffer overflow detected ***: /usr/bin/MP4Box terminated
======= Backtrace: =========
/lib/tls/i686/cmov/libc.so.6(__fortify_fail+0x48)[0xb7c38da8]
/lib/tls/i686/cmov/libc.so.6[0xb7c36eb0]
/lib/tls/i686/cmov/libc.so.6(__strcpy_chk+0x44)[0xb7c36184]
/usr/bin/MP4Box[0x804f58d]
/lib/tls/i686/cmov/libc.so.6(__libc_start_main+0xe5)[0xb7b51775]
/usr/bin/MP4Box[0x804cea1]
======= Memory map: ========
08048000-0806f000 r-xp 00000000 08:27 1094450 /usr/bin/MP4Box
0806f000-08071000 r--p 00026000 08:27 1094450 /usr/bin/MP4Box
08071000-08072000 rw-p 00028000 08:27 1094450 /usr/bin/MP4Box
084bf000-084e0000 rw-p 084bf000 00:00 0 [heap]
b7954000-b7961000 r-xp 00000000 08:27 2719809 /lib/libgcc_s.so.1
b7961000-b7962000 r--p 0000c000 08:27 2719809 /lib/libgcc_s.so.1
b7962000-b7963000 rw-p 0000d000 08:27 2719809 /lib/libgcc_s.so.1
b7963000-b7964000 rw-p b7963000 00:00 0
b7964000-b7966000 r-xp 00000000 08:27 2737489 /lib/tls/i686/cmov/libdl-2.9.so
b7966000-b7967000 r--p 00001000 08:27 2737489 /lib/tls/i686/cmov/libdl-2.9.so
b7967000-b7968000 rw-p 00002000 08:27 2737489 /lib/tls/i686/cmov/libdl-2.9.so
b7968000-b7969000 rw-p b7968000 00:00 0
b7969000-b797e000 r-xp 00000000 08:27 2737509 /lib/tls/i686/cmov/libpthread-2.9.so
b797e000-b797f000 r--p 00014000 08:27 2737509 /lib/tls/i686/cmov/libpthread-2.9.so
b797f000-b7980000 rw-p 00015000 08:27 2737509 /lib/tls/i686/cmov/libpthread-2.9.so
b7980000-b7982000 rw-p b7980000 00:00 0
b7982000-b7ab5000 r-xp 00000000 08:27 2722220 /lib/i686/cmov/libcrypto.so.0.9.8
b7ab5000-b7abd000 r--p 00132000 08:27 2722220 /lib/i686/cmov/libcrypto.so.0.9.8
b7abd000-b7aca000 rw-p 0013a000 08:27 2722220 /lib/i686/cmov/libcrypto.so.0.9.8
b7aca000-b7ace000 rw-p b7aca000 00:00 0
b7ace000-b7b10000 r-xp 00000000 08:27 2722221 /lib/i686/cmov/libssl.so.0.9.8
b7b10000-b7b11000 ---p 00042000 08:27 2722221 /lib/i686/cmov/libssl.so.0.9.8
b7b11000-b7b12000 r--p 00042000 08:27 2722221 /lib/i686/cmov/libssl.so.0.9.8
b7b12000-b7b15000 rw-p 00043000 08:27 2722221 /lib/i686/cmov/libssl.so.0.9.8
b7b15000-b7b39000 r-xp 00000000 08:27 2737491 /lib/tls/i686/cmov/libm-2.9.so
b7b39000-b7b3a000 r--p 00023000 08:27 2737491 /lib/tls/i686/cmov/libm-2.9.so
b7b3a000-b7b3b000 rw-p 00024000 08:27 2737491 /lib/tls/i686/cmov/libm-2.9.so
b7b3b000-b7c97000 r-xp 00000000 08:27 2737483 /lib/tls/i686/cmov/libc-2.9.so
b7c97000-b7c98000 ---p 0015c000 08:27 2737483 /lib/tls/i686/cmov/libc-2.9.so
b7c98000-b7c9a000 r--p 0015c000 08:27 2737483 /lib/tls/i686/cmov/libc-2.9.so
b7c9a000-b7c9b000 rw-p 0015e000 08:27 2737483 /lib/tls/i686/cmov/libc-2.9.so
b7c9b000-b7c9f000 rw-p b7c9b000 00:00 0
b7c9f000-b7cb3000 r-xp 00000000 08:27 2719905 /lib/libz.so.1.2.3.3
b7cb3000-b7cb4000 r--p 00013000 08:27 2719905 /lib/libz.so.1.2.3.3
b7cb4000-b7cb5000 rw-p 00014000 08:27 2719905 /lib/libz.so.1.2.3.3
b7cb5000-b7f2e000 r-xp 00000000 08:27 1094409 /usr/lib/libgpac-0.4.4.so
b7f2e000-b7f2f000 r--p 00279000 08:27 1094409 /usr/lib/libgpac-0.4.4.so
b7f2f000-b7f33000 rw-p 0027a000 08:27 1094409 /usr/lib/libgpac-0.4.4.so
b7f33000-b7f35000 rw-p b7f33000 00:00 0
b7f51000-b7f53000 rw-p b7f51000 00:00 0
b7f53000-b7f54000 r-xp b7f53000 00:00 0 [vdso]
b7f54000-b7f70000 r-xp 00000000 08:27 2719767 /lib/ld-2.9.so
b7f70000-b7f71000 r--p 0001b000 08:27 2719767 /lib/ld-2.9.so
b7f71000-b7f72000 rw-p 0001c000 08:27 2719767 /lib/ld-2.9.so
bfa47000-bfa72000 rw-p bffd5000 00:00 0 [stack]
-> Failed!

-> AVI file size: 182.631 MiB (/home/walter/encodes/chapter3 - chapter 3-3.avi)

Delete the AVI file? [y/n]: n

-> Have a nice day ^_^

Mplayer/Mencoder SVN-r29544-4.3.3 (C) 2000-2009 MPlayer Team
x264 core:72 r1222 d0ee6f8
gpac/libgpac 0.4.4-3
mkvtoolnix 2.9.8
faac/libfaac 1.26
aacplusenc 0.17
neroAacEnc 1.3.3.0

It randomly fails on mkv or mp4 creation depending on what aac encoder and what bitrate setting is used (all the default ones are selected), its the only thing i can think of since the encoding with libx264 works
here is the setting
h264enc -2p -p vdhq
With deinterlacing (default settings, crop to 720x352
Sure i can create my own mp4/mkv file but i am trying to figure out why that fails in h264enc

microchip8
25th August 2009, 18:27
h264enc doesn't fail in this case. It's the muxing programs that do. Probably, your muxing programs are mis-compiled or broken in some way. I also use mkvmerge 2.9.8 and MP4Box 0.4.5 (newer than yours and self-compiled) and have not experienced any problems with them. On occasion, and this is very rare, MP4Box will crash and there's little I can do about it. Blame it on it being cr@p :P

Also, I do not really use any exotic parameters for the muxers and everything is done according to documentation

EDIT: it'll be nice if you save the settings to the batch file and post them here so I can see what you use

WalterK
26th August 2009, 01:44
yes with the exception of mplayer,X264 (which are compiled), neroAacEnc and mkvtoolnix (which comes from bunkus' own repos listed at his site) all the addons required come from the stock ubuntu 9.04 repos.
I guess that could be a problem with Mp4Box but it doesnt explain why mkvmerge fails, however take the same avi run it through mp4box and mkvmerge (via the gui) and it outputs to mp4 and mkv fine.

I wished i had saved the settings i'll run another encode again tonight and post it.

microchip8
26th August 2009, 09:15
My mkvmerge also comes from Moritz' repo and I have yet to see it fail on me. Like I said, unless you show me the settings used from the batchfile, I can't really do much and can only speculate. Also you should remux that avi through the terminal and not using the gui, in order to replicate how h264enc does it as close as possible

WalterK
26th August 2009, 16:37
Ok heres my settings used, this time libfaac instead of accplusenc like the last time and this time mp4 output was successful but mkvmerge failed, i also compiled gpac using the 0.4.5 source
so here it is mkvmerge failure output

-> Converting AVI file to the MKV container, please wait...
-> Failed!

And the settings used

#!/bin/bash
################### START OF COMMANDS ###################

test -d "/home/walter/downloads" || mkdir -p "/home/walter/downloads"
test -d /home/walter/.h264enc/job4976 || mkdir -p /home/walter/.h264enc/job4976
test -e "/home/walter/encodes/chapter3 - chapter 3-3.avi" && mv -f "/home/walter/encodes/chapter3 - chapter 3-3.avi" "/home/walter/encodes/chapter3 - chapter 3-3.avi.old"

/usr/bin/mencoder "dvd://3" -o /dev/null -passlogfile "/home/walter/.h264enc/job4976/chapter3 - chapter 3-3.log" -vc mpeg12 -dvd-device /home/walter/encodes/montanareview -chapter 3-3 -ofps 30000/1001 -vf yadif=0,crop=720:352:0:66,softskip,harddup -field-dominance -1 -aspect 1.3333 -aid 128 -oac faac -faacopts mpeg=4:br=110:object=2 -ovc x264 -x264encopts pass=1:bitrate=1500:turbo=2:me=umh:me_range=24:nodct_decimate:nointerlaced:8x8dct:nofast_pskip:trellis=1:partitions=p8x8,b8x8,i8x8,i4x4:mixed_refs:keyint=300:keyint_min=30:psy_rd=0.8,0.2:frameref=4:bframes=3:b_adapt=2:nob_pyramid:weight_b:direct_pred=auto:subq=7:mbtree:chroma_me:cabac:aq_mode=2:deblock:vbv_maxrate=50000:vbv_bufsize=50000:level_idc=41:threads=auto:ssim:psnr

/usr/bin/mencoder "dvd://3" -o "/home/walter/encodes/chapter3 - chapter 3-3.avi" -passlogfile "/home/walter/.h264enc/job4976/chapter3 - chapter 3-3.log" -vc mpeg12 -dvd-device /home/walter/encodes/montanareview -chapter 3-3 -ofps 30000/1001 -vf yadif=0,crop=720:352:0:66,softskip,harddup -field-dominance -1 -aspect 1.3333 -aid 128 -oac faac -faacopts mpeg=4:br=110:object=2 -ovc x264 -x264encopts pass=2:bitrate=1500:me=umh:me_range=24:nodct_decimate:nointerlaced:8x8dct:nofast_pskip:trellis=1:partitions=p8x8,b8x8,i8x8,i4x4:mixed_refs:keyint=300:keyint_min=30:psy_rd=0.8,0.2:frameref=4:bframes=3:b_adapt=2:nob_pyramid:weight_b:direct_pred=auto:subq=7:mbtree:chroma_me:cabac:aq_mode=2:deblock:vbv_maxrate=50000:vbv_bufsize=50000:level_idc=41:threads=auto:ssim:psnr




sleep 2

test -e "/home/walter/encodes/chapter3 - chapter 3-3.mkv" && mv -f "/home/walter/encodes/chapter3 - chapter 3-3.mkv" "/home/walter/encodes/chapter3 - chapter 3-3.mkv.old"
/usr/bin/mkvmerge --attachment-mime-type image/jpeg --attachment-name Cover --attach-file "/home/walter/encodes/image.jpg" --title "chapter3 - chapter 3-3" --track-name 0:"chapter3 - chapter 3-3" --language 1:aid: --track-name 1:"LC-AAC Stereo" "/home/walter/encodes/chapter3 - chapter 3-3.avi" -o "/home/walter/encodes/chapter3 - chapter 3-3.mkv"
sleep 2

test -e "/home/walter/encodes/chapter3 - chapter 3-3.mp4" && mv -f "/home/walter/encodes/chapter3 - chapter 3-3.mp4" "/home/walter/encodes/chapter3 - chapter 3-3.mp4.old"
/usr/bin/mencoder "/home/walter/encodes/chapter3 - chapter 3-3.avi" -nosound -ovc copy -of rawvideo -o /home/walter/.h264enc/job4976/h264_video.h264
sleep 2
/usr/bin/MP4Box -aviraw audio "/home/walter/encodes/chapter3 - chapter 3-3.avi" -out /home/walter/.h264enc/job4976/aac.raw
mv -f /home/walter/.h264enc/job4976/aac_audio.raw /home/walter/.h264enc/job4976/aac_audio.aac


/usr/bin/mplayer "/home/walter/encodes/chapter3 - chapter 3-3.avi" -noconfig all -loop 1 -identify -nosound -vo null -nocache -frames 1 2>/dev/null | grep '^ID_VIDEO_FPS' | tail -n 1 | awk -F= '{print $2}' > /home/walter/.h264enc/job4976/mp4fps
/usr/bin/MP4Box -fps $(cat /home/walter/.h264enc/job4976/mp4fps) -tmp /home/walter/.h264enc/job4976 -add /home/walter/.h264enc/job4976/h264_video.h264 -add /home/walter/.h264enc/job4976/aac_audio.aac#audio:name="LC-AAC Stereo":lang=aid: -itags name="chapter3 - chapter 3-3":cover="/home/walter/encodes/image.jpg" -mpeg4 -new "/home/walter/encodes/chapter3 - chapter 3-3.mp4"


sleep 2
rm -f /home/walter/.h264enc/job4976/h264_video.h264
rm -f /home/walter/.h264enc/job4976/aac_audio.aac


sleep 2

rm -rf /home/walter/.h264enc/job4976

#################### END OF COMMANDS ####################

microchip8
26th August 2009, 16:46
That's the part that's causing mkvmerge to fail: --language 1:aid:

the aid: after the 1 should really be a language code but for some reason it isn't. I'll have to check why that is here but am using an older mencoder/mplayer revision than yours so am currently pulling from SVN and compiling a new one. Maybe something changed in mplayer. I've not had this problem with older mplayer revisions

microchip8
26th August 2009, 17:57
hmmm, I cannot reproduce your problem here even when using the latest mplayer from SVN. Tested with 4 different DVDs and all works fine here so I'm suspecting that this is specific to the DVD you used. Can you post the the output of:

mplayer dvd://1 -nosound -nocache -vo null -frames 1 2>/dev/null

At the top of this output, there are "audio stream" lines for each audio track on the DVD. Currently, I just grep for each track aid number at the end of each line and then print the 8th positional which gives me the language code. I can modify this to grep *specifically* for the language word with the -o grep option and then sed everything else with exception of the language code (or use awk '{print $2}' which is better in this case). This can be more reliable in case the DVD or mplayer does not report the "language" word for some reason, and thus will just return an empty string and further on allow the muxing to succeed but without language metadata added to the container(s) so it'll default to "und" (undefined) language

Can you test this small patch for me on the DVD that's giving you problems? - save as h264enc.diff http://pastebin.com/pastebin.php?dl=m752ef542

Apply as: patch -p0 < h264enc.diff /path/to/script/h264enc

After applying, you don't have to encode the chapter again just to see how it works. Instead, just save everything to the batchfile, hit ctrl+c when the encoding countdown starts and open the batchfile and check for the --language stuff in the mkvmerge line. It should be something like --language 1:en (for English language). If mplayer or this DVD does not report the language word, then it should be something like --language 1:und

WalterK
26th August 2009, 21:27
I did the encode anyway, its only a 19min chapter so it doesnt take that long to encode.
The muxing to mp4 and mkv now work again

-> Converting AVI file to the MKV container, please wait...
-> Done

-> Converting AVI file to the MP4 container, please wait...
-> Done

-> AVI file size: 178.983 MiB (/home/walter/encodes/chapter3 - chapter 3-3.avi)
-> MKV file size: 177.382 MiB (/home/walter/encodes/chapter3 - chapter 3-3.mkv)
-> MP4 file size: 177.537 MiB (/home/walter/encodes/chapter3 - chapter 3-3.mp4)

Delete the AVI file? [y/n]: y

-> Have a nice day ^_^



its currently on the harddrive but here it is before applied patch

mplayer dvd://3 -dvd-device /home/walter/encodes/montanareview -nosound -nocache -vo null -frames 1 2>/dev/null
MPlayer SVN-r29544-4.3.3 (C) 2000-2009 MPlayer Team

Playing dvd://3.
There are 4 titles on this DVD.
There are 1 angles in this DVD title.
audio stream: 0 format: ac3 (stereo) language: aid: 128.
number of audio channels on disk: 1.
number of subtitles on disk: 0
MPEG-PS file format detected.
VIDEO: MPEG2 720x480 (aspect 2) 29.970 fps 7800.0 kbps (975.0 kbyte/s)
==========================================================================
Forced video codec: ffmpeg12vdpau
Opening video decoder: [ffmpeg] FFmpeg's libavcodec codec family
Selected video codec: [ffmpeg12vdpau] vfm: ffmpeg (FFmpeg MPEG-1/2 (VDPAU))
==========================================================================
Audio: no sound
Starting playback...
[VD_FFMPEG] XVMC-accelerated MPEG-2.
VDec: vo config request - 720 x 480 (preferred colorspace: MPEG2 VDPAU acceleration)
VDec: using MPEG2 VDPAU acceleration as output csp (no 1)
Movie-Aspect is 1.33:1 - prescaling to correct movie aspect.
VO: [null] 720x480 => 720x540 MPEG2 VDPAU acceleration


Patch applied and settings

microchip8
26th August 2009, 22:07
ah, so the DVD does not report any language codes at all. That's why it failed and not due to missing language word. Still, the new method of finding language codes is better anyways so I'll put it in next release of h264enc ;)

Thanks for reporting!

microchip8
1st September 2009, 16:35
ChangeLog for version 9.0.1
* Simplified the audio_channels_func() function a bit
* Merged the QP and CRF settings
* Increased rc_lookahead a bit for the ehq, uhq and ihq presets
* Improved detection of DVD audio language codes. We now specifically grep for the language word and then print the 2nd positional
which gives us the language code. It works more reliably if the DVD does not report its language code for the audio track(s) so if this is
the case, we fall back to undefined language. The previous code fails in such cases due to the printing of the 8th positional which will
print the "aid:" part when there's no language code after the "language:" word, resulting in MKV/MP4 muxing failures. Reported by
WalterK from doom9.org
* Moved the code that deals with DVD subs/cover files/metadata info/chapters and external subs for the MP4 container before its audio code
* Added slicing to the Blu-ray and AVCHD presets. It increases compliancy with the Blu-ray specs. Slicing is only available in the latest x264
from git so please upgrade if you intend to use the Blu-ray/AVCHD presets
* Added new options 'slices', 'slice_max_size' and 'slice_max_mbs' to the preset.cfg file
* Fixed chapters import for the OGM container. Missing '@' before the chapters input file results in the file not being imported
* Added support for audio language metadata info for the OGM container
* Small improvements to how chapters information is added to the output file name

microchip8
4th September 2009, 22:19
ChangeLog for version 9.0.2
* Added new option sync_lookahead available in latest x264 git and updated the preset.cfg file
* Added support for the noise video filter. This change updates the config file to version 12. Also, encoding priority now defaults
to a nice value of 10 in the config file
* Moved out the code which checks and backups/renames a file if it has the same name as the output provided by the user to a
separate function called backup_file_func() and also improved it so that if there's already an existing backup file, the new one will
increase its count number by one thus there's no more overwriting being done anymore. The same thing applies to existing chapter
files and DVD subs
* Added support for Year and Genre metadata tagging for the MKV/MP4/OGM containers. For MKV, the genre and year is set globally
using an automatically generated XML file. MP4 uses the iTunes tagging and OGM the comment space
* Updated the man page

microchip8
6th September 2009, 12:41
ChangeLog for version 9.0.3
* Fixed a typo in the man page, MEnocder -> MEncoder
* Small improvement to how the MKV XML tagging file gets exported. Also improved the XML formatting and added
COMMENT string with text "Tagged by h264enc $version"
* Added comment tag for MP4 and OGM with the same text as above
* Small update to the video_deinterlace_func() function's menu
* Add comment header with dates to batch files

elektronaut
10th September 2009, 23:18
I didn't use h264enc in a little while and now installed the new version. Suddenly I have trouble in the cropping part. The preview window is not really working. It just flashes for a fraction of a second and then disappears again.

Anyone else having the same problem?

(Tried to encode a VOB file.)

microchip8
10th September 2009, 23:50
I haven't changed anything in the cropping code after your patch so this must be file specific. You can always get the cropping values from mplayer and provide them like I told you before. It works here and today I encoded a DVD

punlo
11th September 2009, 19:18
neroAAC encoder supports 2pass encoding. Could you please add this feature to your script. I know that it needs going back from fifos to regular files but the feature might be nice to have, especially if other coders start offering such feature too.

microchip8
11th September 2009, 19:23
I'll see if I will. IIRC 2pass will not get you more quality but guarantees the specified bitrate to be achieved

microchip8
11th September 2009, 21:30
neroAAC encoder supports 2pass encoding. Could you please add this feature to your script. I know that it needs going back from fifos to regular files but the feature might be nice to have, especially if other coders start offering such feature too.

You can do it just as well with FIFOs and I just did that so it'll be supported in next version of h264enc ;)