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

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

 

Go Back   Doom9's Forum > General > Linux, Mac OS X, & Co
Register FAQ Calendar Today's Posts Search

Reply
 
Thread Tools Search this Thread Display Modes
Old 20th January 2010, 14:32   #441  |  Link
Redsandro
Unregistered User
 
Redsandro's Avatar
 
Join Date: Jul 2008
Location: Netherlands
Posts: 133
Oh so it's sort of synchronization compensation! Well during speech I hardly notice it, but when shots are fired I can clearly see it's off. So I thought it was some error that introduced 0.2 seconds of audio-lack-behind.
But how can MEncoder think there's a sync issue when it has no ears? The source is good.

I thought I'd give you a sample then, for educational fair use purposes and stuff, but I cannot quickly find an example where a machine gun is fired (because then you could easily see the sync problem) and I need to go to work. In stead I found a single gunshot but with a keen eye you can clearly see a ~0.2 sec sync issue and you'd have to trust me that in some cases it will be more annoying than it looks.

The original, correct sync: (6 second snippet)
http://red.chillosophy.nl/trash/xfile0124/x0124orig.avi

The mp4 s60 encode, audio comes later because 6 frames are missing from the start (not included) (6 second snippet)
http://red.chillosophy.nl/trash/xfile0124/x0124s60.mp4

Here's a snip from the start of the original, because the missing frames on encodes always occur at the start: (9 second snippet)
http://red.chillosophy.nl/trash/xfil...x0124start.avi
__________________
avi + m2t -> Vdub + DGIndex -> AE CS3 -> x264 -> Hell On Earth
Woop, woop! That's the sound of the police!

Last edited by Redsandro; 20th January 2010 at 14:35.
Redsandro is offline   Reply With Quote
Old 20th January 2010, 15:31   #442  |  Link
microchip8
ffx264/ffhevc author
 
microchip8's Avatar
 
