Tuesday, May 16, 2006

Testing ffmpeg cropping with a 13min clip

Encode 3 versions:
a. -croptop 350 then -s
b. -s then -croptop 350
c. no crop

Results: (a) is correct, (b) is very wrong. (a) is missing top pixels and stretched vertically to fit (expected), (b) is too small (720x144 even though -s specifies 720x480) and has horrid filler pixels at the bottom.

Need to crop more than 10 pixels off the top to remove extra digital tv signal stream (noise at top of screen). Try 20 pixels. [Actually 16 pixels off the top proved to be good]

[root@be scripts]# ffmpeg -y -i /mnt/progamer_goodCut.0000.mpg -r 29.97003 -
target dvd -b 8000 -croptop 20 -s 720x480 -deinterlace -copyts > -aspect 16:9 -acodec copy /mythtv/fatal1ty_ff-dvd-cropB4resize.mpg; > ffmpeg -y -i /mnt/progamer_goodCut.0000.mpg -r 29.97003 > -target dvd -b 8000 -s 720x480 -croptop 20 -deinterlace -copyts > -aspect 16:9 -acodec copy /mythtv/fatal1ty_ff-dvd-sizeB4crop.mpg; > ffmpeg -y -i /mnt/progamer_goodCut.0000.mpg -r 29.97003 > -target dvd -b 8000 -s 720x480 -deinterlace -copyts > -aspect 16:9 -acodec copy /mythtv/fatal1ty_ff-dvd-nocrop.mpg

FFmpeg version CVS, Copyright (c) 2000-2004 Fabrice Bellard
configuration: --prefix=/usr --libdir=/usr/lib --mandir=/usr/share/man --
enable-mp3lame --enable-libogg --enable-vorbis --enable-theora --enable-faad
bin --enable-xvid --enable-a52 --enable-a52bin --enable-pp --enable-shared -
-enable-pthreads --enable-dc1394 --enable-gpl --disable-strip --extra-cflags
=-O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -m32 -march=i386 -f
asynchronous-unwind-tables
libavutil version: 49.0.0
libavcodec version: 51.7.0
libavformat version: 50.3.0
built on Mar 1 2006 06:18:11, gcc: 3.4.4 20050721 (Red Hat 3.4.4-2)
Input #0, mpeg, from '/mnt/progamer_goodCut.0000.mpg':
Duration: 00:13:01.0, start: 20241.810111, bitrate: 17847 kb/s
Stream #0.0[0x1e0], 29.97 fps(r): Video: mpeg2video, yuv420p, 1920x1080, 1
8800 kb/s
Stream #0.1[0x80]: Audio: ac3, 48000 Hz, stereo, 384 kb/s
Assuming NTSC for target.
Output #0, dvd, to '/mythtv/fatal1ty_ff-dvd-cropB4resize.mpg':
Stream #0.0, 29.97 fps(c): Video: mpeg2video, yuv420p, 720x480, q=2-31, 80
00 kb/s
Stream #0.1: Audio: ac3, 48000 Hz, stereo, 384 kb/s
Stream mapping:
Stream #0.0 -> #0.0
Stream #0.1 -> #0.1
Press [q] to stop encoding
frame= 797 q=2.0 size= 13522kB time=26.2 bitrate=4221.5kbits/s

Tuesday, May 09, 2006

Encoding to Xvid instead of DVD

After much struggle with audio sync, found a thread that suggested '-async 50' and this worked.

[root@be mythtv]# ffmpeg -y -i /mnt/finland.0000.mpg -t 60 -vcodec xvid -vtag
xvid -s 320x180 -b 1500 -copyts -deinterlace -acodec mp3 -ab 128 -async 50
finland_ff-xvid-noGOP-noRate-async50-vcodecXvid_h2m.avi

FFmpeg version CVS, Copyright (c) 2000-2004 Fabrice Bellard
configuration: --prefix=/usr --libdir=/usr/lib --mandir=/usr/share/man
--enable-mp3lame --enable-libogg --enable-vorbis --enable-theora
--enable-faadbin --enable-xvid --enable-a52 --enable-a52bin --enable-pp
--enable-shared --enable-pthreads --enable-dc1394 --enable-gpl --disable-strip
--extra-cflags=-O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -m32
-march=i386 -fasynchronous-unwind-tables
libavutil version: 49.0.0
libavcodec version: 51.7.0
libavformat version: 50.3.0
built on Mar 1 2006 06:18:11, gcc: 3.4.4 20050721 (Red Hat 3.4.4-2)
Input #0, mpeg, from '/mnt/finland.0000.mpg':
Duration: 00:58:36.6, start: 31022.294233, bitrate: 17116 kb/s
Stream #0.0[0x1e0], 29.97 fps(r): Video: mpeg2video, yuv420p, 1920x1080,
65000 kb/s
Stream #0.1[0x80]: Audio: ac3, 48000 Hz, 5 channels, 384 kb/s
Output #0, avi, to 'finland_ff-xvid-noGOP-noRate-async50-vcodecXvid_h2m.avi':
Stream #0.0, 29.97 fps(c): Video: xvid, yuv420p, 320x180, q=2-31, 1500 kb/s
Stream #0.1: Audio: mp3, 48000 Hz, stereo, 128 kb/s

Larger size encoding (16:9):

# nice ffmpeg -y -i finland_px-tom2p.m2p -vcodec xvid -vtag
xvid -s 720x406 -b 2500 -copyts -deinterlace -acodec mp3 -ab 128
-async 50 finland_ff-xvid-720x406-async50-2500bps-vcodecXvid_px-tom2p.avi

Sadly, after encoding the whole 1hr show, the audio would get out of sync when there were the usual atsc glitches. Gave up on xvid. Stick with conversion to DVD compliant mpg.

HD2DVD process

cat howto/hd2dvd_process.txt

Look up nuv file with mythrecordings.py
[root@myth ~]# /home/donn/scripts/mythrecordings.py

Correct nuv file with projectx (this is my script to make running PX easier):
[root@be scripts]# ./projectx.sh /mythtv myfixednuv /mnt/1041_20060509003700_20060509013600.nuv

NOTE: use -tom2p option of projectx! Don't demux (has bugs with hidef context)

Script is basically:
/root/tmp_jre/jre1.5.0_06/bin/java
-jar /root/tmp/projectx_0_90_4_doom9/ProjectX_Source_0.90.4/ProjectX.jar
-tom2p -out "$OUTDIR" -name "$OUTNAME" "$INFILE"

PX creates: myfixednuv.m2p
m2p/mpg is MPEG PS (rather than TS) and playable with windows media player, etc.

