Skip to content

Commit 721ac95

Browse files
committed
rework the mp4 exporter to more explicitly allow ipod compatibility AND to enable the higher quality -refs setting when ipod compatibility is not required. Also updates the default nuvexportrc file to be more generic (with better documentation) rather than mimicing some of my personal settings.
1 parent b1f3598 commit 721ac95

File tree

3 files changed

+113
-107
lines changed

3 files changed

+113
-107
lines changed

nuvexport/export/ffmpeg/MP4.pm

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@ package export::ffmpeg::MP4;
2828
add_arg('v_bitrate|v=i', 'Video bitrate');
2929
add_arg('multipass!', 'Enable two-pass encoding.');
3030
add_arg('mp4_codec=s', 'Video codec to use for MP4/iPod video (mpeg4 or h264).');
31-
add_arg('mp4_fps=s', 'Framerate to use: auto, 25, 23.97, 29.97');
31+
add_arg('mp4_fps=s', 'Framerate to use: auto, 25, 23.97, 29.97.');
32+
add_arg('ipod!', 'Produce ipod-compatible output.');
3233

3334
sub new {
3435
my $class = shift;
@@ -107,6 +108,10 @@ package export::ffmpeg::MP4;
107108
$self->val('a_bitrate'));
108109
# Video options
109110
if (!$is_cli) {
111+
# iPod compatibility mode?
112+
$self->{'ipod'} = query_text('Enable iPod compatibility?',
113+
'yesno',
114+
$self->val('ipod'));
110115
# Video codec
111116
if ($self->{'ffmpeg_vers'} eq 'svn') {
112117
while (1) {
@@ -165,11 +170,19 @@ package export::ffmpeg::MP4;
165170
if ($self->{'mp4_codec'} eq 'h264' && $self->{'ffmpeg_vers'} ne 'svn') {
166171
die "h.264 mp4/ipod encoding requires the svn version of ffmpeg.\n";
167172
}
168-
# Query the resolution
169-
$self->query_resolution();
170-
# Warn about ipod resolution
171-
if ($self->{'height'} > 480 || $self->{'width'} > 640) {
172-
print "WARNING: Video larger than 640x480 will not play on an iPod.\n";
173+
# Loop, in case we need to verify ipod compatibility
174+
while (1) {
175+
# Query the resolution
176+
$self->query_resolution();
177+
# Warn about ipod resolution
178+
if ($self->val('ipod') && ($self->{'height'} > 480 || $self->{'width'} > 640)) {
179+
my $note = "WARNING: Video larger than 640x480 will not play on an iPod.\n";
180+
die $note if ($is_cli);
181+
print $note;
182+
next;
183+
}
184+
# Done looping
185+
last;
173186
}
174187
}
175188

@@ -270,7 +283,7 @@ package export::ffmpeg::MP4;
270283
}
271284
# Single/final pass options
272285
if ($self->{'mp4_codec'} eq 'h264') {
273-
$ffmpeg_xtra .= ' -refs 2'
286+
$ffmpeg_xtra .= ' -refs '.($self->var('ipod') ? 2 : 7)
274287
.' -subq 7'
275288
.' -partitions parti4x4+parti8x8+partp4x4+partp8x8+partb8x8'
276289
.' -flags2 +bpyramid+wpred+mixed_refs+8x8dct+brdo'

nuvexport/export/generic.pm

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -247,10 +247,13 @@ package export::generic;
247247
# No height given -- use auto?
248248
if (!$self->val('width') || $self->val('width') =~ /^\s*\D/) {
249249
$self->{'width'} = $episodes[0]->{'finfo'}{'width'};
250+
print 'Default resolution based on ',
251+
($self->val('force_aspect') ? 'forced ' : ''),
252+
$episodes[0]->{'finfo'}{'aspect'}, " aspect ratio.\n";
253+
}
254+
else {
255+
print "Default resolution based on requested dimensions.\n";
250256
}
251-
print 'Default resolution based on ',
252-
($self->val('force_aspect') ? 'forced ' : ''),
253-
$episodes[0]->{'finfo'}{'aspect'}, " aspect ratio.\n";
254257
# Ask the user what resolution he/she wants
255258
while (1) {
256259
my $w = query_text('Width?',

nuvexport/nuvexportrc

Lines changed: 87 additions & 97 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@
66
# nuvexport will look first, if you wish to create settings local to a
77
# specific user.
88
#
9-
# support for nuvexportrc is still new, so expect that more default options
10-
# will be added as time goes on (so you'll know what you can edit). In the
11-
# meantime, you can poke around in the code for add_arg() calls to see which
12-
# options are available.
9+
# I try to use this file to document all of the commandline options supported
10+
# by nuvexport, but it is quite likely that a few slip through here and there
11+
# unnoticed. Feel free to poke around in the code for add_arg() calls to see
12+
# all of the available options.
1313
#
1414

1515
#
@@ -101,11 +101,20 @@
101101
# crop_bottom = 2
102102
# crop_left = 2
103103

104+
#
105+
# You can also override the output aspect ratio. This is useful in combination
106+
# with crop_top=12.5 and crop_bottom=12.5 to remove the black bars from the
107+
# top/bottom of recordings broadcast in fake widescreen.
108+
#
109+
# out_aspect = 16:9
110+
#
111+
112+
104113
#
105114
# Export a matching .txt file, which mythvideo can use to import information
106115
# about your exports, since it likely can't look them up in imdb.
107116
#
108-
save_info = yes
117+
# save_info = yes
109118

110119
</nuvexport>
111120

@@ -119,7 +128,7 @@
119128
#
120129
# Default to export to the current directory
121130
#
122-
path = /home/xris/Video
131+
path = .
123132

124133
#
125134
# Use the cutlist (not to be confused with the commercial flag list) when
@@ -144,8 +153,9 @@
144153

145154
#
146155
# Disabling noise reduction can speed up your exports dramatically, but at the
147-
# expense of some quality. You can also access this on the commandline via
148-
# the --denoise (or --nodenoise) flag.
156+
# expense of some quality. For your convenience, this is also aliased on
157+
# the commandline as --denoise (or --nodenoise), as well as
158+
# --noise_reduction.
149159
#
150160
noise_reduction = no
151161

@@ -224,6 +234,8 @@
224234
<mencoder>
225235
</mencoder>
226236

237+
################################################################################
238+
227239
#
228240
# You can also create settings for generic export module names. These will
229241
# only be overridden by full module names.
@@ -245,17 +257,56 @@
245257
</XviD>
246258

247259
#
248-
# Default mp3 bitrate is 128
260+
# The mp3 bitrate used by MythTV's software encoder is 128, so there is no
261+
# real need to go any higher in exports. You can, of course, turn this up if
262+
# you get your recordings from other sources.
249263
#
250264
<MP3>
251265
bitrate = 128
252266
</MP3>
253267

268+
################################################################################
269+
254270
#
255271
# If you want to provide settings for a very specific export module, you can
256272
# use its full name, and it will override any more generic settings.
257273
#
258274

275+
#
276+
# The MP4 encoder for ffmpeg has a few options unique to itself
277+
#
278+
<ffmpeg::MP4>
279+
280+
#
281+
# Codec to use (mpeg4 or h264). Please note that h264 support requires the
282+
# SVN version of ffmpeg (not CVS!). In fact, even the mpeg4 codec works
283+
# better with the SVN version.
284+
#
285+
# Note: The h.264 files exported by nuvexport seem to play fine on ipods,
286+
# but lack the atom necessary to be recognized by iTunes, so you will have to
287+
# find other means to get the exports onto your ipod (gtkpod works great).
288+
#
289+
mp4_codec = h264
290+
291+
#
292+
# Framerate to use: auto, 25, 23.97, 29.97. PAL will always be 25 fps, and
293+
# auto will set 29.97 for everything over 320x288 and 23.97 for the rest.
294+
#
295+
mp4_fps = auto
296+
297+
#
298+
# Enable ipod compatibility mode. Aside from forcing a max resolution of
299+
# 640x480, this basically just sets motion detection reference frames (-refs)
300+
# to 2 instead of 7 (the ipod can only handle 2), and thus a small drop in
301+
# motion detection quality.
302+
#
303+
ipod = yes
304+
305+
</ffmpeg::MP4>
306+
307+
#
308+
# As does the PSP exporter
309+
#
259310
<ffmpeg::PSP>
260311

261312
# PSP framerate (high=29.97, low=14.985)
@@ -272,113 +323,52 @@
272323

273324
</ffmpeg::PSP>
274325

275-
<ffmpeg::MP4>
276-
277-
# Codec to use (xvid or h264). Please note that h264 support is experimental.
278-
# I have not yet been able to export a file using h264 that actuall works,
279-
# despite the fact that I've tried my best to copy the ffmpeg parameters from
280-
# iSquint, which does work.
281-
mp4_codec = h264
326+
#
327+
# You can also add flags to the one and only mencoder option
328+
#
329+
<mencoder::XviD>
282330

283-
noise_reduction = no
284-
deinterlace = yes
285-
multipass = yes
286-
v_bitrate = 768
287-
a_bitrate = 128
331+
multipass = no
288332

289-
width = 528
290-
height = 480
333+
</mencoder::XviD>
291334

292-
# Framerate to use: auto, 25, 23.97, 29.97. PAL will always be 25 fps, and
293-
# auto will set 29.97 for everything over 320x288 and 23.97 for the rest.
294-
mp4_fps = auto
295-
296-
</ffmpeg::MP4>
335+
################################################################################
297336

298337
#
299-
# You can also make specific profiles called with the --profile parameter that
300-
# will override other config options (but not commandline arguments).
338+
# You can also make specific profiles called with the --profile parameter that
339+
# will override other config options (but not commandline arguments).
301340
#
302-
# For example, you could make a profile that would encode your favorite show
303-
# with your favorite settings.
341+
# For example, you could make a profile that would encode your favorite show
342+
# with your favorite settings.
304343
#
305-
<profile::bourdain>
306-
307-
title = bourdain
308-
309-
export_prog = ffmpeg
310-
mode = mp4
311-
312-
crop_pct = 0
313-
crop_right = 1.5
314-
crop_left = 1.5
315-
316-
width = 528
317-
height = 480
344+
<profile::sample>
318345

319-
</profile::bourdain>
346+
title = test
320347

321-
<profile::follow>
348+
export_prog = transcode
349+
mode = xvid
350+
confirm = true
322351

323-
title = follow that
352+
</profile::sample>
324353

325-
export_prog = ffmpeg
326-
mode = mp4
327-
328-
crop_pct = 0
329-
330-
width = 352
331-
height = 480
332-
333-
# The episodes all say "follow that" at the beginning
334-
filename=%s
335-
336-
</profile::follow>
337-
338-
<profile::goodeats>
354+
#
355+
# Or crop the black bars off of the top/bottom of fake widescreen shows.
356+
#
357+
<profile::samplewide>
339358

340-
title = good eats
359+
title = test
341360

342361
export_prog = ffmpeg
343362
mode = mp4
344363

345-
crop_pct = 0
346-
crop_top = 1
347-
crop_right = 1
348-
crop_left = 1
349-
350-
width = 528
351-
height = 480
352-
353-
</profile::goodeats>
354-
355-
<profile::iron>
356-
357-
title = iron chef
358-
359-
export_prog = ffmpeg
360-
mode = mp4
364+
out_aspect = 16:9
361365

362366
crop_pct = 0
363-
crop_top = 1
364-
crop_left = 1
367+
crop_top = 12.5
368+
crop_bottom = 12.5
365369

366370
width = 528
367-
height = 480
371+
height = 360
368372

369-
</profile::iron>
370-
371-
<profile::greg>
372-
373-
title = greg the
374-
375-
export_prog = ffmpeg
376-
mode = mp4
377-
378-
crop_pct = 0
379-
crop_left = 1
380-
381-
width = 528
382-
height = 480
373+
</profile::samplewide>
383374

384-
</profile::greg>

0 commit comments

Comments
 (0)