Join Date: May 2007
Location: /dev/video0
Posts: 1,844
Mencoder doesn't need ears to adjust a/v sync it has an internal algorithm to do this (though it's not perfect, but then what is?). I watched the mp4 (audio is a bit out of sync in the mp4 while playing under mplayer but the mp4 is not directly coming from h264enc - you used avidemux and I've no idea how it deals with sync) and the other two avi files, but I cannot spot any sync issues, though I must note that mine ears are not that fine-tuned

As for what you can do, you may need to play around with -delay and/or -mc options of mencoder. Currently, h264enc doesn't support (yet) any way of adjusting these options
__________________
ffx264 || ffhevc || ffxvid || microenc
microchip8 is offline   Reply With Quote
Old 20th January 2010, 15:33   #443  |  Link
nm
Registered User
 
Join Date: Mar 2005
Location: Finland
Posts: 2,641
Quote:
Originally Posted by Redsandro View Post
The original, correct sync: (6 second snippet)
http://red.chillosophy.nl/trash/xfile0124/x0124orig.avi

The mp4 s60 encode, audio comes later because 6 frames are missing from the start (not included) (6 second snippet)
http://red.chillosophy.nl/trash/xfile0124/x0124s60.mp4
A/V sync is identical in these clips when played back with MPlayer or VLC. I also tried changing the sync by 0.2 seconds (to both directions) in the other file and then there was a difference. Which players have you tried?
nm is offline   Reply With Quote
Old 20th January 2010, 15:50   #444  |  Link
Redsandro
Unregistered User
 
Redsandro's Avatar
 
Join Date: Jul 2008
Location: Netherlands
Posts: 133
Yes I used AviDemux to cut a snip out of my full encode. I used copy stream (it snaps to keyframes) and I thought it made an identical copy like that.
Thanks for the advise though. I might want to try -mc 0 on my next batch.

Quote:
Originally Posted by nm View Post
A/V sync is identical in these clips when played back with MPlayer or VLC. I also tried changing the sync by 0.2 seconds (to both directions) in the other file and then there was a difference. Which players have you tried?
A/V sync is not identical here when using:
MPC (win)
MPC-HC (win) (I think that one uses ffdshow internally, not sure)
VLC (win)
RealPlayer (I know! But it comes with Symbian S60 and for once it's pretty good at it. :P)

Note that you need an accurate observational A/V sync internally if you know what I mean. It's only a small difference.

I am sorry I did not try linux players because I use my server with ssh for cool stuff like h264enc but for anything other than text I use my windows machine.
__________________
avi + m2t -> Vdub + DGIndex -> AE CS3 -> x264 -> Hell On Earth
Woop, woop! That's the sound of the police!
Redsandro is offline   Reply With Quote
Old 20th January 2010, 16:02   #445  |  Link
nm
Registered User
 
Join Date: Mar 2005
Location: Finland
Posts: 2,641
Quote:
Originally Posted by Redsandro View Post
A/V sync is not identical here when using:
MPC (win)
MPC-HC (win) (I think that one uses ffdshow internally, not sure)
VLC (win)
RealPlayer (I know! But it comes with Symbian S60 and for once it's pretty good at it. :P)

Note that you need an accurate observational A/V sync internally if you know what I mean. It's only a small difference.
Well, I controlled my test by changing the sync, in which case I could hear a difference between the samples, but originally I didn't notice any difference. Did you try these sample clips in all those players too? Maybe they are different from your full encodes.
nm is offline   Reply With Quote
Old 20th January 2010, 16:10   #446  |  Link
Redsandro
Unregistered User
 
Redsandro's Avatar
 
Join Date: Jul 2008
Location: Netherlands
Posts: 133
Yes I tried the samples before I uploaded and just now I tried them in VLC. I do notice the difference or I am really getting crazy. Maybe it's not 200ms because that was just a 6 frame guess. A wrong guess btw, 6 frames would be about 250ms in this case.

I watch sometimes when I need to travel by train to work, school or friends. When I come across a more obvious example I will post another example.
__________________
avi + m2t -> Vdub + DGIndex -> AE CS3 -> x264 -> Hell On Earth
Woop, woop! That's the sound of the police!
Redsandro is offline   Reply With Quote
Old 21st January 2010, 06:24   #447  |  Link
microchip8
ffx264/ffhevc author
 
microchip8's Avatar
 
Join Date: May 2007
Location: /dev/video0
Posts: 1,844
ChangeLog for version 9.1.4
Code:
* Set default H.264 level to 'auto' and also accept integer numbers as levels in addition to accepting fixed point ones,
ie both 41 and 4.1 are now accepted as valid levels
* Renamed the rmconf() function to rmtemp()
* Moved creation of temp dir, the interrupt_func() and rmtemp() functions at the beginning of the script
* Fixed a bug in the DVD part of the -scan option where lsdvd doesn't get a valid device passed. Bug was introduced due to
changes in the new get_devices_func() function
* Reduced duplication in the mencoder_opts() function
* Various small code improvements
__________________
ffx264 || ffhevc || ffxvid || microenc
microchip8 is offline   Reply With Quote
Old 30th January 2010, 16:47   #448  |  Link
microchip8
ffx264/ffhevc author
 
microchip8's Avatar
 
Join Date: May 2007
Location: /dev/video0
Posts: 1,844
ChangeLog for version 9.1.5
Code:
* Reduced duplication in the audio encode exporting code by moving it inside functions
* Reduced duplication in the MKV/MP4/TS/OGM exporting code by moving it inside functions
* Reduced duplication in the code that prints some information before encoding starts
* Various minor code improvements
__________________
ffx264 || ffhevc || ffxvid || microenc
microchip8 is offline   Reply With Quote
Old 31st January 2010, 13:29   #449  |  Link
kripz
Registered User
 
Join Date: Oct 2009
Posts: 12
Not sure if it's me but i just upgraded to h264enc to 9.1.5, mplayer and x264. h264enc says mencoder doesnt have h.264 support in mencoder?

h264enc -r followed by -sc
Code:
-> Checking for 'MPlayer'..................... OK
-> Checking for 'MEncoder'.................... OK
-> H.264 video support in MEncoder............ NO
-> AAC (FAAC) audio support in MEncoder....... NO
-> MP3 (LAME) audio support in MEncoder....... NO
-> AC3 (lavc) audio support in MEncoder....... NO
-> PCM audio support in MEncoder.............. NO

-> Checking for 'bc'.......................... OK
-> Checking for 'pv'.......................... OK
-> Checking for 'dd'.......................... OK
-> Checking for 'neroAacEnc'.................. OK
-> Checking for 'aacplusenc'.................. OK
-> Checking for 'oggenc'...................... FAILED! [no support for Vorbis audio]
-> Checking for 'flac'........................ OK
-> Checking for 'less'........................ OK
-> Checking for 'lsdvd'....................... OK
-> Checking for 'dvdxchap' (from ogmtools).... OK
-> Checking for 'mkvmerge' (from mkvtoolnix).. OK
-> Checking for 'ogmmerge' (from ogmtools).... OK
-> Checking for 'MP4Box' (from gpac).......... OK
-> Checking for 'tsMuxeR'..................... OK
mplayer ./configure
Code:
Checking for cc version ... 4.3.4 
Detected operating system: Linux
Detected host architecture: x86_64
Checking for host cc ... cc 
Checking for cross compilation ... no 
Checking for CPU vendor ... AuthenticAMD (16:5:2) 
Checking for CPU type ...  AMD Athlon(tm) II X4 620 Processor 
Checking for kernel support of mmx ... yes 
Checking for kernel support of mmxext ... yes 
Checking for kernel support of 3dnow ... yes 
Checking for kernel support of 3dnowext ... yes 
Checking for kernel support of sse ... yes 
Checking for kernel support of sse2 ... yes 
Checking for kernel support of cmov ... yes 
Checking for mtrr support ... yes 
Checking for GCC & CPU optimization abilities ... native 
Checking for byte order ... little-endian 
Checking for extern symbol prefix ...  
Checking for assembler support of -pipe option ... yes 
Checking for compiler support of named assembler arguments ... yes 
Checking for .align is a power of two ... no 
Checking for 10 assembler operands ... yes 
Checking for ebx availability ... yes 
Checking for PIC ... no 
Checking for yasm ... yasm 
Checking for bswap ... yes 
Checking for -lposix ... no 
Checking for -lm ... yes 
Checking for langinfo ... yes 
Checking for language ... messages: en - man pages: en - documentation: en 
Checking for enable sighandler ... yes 
Checking for runtime cpudetection ... no 
Checking for restrict keyword ... restrict 
Checking for __builtin_expect ... yes 
Checking for kstat ... no 
Checking for posix4 ... no 
Checking for exp2 ... yes 
Checking for exp2f ... yes 
Checking for llrint ... yes 
Checking for log2 ... yes 
Checking for log2f ... yes 
Checking for lrint ... yes 
Checking for lrintf ... yes 
Checking for round ... yes 
Checking for roundf ... yes 
Checking for truncf ... yes 
Checking for mkstemp ... yes 
Checking for nanosleep ... yes 
Checking for socklib ... yes 
Checking for netdb.h, struct addrinfo ... yes 
Checking for netdb.h, getaddrinfo() ... yes 
Checking for sockaddr_storage ... yes 
Checking for arpa/inet.h ... yes 
Checking for inet_pton() ... yes 
Checking for inet_aton() ... yes 
Checking for socklen_t ... yes 
Checking for closesocket() ... no 
Checking for network ... yes 
Checking for inet6 ... yes 
Checking for gethostbyname2 ... yes 
Checking for inttypes.h (required) ... yes 
Checking for int_fastXY_t in inttypes.h ... yes 
Checking for malloc.h ... yes 
Checking for memalign() ... yes 
Checking for posix_memalign() ... yes 
Checking for alloca.h ... yes 
Checking for fastmemcpy ... yes 
Checking for hard-coded tables ... no 
Checking for mman.h ... yes 
Checking for dynamic loader ... yes 
Checking for dynamic a/v plugins support ... no 
Checking for pthread ... yes (using -lpthread)
Checking for w32threads ... no (using pthread instead)
Checking for rpath ... no 
Checking for iconv ... yes 
Checking for soundcard.h ... yes (sys/soundcard.h)
Checking for sys/dvdio.h ... no 
Checking for sys/cdio.h ... no 
Checking for linux/cdrom.h ... yes 
Checking for dvd.h ... no 
Checking for termcap ... yes (using -lncurses)
Checking for termios ... yes (using sys/termios.h)
Checking for shm ... yes 
Checking for strsep() ... yes 
Checking for vsscanf() ... yes 
Checking for swab() ... yes 
Checking for POSIX select() ... yes 
Checking for audio select() ... yes 
Checking for gettimeofday() ... yes 
Checking for glob() ... yes 
Checking for setenv() ... yes 
Checking for sys/sysinfo.h ... yes 
Checking for Apple IR ... yes 
Checking for pkg-config ... yes 
Checking for Samba support (libsmbclient) ... no 
Checking for tdfxfb ... no 
Checking for s3fb ... no 
Checking for wii ... no 
Checking for tdfxvid ... no 
Checking for xvr100 ... no 
Checking for tga ... yes 
Checking for md5sum support ... yes 
Checking for yuv4mpeg support ... yes 
Checking for bl ... no 
Checking for DirectFB ... no 
Checking for X11 headers presence ... no (check if the dev(el) packages are installed)
Checking for X11 ... no (check if the dev(el) packages are installed)
Checking for Xss screensaver extensions ... no 
Checking for DPMS ... no 
Checking for Xv ... no 
Checking for XvMC ... no 
Checking for VDPAU ... no 
Checking for Xinerama ... no 
Checking for Xxf86vm ... no 
Checking for XF86keysym ... no 
Checking for DGA ... no 
Checking for 3dfx ... no 
Checking for VIDIX ... yes 
Checking for VIDIX PCI device name database ... yes 
Checking for VIDIX dhahelper support ... no 
Checking for VIDIX svgalib_helper support ... no 
Checking for /dev/mga_vid ... no 
Checking for xmga ... no 
Checking for GGI ... no 
Checking for GGI extension: libggiwmh ... no 
Checking for AA ... no 
Checking for CACA ... no 
Checking for SVGAlib ... no 
Checking for FBDev ... yes 
Checking for DVB ... no 
Checking for DVB HEAD ... yes 
Checking for OpenGL ... no 
Checking for MatrixView ... no 
Checking for PNG support ... no 
Checking for MNG support ... no 
Checking for JPEG support ... no 
Checking for OpenJPEG (JPEG2000) support ... no 
Checking for PNM support ... yes 
Checking for GIF support ... no 
Checking for VESA support ... no 
Checking for SDL ... no 
Checking for DXR2 ... no 
Checking for DXR3/H+ ... no 
Checking for IVTV TV-Out (pre linux-2.6.24) ... no 
Checking for V4L2 MPEG Decoder ... yes 
Checking for OSS Audio ... yes 
Checking for aRts ... no 
Checking for EsounD ... no 
Checking for NAS ... no 
Checking for pulse ... no 
Checking for JACK ... no 
Checking for OpenAL ... no 
Checking for ALSA audio ... no 
Checking for Sun audio ... no 
Checking for VCD support ... yes 
Checking for dvdread ... yes (internal)
Checking for internal libdvdcss ... yes 
Checking for cdparanoia ... no 
Checking for libcdio ... no 
Checking for bitmap font support ... yes 
Checking for freetype >= 2.0.9 ... no 
Checking for fontconfig ... no (FreeType support needed)
Checking for SSA/ASS support ... no (FreeType support needed)
Checking for fribidi with charsets ... no 
Checking for ENCA ... no 
Checking for zlib ... yes 
Checking for bzlib ... yes 
Checking for RTC ... yes 
Checking for liblzo2 support ... no 
Checking for mad support ... no 
Checking for Twolame ... no 
Checking for Toolame ... no 
Checking for OggVorbis support ... yes (internal Tremor)
Checking for libspeex (version >= 1.1 required) ... no 
Checking for OggTheora support ... no 
Checking for internal mp3lib support ... yes 
Checking for liba52 support ... no 
Checking for internal libmpeg2 support ... yes 
Checking for libdca support ... no 
Checking for libmpcdec (musepack, version >= 1.2.1 required) ... no 
Checking for FAAC support ... yes (in libavcodec: yes)
Checking for FAAD2 support ... yes (internal floating-point)
Checking for LADSPA plugin support ... no 
Checking for libbs2b audio filter support ... no 
Checking for Win32 codecs ... no 
Checking for XAnim codecs ... yes (using /usr/local/lib/codecs)
Checking for RealPlayer codecs ... yes (using /usr/local/lib/codecs)
Checking for QuickTime codecs ... auto 
Checking for Nemesi Streaming Media libraries ... no 
Checking for LIVE555 Streaming Media libraries ... no 
Checking for FFmpeg libavutil ... yes (static)
Checking for FFmpeg libavcodec ... yes (static)
Checking for FFmpeg libavformat ... yes (static)
Checking for FFmpeg libpostproc ... yes (static)
Checking for FFmpeg libswscale ... yes (static)
Checking for libopencore_amr narrowband ... no 
Checking for libopencore_amr wideband ... no 
Checking for libdv-0.9.5+ ... no 
Checking for Xvid ... no 
Checking for Xvid two pass plugin ... no 
Checking for x264 ... yes (in libavcodec: yes)
Checking for libdirac ... no 
Checking for libschroedinger ... no 
Checking for libnut ... no 
Checking for zr ... no 
Checking for libmp3lame ... yes (in libavcodec: yes)
Checking for mencoder ... yes 
Checking for UnRAR executable ... yes 
Checking for TV interface ... yes 
Checking for DirectShow TV interface ... no 
Checking for Video 4 Linux TV interface ... yes 
Checking for Video 4 Linux 2 TV interface ... yes 
Checking for Radio interface ... no 
Checking for Capture for Radio interface ... no 
Checking for Video 4 Linux 2 Radio interface ... no 
Checking for Video 4 Linux Radio interface ... no 
Checking for Video 4 Linux 2 MPEG PVR interface ... yes 
Checking for ftp ... yes 
Checking for vstream client ... no 
Checking for OSD menu ... no 
Checking for Subtitles sorting ... yes 
Checking for XMMS inputplugin support ... no 
Checking for GUI ... no
Checking for automatic gdb attach ... no 
Checking for compiler support for noexecstack ... yes 
Checking for linker support for --nxcompat --no-seh --dynamicbase ... no 
Checking for joystick ... no 
Checking for lirc ... no 
Checking for lircc ... no 
Checking for DVD support (libdvdnav) ... yes (internal)
Creating config.mak
Creating config.h

Config files successfully generated by ./configure  !

  Install prefix: /usr/local
  Data directory: /usr/local/share/mplayer
  Config direct.: /usr/local/etc/mplayer

  Byte order: little-endian
  Optimizing for: native

  Languages:
    Messages/GUI: en
    Manual pages: en
    Documentation: en

  Enabled optional drivers:
    Input: dvdnav(internal) ftp pvr tv-v4l2 tv-v4l tv libdvdcss(internal) dvdread(internal) vcd dvb network 
    Codecs: x264 libavcodec(internal) real xanim faad2(internal) faac libmpeg2(internal) mp3lib(internal) tremor(internal) 
    Audio output: oss v4l2 mpegpes(dvb) 
    Video output: v4l2 pnm mpegpes(dvb) fbdev cvidix yuv4mpeg md5sum tga 

  Disabled optional drivers:
    Input: vstream radio tv-dshow live555 nemesi cddb cdda smb 
    Codecs: libschroedinger libdirac xvid libdv libopencore_amrwb libopencore_amrnb qtx win32 musepack libdca liba52 libtheora speex toolame twolame libmad liblzo gif OpenJPEG 
    Audio output: sun alsa openal jack pulse nas esd arts ivtv dxr2 sdl 
    Video output: zr zr2 ivtv dxr3 dxr2 sdl vesa gif89a jpeg matrixview opengl svga caca aa ggi xmga mga xvidix winvidix 3dfx dga vdpau xvmc xv x11 dfbmga directfb bl xvr100 tdfx_vid wii s3fb tdfxfb 

'config.h' and 'config.mak' contain your configuration options.
Note: If you alter theses files (for instance CFLAGS) MPlayer may no longer
      compile *** DO NOT REPORT BUGS if you tweak these files ***

'make' will now compile MPlayer and 'make install' will install it.
Note: On non-Linux systems you might need to use 'gmake' instead of 'make'.

Please check mtrr settings at /proc/mtrr (see DOCS/HTML//video.html#mtrr)

NOTE: Win32 codec DLLs are not supported on your CPU (x86_64) or your
operating system (Linux). You may encounter a few files that cannot
be played due to missing open source video/audio codec support.

Check configure.log if you wonder why an autodetection failed (make sure
development headers/packages are installed).

NOTE: The --enable-* parameters unconditionally force options on, completely
skipping autodetection. This behavior is unlike what you may be used to from
autoconf-based configure scripts that can decide to override you. This greater
level of control comes at a price. You may have to provide the correct compiler
and linker flags yourself.
If you used one of these options (except --enable-gui and similar ones that
turn on internal features) and experience a compilation or linking failure,
make sure you have passed the necessary compiler/linker flags to configure.

If you suspect a bug, please read DOCS/HTML//bugreports.html.
kripz is offline   Reply With Quote
Old 31st January 2010, 15:26   #450  |  Link
microchip8
ffx264/ffhevc author
 
microchip8's Avatar
 
Join Date: May 2007
Location: /dev/video0
Posts: 1,844
No problems here at all with all latest versions. Do you have multiple instances of mencoder/mplayer? If so, make sure the correct one is set in the config. Also check with ldd to see if mencoder is linked against libx264 - ldd /paht/to/bin/mencoder | grep x264. Also see with mencoder -ovc help
__________________
ffx264 || ffhevc || ffxvid || microenc
microchip8 is offline   Reply With Quote
Old 1st February 2010, 00:33   #451  |  Link
WalterK
Registered User
 
WalterK's Avatar
 
Join Date: Jan 2006
Posts: 177
yes make sure your version of libx264 and mplayer/mencoder are uptodate
WalterK is offline   Reply With Quote
Old 18th February 2010, 17:30   #452  |  Link
microchip8
ffx264/ffhevc author
 
microchip8's Avatar
 
Join Date: May 2007
Location: /dev/video0
Posts: 1,844
ChangeLog for version 9.1.6

Code:
* Added new veriable 'DEFOUTPUT' to the config file which can be used to set a default
output directory. This updates the config to version 15
* Modified the set_output_filename_func() function to support the above variable.
		- If the DEFOUTPUT variable is empty, user can either provide just the output
		  name for the encode (in this case the script assumes $HOME as output dir), or
		  the full path and output name, which in this case the script will create the
		  output dir if it's not present or will do a write test when the dir is present
		  to see if it's writable by the user. If creation of output dir or the write test
		  fails, the script exits with a notice.
		- If the DEFOUTPUT variable contains a custom output dir, the script will test for
		  it and create it if it's not present. If creation fails, the script exits with a
		  notice. If the dir is present, the script will do a write test to see if the
		  custom dir is writable. If not, the script exits with a notice.
		- The DEFOUTPUT variable can be overwritten on the command line. This means that if
		  user has set a custom output dir in the DEFOUTPUT variable but provides a path when
		  asked on the command line, that path will be used instead of the one in the DEFOUTPUT
		  variable. The script then will either check and create the provided output dir on
		  the command line (if that dir is not present) or will do a write test if the dir
		  is present. Upon failure of creation or write test, the script exits with a notice.
		  If no path is provided on the command line but only the output name for the encode,
		  the script will use the one set in the DEFOUTPUT variable.
__________________
ffx264 || ffhevc || ffxvid || microenc
microchip8 is offline   Reply With Quote
Old 10th March 2010, 23:29   #453  |  Link
dbg0
Registered User
 
Join Date: Jan 2010
Posts: 1
@froggy1,

h264enc is a nice script, thank you. I agree that GUI is almost useless. However, I am just a beginner user of h264, and it frustrates me a bit. Let us consider an example:

Code:
$ h264enc -3p ehq
...
Select the Input type [file/dir/dvd/vcd]: filr    # It is just a typo, I wanted to enter "file".
-> You have to specify the input type (file/dir/dvd/vcd)
That's all, program finished, so I have to restart it and be more careful. It this particular case my mistake is not a big problem, because h264enc terminates at the first question. But in reality I made a few mistakes no so close to the beginning, so I had to restart h264enc again and again.

Once I entered a relative path to file (I believe it is rather natural for a person working with command line), but h264enc said I should enter an absolute one and terminated again.

I did not like it. I believe (1) some more amount of interactivity would not hurt, it would be better if h264enc would check user input, and if it is wrong, let user a chance to fix it and continue, (2) h264enc should not stop if an absolute path is required -- h264enc should convert relative path to absolute and continue.

I wrote few functions for getting user input. They allows user correct a mistake and continue. For example:

Code:
$ h264enc -3p -p ehq
...
Available input types
~~~~~~~~~~~~~~~~~~~~~
1 --> File
2 --> Directory
3 --> DVD
4 --> VCD

Select the input type [1, 2, 3, 4]: 6
Invalid choice, try again.
Select the input type [1, 2, 3, 4]:
Here is the code of functions:

Code:
bold()  { echo -e "\e[1m$1\e[0m"; }

function ask_choice() {
    local _ac_prompt=$1    # Prompt string.
    local _ac_choices=$2   # Choices string.
    local _ac_var=$3       # Name of variable to save answer to.
    local _ac_default=$4   # Default answer.
    local _ac_n=0          # Index variable.
    local _ac_choice       # Array of choices.
    local _ac_answer       # User's answer.
    # Parse $2, fill in array of valid choices.
    while [[ $_ac_choices == *\,* ]]; do
        _ac_n=$(( _ac_n + 1 ))
        _ac_choice[ $_ac_n ]=${_ac_choices%%,*}
        _ac_choices=${_ac_choices#*,}
    done
    _ac_n=$(( _ac_n + 1 ))
    _ac_choice[ $_ac_n ]=$_ac_choices
    # Reconstruct _ac_choices (it was destroyed during parsing).
    _ac_choices=
    for (( _ac_n = 1; _ac_n <= ${#_ac_choice[@]}; _ac_n = _ac_n + 1 )); do
        if [[ $_ac_n -gt 1 ]]; then
            _ac_choices="$_ac_choices, "
        fi
        if [[ ${_ac_choice[ $_ac_n ]} == "$_ac_default" ]]; then
            # Highligh default choice.
            _ac_choices="$_ac_choices$(bold "${_ac_choice[ $_ac_n ]}")"
        else
            _ac_choices="$_ac_choices${_ac_choice[ $_ac_n ]}"
        fi    
    done
    # Now ask user.
    while true; do 
      read -e -p "$_ac_prompt [$_ac_choices]: " _ac_answer
      if [[ $_ac_answer == "" ]]; then
          _ac_answer=$_ac_default
      fi
      for (( _ac_n = 1; _ac_n <= ${#_ac_choice[@]}; _ac_n = _ac_n + 1 )); do
          if [[ $_ac_answer == "${_ac_choice[ $_ac_n ]}" ]]; then
              eval $_ac_var=\$_ac_answer
              return $_ac_n
          fi
      done
      printf "Invalid choice, try again.\n"
    done
} # function ask

function ask_yn() {
    local _ay_prompt=$1    # Prompt string.
    local _ay_var=$2       # Name of variable to save answer to.
    local _ay_default=$3   # Default answer.
    if [[ -z $_ay_default ]]; then
        _ay_default="n"
    fi
    # Ask user.
    ask_choice "$_ay_prompt" "y,n" "$_ay_var" "$_ay_default"
} # function ask_yn

function ask_file() {
    local _af_prompt=$1    # Prompt string.
    local _af_tests=$2     # File tests.
    local _af_var=$3       # Name of variable to save answer to.
    local _af_default=$4   # Default answer.
    local _af_n=0          # Index variable.
    local _af_test
    local _af_answer=   
    # Parse $2, fill in array of tests.
    while [[ $_af_tests == *,* ]]; do
        _af_n=$(( _af_n + 1 ))
        _af_test[ $_af_n ]=${_af_tests%%,*}
        _af_tests=${_af_tests#*,}
    done
    _af_n=$(( _af_n + 1 ))
    _af_test[ $_af_n ]=$_af_tests
    # Prepare prompt.
    if [[ -n $_af_default ]]; then
        _af_prompt="$_af_prompt [default is $(bold "$_af_default")]"
    fi
    # Ask user.
    while true; do 
      read -e -p "$_af_prompt: " -i "$_af_answer" _af_answer
      if [[ $_af_answer == "" ]]; then
          _af_answer=$_af_default
      fi
      for (( _af_n = 1; _af_n <= ${#_af_test[@]}; _af_n = _af_n + 1 )); do
          if [[ ${_af_test[ $_af_n ]} == "-e" && ! -e $_af_answer ]]; then
              echo "\`$_af_answer' does not exist."
              continue 2
          fi
          if [[ ${_af_test[ $_af_n ]} == "-d" && ! -d $_af_answer ]]; then
              echo "\`$_af_answer' not a directory."
              continue 2
          fi
          if [[ ${_af_test[ $_af_n ]} == "-f" && ! -f $_af_answer ]]; then
              echo "\`$_af_answer' not a file."
              continue 2
          fi
          if [[ ${_af_test[ $_af_n ]} == "-b" && ! -b $_af_answer ]]; then
              echo "\`$_af_answer' not a block device."
              continue 2
          fi
          if [[ ${_af_test[ $_af_n ]} == "-A" ]]; then
              rel2abs "$_af_answer" _af_answer
          fi
      done
      eval $_af_var=\$_af_answer
      return 0
    done
} # function ask_file

function rel2abs() {
    local _rel2abs_path=$1
    local _rel2abs_var=$2
    local _rel2abs_dir
    local _rel2abs_file
    if [[ ! $_rel2abs_path == "/" ]]; then 
      _rel2abs_dir=$(dirname "$_rel2abs_path")
      _rel2abs_file=$(basename "$_rel2abs_path")
      _rel2abs_dir=$(cd "$_rel2abs_dir" && pwd -P)
      if [[ $_rel2abs_dir == "" ]]; then
          echo "??????????"
      fi
      if [[ $_rel2abs_dir == */ ]]; then
          _rel2abs_path=$_rel2abs_dir$_rel2abs_file
      else
          _rel2abs_path=$_rel2abs_dir/$_rel2abs_file
      fi    
    fi
    eval $_rel2abs_var=\"\$_rel2abs_path\"
} # function rel2abs
Function ask_choice asks user for a choice one of allowed options, e. g.:

Code:
ask_choice "In which format to export" "text,perl,python,ruby,xml" format
or

Code:
echo ""
brown "Deinterlace Methods"
brown "~~~~~~~~~~~~~~~~~~~"
echo "0 -> Deinterlace at half frame rate"
echo "1 -> Deinterlace at original frame rate"
echo "2 -> Deinterlace at double frame rate (bobbing)"
echo "3 -> Skip deinterlacing"
echo ""
ask_choice "Select the deinterlacing method" "0,1,2,3" deintmethod "1"
ask_yn is an adaptation of ask_choice to yes/no questions.

ask_file asks for a file or directory name, e. g.:

Code:
ask_file "Provide the input video file: " "-e,-f,-A" infile
"-e,-f,-A" means that file should exist, be a plain file, and function will convert relative path to absolute one.

Another example, asking for a DVD device:

Code:
ask_file "Specify the DVD device" "-e,-b,-A" dvd_dev "/dev/dvd"
Here is an example of work:

Code:
Specify the DVD device [default is /dev/dvd]: /home/
`/home/' not a block device.
Specify the DVD device [default is /dev/dvd]:
Do you think you could incorporate these functions into h264enc?

Thanks.

Last edited by dbg0; 10th March 2010 at 23:39.
dbg0 is offline   Reply With Quote
Old 11th March 2010, 00:07   #454  |  Link
microchip8
ffx264/ffhevc author
 
microchip8's Avatar
 
Join Date: May 2007
Location: /dev/video0
Posts: 1,844
if you provide a decent real unified patch against the latest version, then I just might. Otherwise, no.
__________________
ffx264 || ffhevc || ffxvid || microenc
microchip8 is offline   Reply With Quote
Old 16th March 2010, 22:10   #455  |  Link
microchip8
ffx264/ffhevc author
 
microchip8's Avatar
 
Join Date: May 2007
Location: /dev/video0
Posts: 1,844
ChangeLog for version 9.1.7
Code:
* Space escaped some previously missed variables
* Use one variable in the presets (x264params) for all MEncoder x264 encoding options. Reduces some code and simplifies things a bit
* Updated the preset.cfg file to support the "one variable for all x264 encoder opts"
Note: those using custom preset files for encoding should read the preset.cfg file in the doc dir and adapt their existing preset files to
be compatible with the changes. Previous older custom presets written by users will not work with this and future versions of h264enc!
__________________
ffx264 || ffhevc || ffxvid || microenc
microchip8 is offline   Reply With Quote
Old 18th March 2010, 16:51   #456  |  Link
microchip8
ffx264/ffhevc author
 
microchip8's Avatar
 
Join Date: May 2007
Location: /dev/video0
Posts: 1,844
ChangeLog for version 9.1.8
Code:
* Small bugfix: keyint and keyint_min weren't passed on to MEncoder when using some presets
__________________
ffx264 || ffhevc || ffxvid || microenc
microchip8 is offline   Reply With Quote
Old 22nd March 2010, 17:02   #457  |  Link
ennob
Registered User
 
Join Date: Mar 2010
Posts: 3
patch to get rid of '-r' in sed(1) commands

Hi froggy1

Nice tool. I especially like the presets, it can be a pain to figure out what all the different platforms support.

I attached a patch to replace some sed(1) commands with awk(1) commands since the '-r' switch for sed(1) is not university supported. E.g., my FreeBSD box didn't like them.

Hope you can use it and thanks for a great tool.

/ennob
Attached Files
File Type: diff h264enc_freebsd.diff (1.1 KB, 16 views)
ennob is offline   Reply With Quote
Old 22nd March 2010, 21:49   #458  |  Link
ennob
Registered User
 
Join Date: Mar 2010
Posts: 3
Btw froggy1, any plans of putting this under version control, say Git?

It would make it a bit easier to update and you might get more community support/development.

/ennob
ennob is offline   Reply With Quote
Old 22nd March 2010, 22:26   #459  |  Link
microchip8
ffx264/ffhevc author
 
microchip8's Avatar
 
Join Date: May 2007
Location: /dev/video0
Posts: 1,844
@ennob

No plan for version control. Project's too small and it's already easy

Also, upload the patch somewhere else as on here it can take some time before a mod approves the attachment
__________________
ffx264 || ffhevc || ffxvid || microenc
microchip8 is offline   Reply With Quote
Old 23rd March 2010, 11:55   #460  |  Link
ennob
Registered User
 
Join Date: Mar 2010
Posts: 3
here is the diff:

Code:
--- h264enc.orig        2010-03-17 15:30:11.000000000 +0100                    
+++ h264enc     2010-03-17 15:38:49.000000000 +0100                            
@@ -1099,7 +1099,7 @@                                                          
        }                                                                      
        trap 'interrupt_iso_func' SIGHUP SIGTSTP SIGINT SIGQUIT SIGKILL SIGABRT SIGFPE SIGSEGV SIGTERM SIGPIPE SIGIO
        check_space_func() {
-               HDSPACE="$(df -m "$(dirname "$OUTPUT")" | tail -n 1 | sed -r 's/^.*\s+[0-9]+\s+[0-9]+\s+([0-9]+)\s+[0-9]+%.*/\1/')"
+               HDSPACE="$(df -m "$(dirname "$OUTPUT")" | tail -n 1 | awk '{print $4}')"
                if [ $HDSPACE -le 9216 ]; then
                        echo ""
                        error "-> You are running out of disk space in '$(dirname "$OUTPUT")'"
@@ -2961,8 +2961,8 @@
 }

 check_diskspace_func() {
-       HDOUT="$(df -m "$(dirname "$OUTPUT")" | tail -n 1 | sed -r 's/^.*\s+[0-9]+\s+[0-9]+\s+([0-9]+)\s+[0-9]+%.*/\1/')"
-       HDCONF="$(df -m "$TEMPDIR" | tail -n 1 | sed -r 's/^.*\s+[0-9]+\s+[0-9]+\s+([0-9]+)\s+[0-9]+%.*/\1/')"
+       HDOUT="$(df -m "$(dirname "$OUTPUT")" | tail -n 1 | awk '{print $4}')"
+       HDCONF="$(df -m "$TEMPDIR" | tail -n 1 | awk '{print $4}')"
        if [ $HDOUT -le 4096 -o $HDCONF -le 4096 ]; then
                echo ""
                echo "Note that you are running out of disk space in"
ennob is offline   Reply With Quote
Reply

Tags
h264enc, ipod, mencoder, ps3, xbox360


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 17:25.


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