Encode to DVD-compliant video with ffmpeg (copy audio stream at same time). This file can be played with mplayer, windows media player, etc.:
[root@be scripts]# ffmpeg -y -i myfixednuv.m2p -r ntsc -target dvd -b 8000
-s 720x480 -deinterlace -copyts
-aspect 16:9 -acodec copy /mythtv/mydvdcompliant.mpg

If source video is 4:3, use -aspect 4:3

Optionally, check dvd compliant .mpg with mplayer:
mplayer -vo dummy -ao dummy -identify /mythtv/mydvdcompliant.mpg 2>&1 | grep "VIDEO|AUDIO"

Play .mpg file with xine:
# xine -pfhq --no-splash file:/mythtv/mydvdcompliant.mpg

Note, atsc files inevitably have some dropouts (transmission glitches) and this caused mplayer to lose audio and then halt. Playing the same file in xine results in no problems (except the glitches themselves, of course).

Build DVD disc layout with dvdauthor (output dir is 'mydvd'):
dvdauthor -o mydvd -x dvd.xml

Where dvd.xml is:
<dvdauthor>
<vmgm />
<titleset>
<titles>
<audio lang="en" />
<pgc>
<vob file="mydvdcompliant.mpg" chapters="0,10:00,15:00,20:00" />
</pgc>
</titles>
</titleset>
</dvdauthor>

Or via CLI for scripting (two programs as back-to-back chapters):
dvdauthor -o /mythtv/dvd_mars_prague -t -a ac3+en -c 0,10:00,20:00,30:00,40:00,50:00 mars_px_ff-dvd.mpg -c 0,5:00,10:00,15:00,20:00 prague_px_ff-dvd.mpg

Build video_ts.ifo:
dvdauthor -o /mythtv/dvd_mars_prague/ -T

Together:
# dvdauthor -o dvd_concorde_paris -t -a ac3+en
-c 0,10:00,20:00,30:00,40:00,50:00 concorde_px_ff-dvd.mpg
-c 0,5:00,10:00,15:00,20:00 paris_px_ff-dvd.mpg;
dvdauthor -o dvd_concorde_paris -T

Play from hard drive with xine:
# xine -pfhq dvd:///mythtv/dvd_mars_prague/

Footnotes:
* Thanks to Mike Shell for pointing out another nuance of ffmpeg: If you crop or pad, the order is very important. It makes a difference if crop/pad is entered before (or after) setting the video size (-s 720x480).

* During all this hassling with ffmpeg, I tried other programs: mencoder, transcode, and tmpgenc (Windows). I can say with ease, that ffmpeg is light years faster than these other programs, and its speed (and quality) is the main reason I worked hard to get ffmpeg to work with my recordings. The ffmpeg command line is not so bad after you are fluent in it. And now I've reduced the number of options so the command is shorter. Actually, it's kinda fun reading the ffmpeg lines used by other people. Yeah, the geek that I am.

Scripts I wrote to automate the process:

Script for making .m2p file with projectx:


donn@fatso:~/scripts/root_scripts$ cat projectx.sh
#!/bin/bash

if [ $# -ne 3 ]; then
   echo 1>&2 "Usage: $0 outdir outname "
   exit 127
fi

OUTDIR="$1"
OUTNAME="$2"
INFILE="$3"

/root/tmp_jre/jre1.5.0_06/bin/java -jar /root/tmp/projectx_0_90_4_doom9/ProjectX_Source_0.90.4/ProjectX.jar -tom2p -out "$OUTDIR" -name "$OUTNAME" "$INFILE"

# Show user the aspect ratio.
mplayer -vo dummy -ao dummy -identify "${OUTDIR}/${OUTNAME}.m2p" 2>&1 | grep VIDEO


===
Script for converting .m2p file to DVD .mpg


donn@fatso:~/scripts/root_scripts$ cat convert_m2p.sh
#!/bin/bash

if [ $# -ne 3 ]; then
   echo 1>&2 "Usage: $0 src_dir outdir basename"
   echo 1>&2 " $0 /mnt/nfs /mythtv leno_clip"
   echo 1>&2 " if srcfile is /mnt/nfs/leno_clip.m2p"
   exit 127
fi

date

SRCDIR="$1"
OUTDIR="$2"
OUTNAME="$3"

# Get AR.

ASPECTTMP=`mplayer -vo dummy -ao dummy -identify "${SRCDIR}/${OUTNAME}.m2p" 2>&1 | egrep VIDEO\_ASPECT`
#echo $ASPECTTMP
# This ($ASPECTTMP2) is 1.3333 or 1.777
ASPECTTMP2=`expr match "$ASPECTTMP" '[=_A-Z]\+\(.\+\)'`
echo "Numerical aspect is $ASPECTTMP2"
# Keep only '[0-9].[0-9]'
ASPECTNUM=`expr match "$ASPECTTMP2" '\([0-9]\.[0-9]\)'`
# ASPECTNUM is "1.3" or "1.7"
#echo $ASPECTNUM

if [ $ASPECTNUM == "1.3" ]; then
   ASPECT="4:3"
else
   ASPECT="16:9"
fi
echo "Aspect ratio is $ASPECT"

echo "Running ffmpeg."
echo "Input is : ${SRCDIR}/${OUTNAME}.m2p"
echo "Outputting: ${OUTDIR}/${OUTNAME}_ff-dvd.mpg"

nice ffmpeg -y -i "${SRCDIR}/${OUTNAME}.m2p" -r ntsc -target dvd -b 2048k \
-s 720x480 -deinterlace -copyts \
-aspect $ASPECT -acodec copy "${OUTDIR}/${OUTNAME}_ff-dvd.mpg"

date


Poor quality video (lots of blockiness):

From the ffmpeg docs:

"The parameter 'q' which is displayed while encoding is the current quantizer. The value 1 indicates that a very good quality could be achieved. The value 31 indicates the worst quality. If q=31 appears too often, it means that the encoder cannot compress enough to meet your bitrate. You must either increase the bitrate, decrease the frame rate or decrease the frame size."

For target type 'dvd', this gave q of 5-10 (for a HD recording):

-target dvd -b 2048k

More tips from the ffmpeg docs:


* To have a constant quality (but a variable bitrate), use the option '-qscale n' when 'n' is between 1 (excellent quality) and 31 (worst quality).
* When converting video files, you can use the '-sameq' option which uses the same quality factor in the encoder as in the decoder. It allows almost lossless encoding.


Using -qscale instead of -b: Found blog that said best (best tradeoff of quality to filesize) qscale numbers are 5, 9, 11. [ http://www.kilobitspersecond.com/2007/05/24/ffmpeg-quality-comparison/ ]

Good audio sync AND no buffer underflows

It took a lot of testing, sheesh. But finally...

The following resulted in good quality video and no underflow errors, but audio sync was way off (video lagged):

# ffmpeg -y -i /mythtv/finland_px.m2v -r ntsc -target dvd
-b 3000 -s 720x480 -copyts -aspect 16:9 /mythtv/finland_ff_px.mpg

Problem is that duration of show is incorrect!

Input #0, mpegvideo, from '/mythtv/finland_px.m2v':
Duration: 01:40:23.6, start: 0.000000, bitrate: 8999 kb/s
Stream #0.0, 29.97 fps(r): Video: mpeg2video, yuv420p, 1920x1080, 9000 kb/s
Assuming NTSC for target.
Output #0, dvd, to '/mythtv/finland_ff-deinterlaced_px.mpg':
Stream #0.0, 29.97 fps(c): Video: mpeg2video, yuv420p, 720x480, q=2-31, 3000 kb
/s
Stream mapping:
Stream #0.0 -> #0.0
Press [q] to stop encoding

ffmpeg reports that duration is "Duration: 01:40:23.6" which is not correct for this 1 hour show. Perhaps ProjectX is miscalculating the length of the video, and note that bitrate is capped at 8999. This explains why video was lagging badly, it was playing 1hr of video over a period of 1:40:23! Slooooooow....

mplayer agrees that length is 01:40:

# mplayer -vo dummy -ao dummy -identify finland_px.m2v 2>&1
Playing finland_px.m2v.
MPEG-ES file format detected.
ID_VIDEO_ID=0
VIDEO: MPEG2 1920x1080 (aspect 3) 29.970 fps 9000.0 kbps (1125.0 kbyte/s)
ID_FILENAME=finland_px.m2v
ID_VIDEO_FORMAT=0x10000002
ID_VIDEO_BITRATE=9000000
ID_VIDEO_WIDTH=1920
ID_VIDEO_HEIGHT=1080
ID_VIDEO_FPS=29.970
ID_VIDEO_ASPECT=1.7778
ID_LENGTH=6023

6023/60 is 100.38m = 1hr 40m 23s! This means ProjectX is putting wrong duration in the m2v file. Maybe we can hexedit the value in the file somewhere? Maybe there's more PX command line options to try? Who knows.

Also note "Input #0, mpegvideo", which differs from "Input #0, mpeg" in the hdtvtompeg2 example below.

UPDATE: Found this on myth-users (will try next):
> don't demux with projectX, it has problems with its demux code and
> theres really no reason to demux with it, just output with --tom2p
> which will output a PS stream with proper audio sync.

UPDATE2: -tom2p option works. When feeding px .m2p to ffmpeg, ffmpeg now reports correct duration and bitrate:
Input #0, mpeg, from 'finland_px-tom2p.m2p':
Duration: 00:58:54.7, start: 38287.531567, bitrate: 16765 kb/s
Stream #0.0[0x1e0], 29.97 fps(r): Video: mpeg2video, yuv420p, 1920x1080, 65000 kb/s

Next try using hdtvtompeg2 file as the source file. This time duration is correct (00:58:36). Note, audio processing is done simultaneously so there's no muxing later:

# ffmpeg -y -i /mnt/finland.0000.mpg -t 600 -r ntsc -target dvd
-b 3000 -s 720x480 -deinterlace -copyts -aspect 16:9
-acodec copy /mythtv/fin-ff-h2m.mpg

(-t 600 for a 10min test clip)

Input #0, mpeg, from '/mnt/finland.0000.mpg':
Duration: 00:58:36.6, start: 31022.294233, bitrate: 17116 kb/s
Stream #0.0[0x1e0], 29.97 fps(r): Video: mpeg2video, yuv420p, 1920x1080, 65000
kb/s
Stream #0.1[0x80]: Audio: ac3, 48000 Hz, 5 channels, 384 kb/s
Assuming NTSC for target.
Output #0, dvd, to '/mythtv/fin-ff-h2m.mpg':
Stream #0.0, 29.97 fps(c): Video: mpeg2video, yuv420p, 720x480, q=2-31, 3000 kb
/s
Stream #0.1: Audio: ac3, 48000 Hz, 5 channels, 384 kb/s
Stream mapping:
Stream #0.0 -> #0.0
Stream #0.1 -> #0.1
Press [q] to stop encoding

Note how bitrate is now much higher (17116 kbps, and 65000 kbps). This is likely the correct bitrate. And in fact, it worked. Audio/video sync was perfect.

Maybe there's a way to use the -b option with -i (the input file). Maybe force format to mpeg instead of 'mpegvideo' with -f mpeg?

-f mpeg did not work with PX m2v file:

[root@be mythtv]# ffmpeg -y -f mpeg -i /mythtv/finland_px.m2v -r ntsc -target dvd
-b 3000 -s 720x480 -copyts -aspect 16:9 /mythtv/finland_force_ff_px.mpg
FFmpeg version CVS, Copyright (c) 2000-2004 Fabrice Bellard
libavutil version: 49.0.0
libavcodec version: 51.7.0
libavformat version: 50.3.0
built on Mar 1 2006 06:18:11, gcc: 3.4.4 20050721 (Red Hat 3.4.4-2)
Input #0, mpeg, from '/mythtv/finland_px.m2v':
Duration: N/A, bitrate: N/A
Assuming NTSC for target.
No audio or video streams available

-b 65000 did not work on m2v file:

ffmpeg -y -b 65000 -i /mythtv/finland_px.m2v -t 60 -r ntsc ...
"Duration: 01:40:23.6, start: 0.000000, bitrate: 8999 kb/s"

Sunday, May 07, 2006

HDTVtoMPEG2 instead of projectx

ProjectX has problems with the conan_finland show, so tried hdtvtompeg2 (windows). Made public samba share. Symlinked to .nuv file, named symlink foo.nuv. Convert to finland.0000.mpg (mpeg2) with hdtvtompeg2. Xfer to FE. then:

# ffmpeg -y -i finland.0000.mpg -pass 1 -passlogfile fin_passfile
-target dvd -s 720x480 -deinterlace -r 30000/1001 -b 3200
-minrate 1500 -maxrate 7000 -aspect 16:9 -bufsize 8192
-acodec copy fin_h2m.mpg

Problem was that there were lots of 'buffer underflow' messages and video/audio sync was off. Later, I looked at how mytharchive runs ffmpeg and followed its ffmpeg cli options to the tee. Seems that the -copyts option might do the trick.

Then dvdauthor.
(don't need to mplex since we are processing audio with the video (-acodec copy)

Upgraded ffmpeg & projectx

After getting lots of buffer underflow errors, upgraded ffmpeg to latest version. Had to use ATrpms repository and comment out DAG repository.

UPDATE: Using latest versions of ffmpeg & px did not help the underflow errors.

[root@be yum.repos.d]# ffmpeg -version
FFmpeg version CVS, Copyright (c) 2000-2004 Fabrice Bellard
configuration: --prefix=/usr --libdir=/usr/lib --mandir=/usr/share/man --enable-mp3lame --enable-libogg --enable-vorbis --enable-theora --enable-faadbin --enable-xvid -
-enable-a52 --enable-a52bin --enable-pp --enable-shared --enable-pthreads --enable-dc1394 --enable-gpl --disable-strip --extra-cflags=-O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOU
RCE=2 -fexceptions -m32 -march=i386 -fasynchronous-unwind-tables
libavutil version: 49.0.0
libavcodec version: 51.7.0
libavformat version: 50.3.0
built on Mar 1 2006 06:18:11, gcc: 3.4.4 20050721 (Red Hat 3.4.4-2)
ffmpeg CVS
libavutil 3211264
libavcodec 3344128
libavformat 3277568

===
Got new projectx zip file from doom9. Now run as:
# /root/tmp_jre/jre1.5.0_06/bin/java -jar /root/tmp/projectx_0_90_4_doom9/ProjectX_Source_0.90.4/ProjectX.jar -out /mythtv -name finland_newpx_demux /mnt/1039_20060311003700_20060311013600.nuv

Saturday, May 06, 2006

Script that shows all recordings titles, filenames

Full-text version of this script is at:
http://www.donnlee.com/static/mythtv/mythrecordings.py.txt

#!/usr/bin/python

import sys
import re
import MySQLdb

MYTHDIR = '/mythtv/recordings'

def GetSQLdict(sql):
try:
db = MySQLdb.Connect(host="localhost", port=3306, user="root", passwd=
"mypass", db="mythconverg")
c=db.cursor(MySQLdb.cursors.DictCursor)
except:
return 'FAILED'
# Execute the SQL query.
try:
c.execute(sql)
except:
return 'FAILED'
# Get results as a dictionary. Column names are dict keys.
Results = c.fetchall()
db.close()
return Results

sql = "SELECT chanid,starttime,endtime,title,subtitle,description FROM recor
dedprogram order by starttime desc"
Results = GetSQLdict(sql)

for r in Results:
chanid = r['chanid']
starttime = str(r['starttime'])
endtime = str(r['endtime'])
title = r['title']
subtitle = r['subtitle']
description = r['description']

# Remove hyphen, colon, space, and '.00' from time values.
p_starttime = re.sub(r'[-: ]|\.00', '', starttime)
p_endtime = re.sub(r'[-: ]|\.00', '', endtime)

f = '%s/%s_%s_%s.nuv' % (MYTHDIR, chanid, p_starttime, p_endtime)

print '%s' % starttime
print "%s - %s" % (title, subtitle)
print description
print f
print

# End.

Friday, May 05, 2006

ATSC to HDTV without any GUI's (ffmpeg)

So converting to DVD works fine with avidemux2, except for the fact that when I use "DVD (lavcodec)" the video file is too small and the video quality sucks rocks. My goal is to go 100% non-gui: Abandon avidemux2 because it is heavily GUI dependent. It does have a command line mode, but I can't figure it out, and even if I did, cli mode still requires X11 and gtk for some reason.

Since I'm really running avidemux to use ffmpeg, why not just use ffmpeg instead of avidemux? Sounds like a decent plan. So here goes...

After much reading of ffmpeg, I settled on the following ffmpeg procedure:

Do two pass encoding where the first pass is:

nice ffmpeg -y -hq -i mars_demux.m2v -pass 1 -passlogfile mars_rate7500_passfile -target dvd -s 720x480 -deinterlace -r 30000/1001 -b 3200 -minrate 1500 -maxrate 7500 -aspect 4:3 -bufsize 4096 mars_out.mpg

After this completes, repeat the same command but with "-pass 2".

Explanation of ffmpeg options I used:
-y: Overwrite existing files (don't prompt user).
-hq: Enable high-quality mode (uh, sure, sounds good).
-i mars_demux.m2v: This is the video file produced when running the .nuv file thru ProjectX.
-pass 1: This is the first pass of two passes.
-passlogfile mars_rate7500_passfile: Specifies the file to write/read first pass data.
-target dvd: We want DVD formatted video to be outputted.
-s 720x480: Output will be standard DVD resolution (NTSC).
-deinterlace: We want progressive scan, not interlaced.
-r 30000/1001: Set frame rate to 29.97 ('-r 29.97' or '-r ntsc' should also work).
-b 3200: Set video bitrate to 3200kbps. Lower this if getting buffer underflow msgs.
-minrate 1500: Set min data rate to 1500kbps (VBR video).
-maxrate 7500: Set max data rate to 7500kbps. Max allowed by DVD spec is 9800, but probably wise to go no higher than 9000. There's a ffmpeg bug that might still exist that causes problems with high rates, http://www.transcoding.org/cgi-bin/transcode?DVtoDVD
-aspect 4:3 : This is the aspect ratio of the source video. This show was not widescreen. If it was then I would do -aspect 16:9.
-bufsize 4096 : This sets the DVD rate control buffer size (may not be needed but some examples I saw set this, and it seems reasonable to me). Seems to be a standard value of 224kb, but I got 'buffer underflow' error messages, so increased it to 1840. This was ok on a non-hidef show, but not enough for HD. So 4096. But this did not stop the buffer underflow errors either, so upgraded ffmpeg to a newer version.
mars_out.mpg: The name of the outputted DVD video.

Here's the output

ffmpeg version 0.4.9-pre1, build 4730, Copyright (c) 2000-2004 Fabrice Bellard
configuration: --host=i686-redhat-linux-gnu --build=i686-redhat-linux-gnu --target=i386-redhat-linux --program-prefix= --prefix=/usr --exec-prefix=/usr --bindir=/usr/bin --sbindir=/usr/sbin --sysconfdir=/etc --datadir=/usr/share --includedir=/usr/include --libdir=/usr/lib --libexecdir=/usr/libexec --localstatedir=/var --sharedstatedir=/usr/com --mandir=/usr/share/man --infodir=/usr/share/info --extra-cflags=-O2 -march=i386 -mcpu=i686 --enable-mp3lame --enable-vorbis --enable-faad --enable-faac --enable-xvid --enable-pp --enable-shared-pp --enable-shared --enable-gpl --disable-strip
built on Jan 15 2005 14:50:54, gcc: 3.4.2 20041017 (Red Hat 3.4.2-6.fc3)
Input #0, mpegvideo, from 'mars_demux.m2v':
Duration: N/A, bitrate: N/A
Stream #0.0: Video: mpeg2video, 704x480, 29.97 fps
Assuming NTSC for target.
File 'mars_rate7500_ffmpeg.mpg' already exists. Overwrite ? [y/N] y
Output #0, dvd, to 'mars_rate7500_ffmpeg.mpg':
Stream #0.0: Video: mpeg2video (hq), 720x480, 29.97 fps, q=2-31, pass 1, 6000 kb/s
Stream mapping:
Stream #0.0 -> #0.0
[mpeg2video @ 0x5edce30]Warning min_rate > 0 but min_rate != max_rate isnt recommanded!
Press [q] to stop encoding
frame=40458 q=0.0 size= 739888kB time=1349.9 bitrate=4490.0kbits/s

Ignore the message "Warning min_rate > 0 but min_rate != max_rate isnt recommanded". http://www.cdr-zone.com/forum/about2271.html

Some insight to why the recorded source is 704x480 instead of 720x480 I found in this page:

"The 720-pixel-wide DV frame is actually slightly wider than the 720-pixel-wide DVD-Video frame--technically, the two formats have a slightly different pixel aspect ratio, and therefore display aspect ratio--so that if you encode DV directly to DVD without changing the size, the image will be slightly "squished" horizontally. The difference is small enough that it's usually not visible, but if you want to get the correct aspect ratio, you can clip 16 pixels from the left and/or right borders to get a 704-pixel-wide frame, which is also legal for DVDs. In particular, TV broadcasts often have thin black bars at the left and right due to the frame size difference, and clipping these off will also improve encoding quality. (For these reasons, it is also preferable to clip the video frame before resizing when using half-width or half-width/half-height video.)"

So next time I could try adding padding to the left/right with the following ffmpeg options:

-padleft 8 -padright 8

and that would make the source 720 pixels wide. This would probably remove any aspect ratio distortion introduced by going from 704 to 720. Probably worth a test run and a good test would be to set the padding color to something noticable like red:

-padcolor FF0000

I tried running with "-qscale 1" and got horrible buffer underflow error messages. So I went with the -maxrate, -minrate params instead. Later, I found a posting that said you have to set '-qmin 1' when doing '-qscale 1', but I never bothered trying it.


5/9/2006:
The sdtv programs were fine with this procedure, but when trying HD Late Night show, I would get many underflow errors though I searched and tried various adjustments of -b -minrate -maxrate -qmin -qmax -bufsize and probably a couple others. I posted to ffmpeg-user list for help, then had this idea to look at the mytharchive code for how it runs ffmpeg. This led to a new direction:

I found a possible solution, a new switch "-copyts" from mythburn/mytharchive and a simpler/reduced command line. So:

[root@be ~]# ffmpeg -y -i /mnt/finland.0000.mpg -r ntsc -target dvd -b 3000
-s 720x480 -copyts -aspect 16:9 /mythtv/finland_mytharchive2.mpg

Where finland.0000.mpg was created from hdtvtompeg2 (but could have used .m2v for inputfile just the same). The encoding finished without the underflow errors.


Sadly, the resulting mpeg file from ffmpeg cannot be muxed with mplex. So, I simply ran projectx on the resulting mpeg to produce a new .m2v (pass2.m2v), then mplex'd it:

mplex -f 8 -V -o mars_final.mpg mars_demux.ac3 pass2.m2v

Then, used dvdauthor on this .mpg file.

If this info helped you or saved you valuable time, please consider linking to this site as a favor.

Wednesday, May 03, 2006

ProjectX, avidemux2, HDTV to DVD encode HOWTO

Issue: PC with fastest CPU has low-resolution plasma (it's the myth frontend). Need high res monitor.
Fix: use 'ssh -Y myfrontend' and remotely view X11 apps on a hi res monitor. Don't do 'ssh -X' with gtk apps like avidemux. You'll get error:

The program 'avidemux2' received an X Window System error.
The error was 'BadWindow (invalid Window parameter)'.

Use projectx in command line mode to demux mythtv .nuv file. This also corrects audio sync and other minor errors commonly found in OTA atsc recordings.

cd ~/tmp_jre/jre1.5.0_06/bin
# ./java -jar ~/tmp3/ProjectX_Source_0.90.3/ProjectX.jar -out /mythtv -name scrubs_demux /mnt/1041_20060425210000_20060425213000.nuv
(/mnt is nfs mount of the backend's recordings dir)

To find the .nuv files and map them to human names like 'Tonight Show with Jay Leno', use the mythls script blogged earlier.

projectx will give you audio and video files:

-rw-r--r-- 1 root root 42732288 May 2 16:09 scrubs_demux.ac3
-rw-r--r-- 1 root root 4055 May 2 16:09 scrubs_demux_log.txt
-rw-r--r-- 1 root root 2230187930 May 2 16:09 scrubs_demux.m2v

We need to convert (encode) the video/m2v file to DVD standard resolution with avidemux2.

Issue: Using avidemux2 with hdtv results in avidemux's window being so large that you can't see the bottom portion where the navigation/cutting controls are.
Fix: Make a large 2667x2000 virtual desktop in your xorg.conf. I did this:

SubSection "Display"
Viewport 0 0
Depth 16
Modes "1024x768" "800x600" "640x480"
Virtual 2667 2000
EndSubSection

I tried to run avidemux2 in cli mode, but gave up and tried gui mode first.

It wouldn't run because it requires X11 and GTK2 (gtk+). And that requires X11 forwarding over ssh and that failed because I was missing ssh switch '-X' and that failed because gtk apps need ssh switch '-Y'. sheesh. anyway, run avidemux gui. Then followed this guide:

http://forum.videohelp.com/viewtopic.php?t=242455

Optionally, check the video info for the file created by avidemux2:

[root@be mythtv]# mplayer -vo dummy -ao dummy -identify scrubs_avidemuxOutput 2>&1 | grep VIDEO
ID_VIDEO_ID=0
VIDEO: MPEG2 720x480 (aspect 3) 29.970 fps 7800.0 kbps (975.0 kbyte/s)
ID_VIDEO_FORMAT=0x10000002
ID_VIDEO_BITRATE=7800000
ID_VIDEO_WIDTH=720
ID_VIDEO_HEIGHT=480
ID_VIDEO_FPS=29.970
ID_VIDEO_ASPECT=1.7778

Mux the audio and video files to a single .mpg:

# mplex -f 8 -V -o scrubs.mpg scrubs_demux.ac3 scrubs_avidemuxOutput

Author a basic dvd:
dvdauthor -o dvd -x dvd.xml

Where .xml is:
<dvdauthor>
<vmgm />
<titleset>
<titles>
<audio lang="en" />
<pgc>
<vob file="scrubs.mpg" chapters="0,10:00,15:00,20:00" />
</pgc>
</titles>
</titleset>
</dvdauthor>

Or you could do two titles on one disc:

<titles>
<video widescreen="nopanscan" />
<pgc>
<vob file="source-1.mpg" chapters="0,0:30,1:00,1:30,2:30,3:00,3:30,4:00"/>
<post> jump title 2; </post>
</pgc>

<pgc>
<vob file="source-2.vob" chapters="0,0:30,1:00,1:30,2:30,3:00,3:30,4:00"/>
<post> call menu; </post>
</pgc>
</titles>

The above has some more advanced dvd authoring tags. See:
http://gentoo-wiki.com/HOWTO_Create_a_DVD:Filesystem

Good output of dvdauthor:

[root@be mythtv]# dvdauthor -o mars_dvd -x dvd_mars.xml
DVDAuthor::dvdauthor, version 0.6.11.
Build options: gnugetopt magick iconv freetype fribidi
Send bugs to

INFO: Locale=en_US.UTF-8
INFO: Converting filenames to UTF-8
INFO: dvdauthor creating VTS
STAT: Picking VTS 01

STAT: Processing mars.mpg...
STAT: VOBU 8560 at 640MB, 1 PGCS
INFO: Video pts = 0.178 .. 3594.568
INFO: Audio[0] pts = 0.178 .. 3594.706
STAT: VOBU 8562 at 641MB, 1 PGCS
INFO: Generating VTS with the following video attributes:
INFO: MPEG version: mpeg2
INFO: TV standard: ntsc
INFO: Aspect ratio: 16:9
INFO: Resolution: 720x480
INFO: Audio ch 0 format: ac3/2ch, 48khz drc

STAT: fixed 8562 VOBUS
INFO: dvdauthor creating table of contents
INFO: Scanning mars_dvd/VIDEO_TS/VTS_01_0.IFO


Play dvd from hard drive:
mplayer dvd:// -dvd-device ./dvd -fs -zoom -vo xv -ao alsa:device=hw=1.0
or
mplayer dvd://1 -dvd-device ./dvd -fs -zoom -monitoraspect 16:9 -vo xv -ao alsa:device=digital2c -aid 128

Instead of "-aid 128" can also try "-alang en"
Your alsa device will be different than mine.

Normally my dvd device is "-dvd-device /dev/hdb" (dvdrom drive).

Versions:

[root@be ~]# rpm -qa | grep gtk
gtkhtml2-2.6.2-1
gtk+-1.2.10-33
gtk2-2.4.14-4.fc3.3
gnome-python2-gtkhtml2-2.6.0-3
gtk2-devel-2.4.14-4.fc3.3
usermode-gtk-1.74-1
gtk+-devel-1.2.10-33
pygtk2-2.4.0-1
authconfig-gtk-4.6.5-3.1
pygtk2-libglade-2.4.0-1
gtkspell-2.0.7-2

[root@be ~]# rpm -qa | grep avidemux
avidemux2-2.0.40-1.1.fc3.rf

[root@be ~]# rpm -qf /usr/bin/mplex
mjpegtools-1.6.2-4.1.fc3.rf

[root@be ~]# rpm -qf /usr/bin/dvdauthor
dvdauthor-0.6.11-1.1.fc3.rf

I tried to compile the latest avidemux2, but it required gtk 2.6 and I couldn't find a good yum package for gtk 2.6 on Fedora Core 3. So just went back to using this yum version of avidemux2 (from DAG).

References:
http://www.linux.com/article.pl?sid=06/04/17/2058219
http://www.linuxquestions.org/questions/showthread.php?s=&postid=1228258
http://forum.videohelp.com/viewtopic.php?t=242455

Compiling avidemux2 from source

From website:
make -f Makefile.dist
./configure
make

'configure' got error:
checking for pkg-config... /usr/bin/pkg-config
Package gtk+-2.0 was not found in the pkg-config search path.
Perhaps you should add the directory containing `gtk+-2.0.pc'
to the PKG_CONFIG_PATH environment variable
No package 'gtk+-2.0' found
************ Cannot identify gtk2 version ***************
configure: error: *** pkg-config installed incorrectly or gtk2-dev absent !
***

Installed gtk2-dev:
# yum install gtk2-devel

Reran configure, got error:
checking for pkg-config... /usr/bin/pkg-config
configure: error: *** need gtk+ v2.6 or greater ! ***

Couldn't find a yum package for gtk2-devel-2.6.

Tuesday, May 02, 2006

Avidemux2 (processing after projectx)

ssh with X forwarding (even using cli, must have X11 and gtk running):

ssh -X myhost.mydomain.com
(test with xclock & )

Process video only:

# avidemux2 --load scrubs_demux.m2v --video-codec DVD --video-conf cq=10 --video-process --save avidemuxOutput_dvd.m2v --quit

Handling ProjectX output files

> There's a really good program called ProjectX it's a java app with fixes
> most errors in av sync'ing .It hasn't failed to work on eveything I have
> thrown at it .once I get the output from Project X I use Avidemux2 to edit
> and re-encode to what ever format needed.

Another poster:

> I use ProjectX to tidy up and edit (out the commercials) these problem
> recordings.
>
> http://sourceforge.net/projects/project-x
>
> Then I use ffmpeg at the command line to transcode.

And:

avidemux2 --load yourfile.nuv --video-codec DVD --video-conf cq=10 --video-process --save foo_dvd.m2v --quit

And:

With ProjectX, from an input .mpg file, I generated an output .m2v and .mp2 files. I used these two ProjectX files as an input to Avidemux. I was then able to edit/remux the audio & video files with avidemux, and this time retain audio/video synchronisation. My edit/cut was successfully made in between two keyframes (where as before, using only avidemux on the original .mpg file gave me an audio/video desync problem). Impressive!

Demux and fix audio sync with ProjectX

[root@be mnt]# cd -
/root/tmp_jre/jre1.5.0_06/bin
[root@be bin]# ./java -jar ~/tmp3/ProjectX_Source_0.90.3/ProjectX.jar > -demux -out /mythtv -name scrubs_demux /mnt/1041_20060425210000_20060425213000.nuv
Reading GUI-Switch...
Reading Help Switch...
Reading Config File Switch...
Start without GUI...
Loading last Config or Standard File...
Loading Language -> 'en'

ProjectX 0.90.3.00/31.12.2005 TEST PROJECT ONLY , User: root


TERMS AND CONDITIONS:
(1) this is a free Java based demux utility.
(2) It is intended for educational purposes only, as a non-commercial test project.
(3) released under the terms of the GNU GPL.
(4) there is NO WARRANTY of any kind attached to this software.
(5) use it at your own risk and for your own education.

Java Environment
May 2, 2006 4:03:47 PM PDT
java.version 1.5.0_06
java.vendor Sun Microsystems Inc.
java.home /root/tmp_jre/jre1.5.0_06
java.vm.version 1.5.0_06-b05
java.vm.vendor Sun Microsystems Inc.
java.vm.name Java HotSpot(TM) Client VM
java.class.vers 49.0
java.class.path /root/tmp3/ProjectX_Source_0.90.3/ProjectX.jar
os.name Linux
os.arch i386
os.version 2.6.9-1.667
ini.file /root/tmp_jre/jre1.5.0_06/bin/X.ini
ext.disk.access disabled or library not found
user.language en
user.name root
user.home /root

quick CL usage:
Note: CL doesn't load the GUI components, except with switch [-gui]
...starts the GUI
switches and inputfiles can be in any order

options:
[-ini ] ..use that specified iniFile instead of the standard
[-dvx1] ..create a .d2v ProjectFile on demux
[-dvx2] ..create a .d2v ProjectFile + .ac3.wav (RIFF WAVE Header)
[-dvx3] ..create a .d2v ProjectFile + .mpa.wav (RIFF WAVE Header)
[-dvx4] ..create a .d2v ProjectFile + .ac3.wav + mpa.wav (RIFF WAVE Header)
[-out ] ..use that specified directory for output
[-name ] ..use that specified filename for output
[-cut ] ..use that text based file as cutpoint list
[-chp ] ..use that text based file as chapterpoint list
[-id ] ..use only these (P)IDs, separated by comma ","
[-gui] ..display the GUI using all given CLI options
[-log] ..write the normal logfile
[-saveini] ..save changes made bei CLI in active .ini
[-split ] ..split output at xxx MB
[-demux, -tom2p, -topva, -tovdr, -tots, -filter] ..action types

Loading Basic Classes...
Reading CLI Switches...
Checking Commons-Net library access...
Loading AC3 frames...
Starting Collection Process...
preparing collection(s)...
1 %Tuesday, May 2, 2006 4:03:48 PM PDT
ProjectX 0.90.3.00 (31.12.2005)

<<< session infos >>>

-> working with collection 0

-> save normal log file
-> write all video data
-> write all other data
-> patch c.d.flagged infos of pictures
-> add sequence end code
-> set resolution in SDE
-> PVA: strictly specs. for audio streams
-> VOB: determine diff. Cell timelines
-> TS: ignore scrambled packets
-> TS: enhanced search for open packets
-> TS: join file segments (of Dreambox®)
-> TS: generate PMT stream dependent
-> get only enclosed PES/TS packets
-> concatenate different recordings
-> ensure 1st PES-packet start with video
-> generate PCR/SCR from PTS

-> write output files to: '/mythtv'

-> Input File 0: '/mnt/1041_20060425210000_20060425213000.nuv' (2,345,324,440 bytes)
-> Filetype is TS (generic PES Container)
-> demux
-> Service ID 0x1
-> PMT 0x10 refers to these usable streams:
Video:
n/a
Audio:
n/a
Teletext:
n/a
Subpict.:
n/a

demuxing DVB MPEG-TS file 1041_20060425210000_20060425213000.nuv
--> PID 0x0 (PAT) (0 #1) -> ignored
--> PID 0x10 (PMT) (188 #2) -> ignored
ok> PID 0x31 has PES-ID 0xE0 (MPEG Video) (376 #3)
ok> PID 0x34 has PES-ID 0xBD (private stream 1) (190068 #1012)
-> video basics: 1920*1080 @ 29.97fps @ 0.7031 (16:9) @ 10957600bps, vbvBuffer 222
-> starting export of video data @ GOP# 0
!> dropping useless B-Frames @ GOP# 0 / new Timecode 00:00:00.000
9 %!> dropping GOP# 309 @ orig.PTS 06:37:12.030 (2144882778)
-> Pics exp/cnt 15/15, inGOP PTS diff. 100ms, new Timecode 00:02:34.587
!> dropping GOP# 310 @ orig.PTS 06:37:12.664 (2144939835)
-> Pics exp/cnt 15/15, inGOP PTS diff. 83ms, new Timecode 00:02:34.587
!> dropping GOP# 311 @ orig.PTS 06:37:13.282 (2144995390)
-> Pics exp/cnt 15/15, inGOP PTS diff. 100ms, new Timecode 00:02:34.587
!> PTS difference of 171171 (00:00:01.901) to last exported GOP detected
!> dropping useless B-Frames @ GOP# 312 / new Timecode 00:02:34.587
10 %!> dropping GOP# 373 @ orig.PTS 06:37:44.429 (2147798691)
-> Pics exp/cnt 15/15, inGOP PTS diff. 83ms, new Timecode 00:03:05.051
!> dropping GOP# 374 @ orig.PTS 06:37:45.047 (2147854246)
-> Pics exp/cnt 15/15, inGOP PTS diff. 83ms, new Timecode 00:03:05.051
!> dropping GOP# 375 @ orig.PTS 06:37:45.664 (2147909802)
-> Pics exp/cnt 15/15, inGOP PTS diff. 100ms, new Timecode 00:03:05.051
!> dropping GOP# 376 @ orig.PTS 06:37:46.298 (2147966859)
-> Pics exp/cnt 15/15, inGOP PTS diff. 33ms, new Timecode 00:03:05.051
!> PTS difference of 216216 (00:00:02.402) to last exported GOP detected
!> dropping useless B-Frames @ GOP# 377 / new Timecode 00:03:05.051
70 %!> dropping GOP# 2527 @ orig.PTS 06:55:42.957 (2244866161)
-> Pics exp/cnt 15/15, inGOP PTS diff. 100ms, new Timecode 00:21:01.061
!> dropping GOP# 2528 @ orig.PTS 06:55:43.591 (2244923218)
-> Pics exp/cnt 15/15, inGOP PTS diff. 83ms, new Timecode 00:21:01.061
!> dropping GOP# 2529 @ orig.PTS 06:55:44.208 (2244978774)
-> Pics exp/cnt 15/15, inGOP PTS diff. 100ms, new Timecode 00:21:01.061
!> PTS difference of 171171 (00:00:01.901) to last exported GOP detected
!> dropping useless B-Frames @ GOP# 2530 / new Timecode 00:21:01.061
101 %packs: 12418057 100% 2345324440

-> Video: fr/ ct/ 1p/ cg/ og/ dg -> 53362/ 12/ 0/ 3558/ 0/ 10
-> Video length: 53362 frames @ 00:29:40.510
-> GOP summary: min. 26, max. 30 fields; contains interlaced & progressive frames
-> avg. nom. bitrate 10020434bps (min/max: 1488400/14322400)
-> set first sequenceheader bitrate to 9000000bps
---> new File: /mythtv/scrubs_demux.m2v

--> AC-3/DTS Audio on PID 0x34
check & synchronize audio file scrubs_demux.ac
1 %-> check CRC of AC-3 / MPEG-Audio L1,2
-> delete CRC in MPEG-Audio Layer1,2
-> add frames
Audio PTS: first packet 06:34:37.132, last packet 07:04:24.332
Video PTS: start 1.GOP 06:34:37.409, end last GOP 07:04:24.328
-> adjusting audio at video-timeline
-> src_audio: AC-3, CM, 1/0(1.0), dn -27dB, 48000Hz, 192kbps @ 00:00:00.000
101 %audio frames: wri/pre/skip/ins/add 55641/0/0/0/0 @ 00:29:40.512 done...
---> new File: '/mythtv/scrubs_demux.ac3'

summary of created media files:
.Video (m2v): 53362 Frames 00:29:40.510 '/mythtv/scrubs_demux.m2v'
Audio 0 (ac3): 55641 Frames 00:29:40.512 0/0/0/0 '/mythtv/scrubs_demux.ac3'
=> 2,272,920,218 bytes written...
-> we have 17 warnings/errors.
done... 1 collection(s) processed @ 00:05:41.806

[root@be bin]#

avidemux2 scripting options

list-->0
List of functions available in script mode

exit ( )
scanblackframes ( string/file )
indexmpeg ( string/file string/file number )
removeframes ( number number )
addvideofilter ( string/file number number number number number number number number number number number
number number number number number number number number number number number number number number number number number number number number number number number number number number number number ??? ??? string/file number number number number number number number number number number number number number number number number number number number number number number number number number number number number
number number number number number number number number number number number number ??? ??? ??? string/file string/file number number number number number number number number number number number number number number number number number number number number number number number number number number number number number number number number number number number number number number ??? ??? ??? string/file number number number number number number number number number number number number number number number number number number number number number number number number number number number number number number
number number number number number number number number number ??? ??? number number number number number number number number number number number number number number number number number number number number number number number number number number number number number number number number number number
number number number number number number number number ??? ??? ??? string/file ??? ??? ??? ??? ???
??? ??? ??? ??? number number ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? number ??? ???
??? ??? ??? ??? ??? ??? ??? ??? ??? number number number number )
setmarkerb ( number )
setmarkera ( number )
sleep ( number )
setfps ( float )
goto ( number )
scanvbr ( )
loadfilter ( string/file )
videocodec ( string/file string/file string/file )
videocodec ( string/file string/file )
audiocodec ( string/file number )
saveaudio ( string/file )
loadaudio ( string/file string/file )
film2pal ( number )
delay ( number )
resample ( number )
downsample ( number )
normalize ( number )
setformat ( string/file )
saveogm ( string/file )
save ( string/file )
savedvd ( string/file )
saverawvideo ( string/file )
savejpg ( string/file )
audioprocess ( number )
videoprocess ( number )
append ( string/file )
load ( string/file )


help-->0

Command line possible arguments :
--list, list functions available for scripting ( no arg )
--listfilters, list all filters by name ( no arg )
--run, load and run a script (one arg )
--audio-process, activate audio processing ( no arg )
--audio-normalize, activate normalization ( no arg )
--audio-downsample, activate 48->44 downsampling ( no arg )
--audio-resample, resample to x hz (one arg )
--audio-mono2stereo, channel: convert mono to stereo ( no arg )
--audio-stereo2mono, channel: convert stereo tp mono ( no arg )
--video-process, activate video processing ( no arg )
--filters, load a filter preset (one arg )
--codec-conf, load a codec configuration (one arg )
--vcd-res, set VCD resolution ( no arg )
--svcd-res, set SVCD resolution ( no arg )
--dvd-res, set DVD resolution ( no arg )
--halfd1-res, set 1/2 DVD resolution ( no arg )
--save-jpg, save a jpeg (one arg )
--begin, set start frame (one arg )
--end, set end frame (one arg )
--save-dvd, save as dvd ps stream (two args )
--save-unpacked-vop, save avi, unpacking vop (one arg )
--save-ogm, save as ogm file (one arg )
--save-raw-audio, save audio as-is (one arg )
--save-raw-video, save raw video stream (mpeg/... ) (one arg )
--save-uncompressed-audio, save uncompressed audio (one arg )
--index-mpeg, create index of vob/mpeg : vob.vob index.index audio# (three args)
--load, load video or workbench (one arg )
--load-workbench, load workbench file (one arg )
--append, append video (one arg )
--save, save avi (one arg )
--save-workbench, save workbench file (one arg )
--force-b-frame, Force detection of bframe in next loaded file ( no arg )
--force-unpack, Force detection of packed vop in next loaded file ( no arg )
--external-mp3, load external mpeg audio as audio track (one arg )
--external-ac3, load external ac3 audio as audio track (one arg )
--external-wav, load external wav audio as audio track (one arg )
--no-audio, load external wav audio as audio track ( no arg )
--audio-delay, set audio time shift in ms (+ or -) (one arg )
--audio-map, build audio map (MP3 VBR) ( no arg )
--audio-bitrate, set audio encoding bitrate (one arg )
--fps, set frames per second (one arg )
--audio-codec, set audio codec (MP2/MP3/AC3/NONE/TOOLAME) (one arg )
--audio-toolame, pipe audio to toolame and save to file (one arg )
--video-codec, set video codec (Divx/Xvid/FFmpeg4/VCD/SVCD/DVD/XVCD/XSVCD) (one arg )
--video-conf, set video codec conf (cq=q|cbr=br|2pass=size)[,mbr=br][,matrix=(0|1|2|3)] (one arg )
--set-pp, set post processing default value, value(1=hdeblok|2=vdeblock|4=dering) and strength (0-5) (two args )
--autosplit, split every N MBytes (one arg )
--requant, requantize mpeg2 : percent quality[0..3] output_name (three args)
--info, show information about loaded video and audio streams ( no arg )
--autoindex, try to generate required index files ( no arg )
--output-format, set output format (AVI|OGM|ES|PS|AVI_DUAL|AVI_UNP|...) (one arg )
--rebuild-index, rebuild index with correct frame type ( no arg )
--var, set var (--var myvar=3) (one arg )
--help, print this ( no arg )
--quit, exit avidemux ( no arg )Images stat:___________Max memory consumed (MB) : 0
Current memory consumed (MB) : 0
Max image used : 0
Cur image used : 0
Global mem stat
Memory consumed :0 (MB)

Goodbye...

Get a listing of all mythtv recordings

'mythls' script:

#!/bin/sh
mysql -B -u root --password=mypass mythconverg -e 'select chanid, starttime, endtime, title from recorded order by starttime' | tr -d ': -' | tr '\t' _ |
sed 's^.*^/mythtv/recordings/&.nuv^'

Actual filename doesn't include the title of the show, but this script prints the title to make it easy to identify the file.