forked from cmarrin/videomonkey
-
Notifications
You must be signed in to change notification settings - Fork 0
/
encoding-notes.txt
513 lines (381 loc) · 14.1 KB
/
encoding-notes.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
Notes About Encoding
Stitching together files
mkfifo intermediate1.mpg
mkfifo intermediate2.mpg
ffmpeg -i input1.avi -sameq -y intermediate1.mpg < /dev/null &
ffmpeg -i input2.avi -sameq -y intermediate2.mpg < /dev/null &
cat intermediate1.mpg intermediate2.mpg |\
ffmpeg -f mpeg -i - -sameq -vcodec mpeg4 -acodec libmp3lame output.avi
The above will stitch together files of any format by first converting to mpeg (at the same quality), outputting the result into a pipe and then catting the piped data and feeding it into the final ffmpeg conversion. This requires 2 conversions per movie. We can skip the conversion to mpg if the input movie is already mpg.
DV files can be catted without feeding into ffmpeg. So you can convert to DV, then cat directly to the output DV file.
Another technique was:
mkfifo temp1.a
mkfifo temp1.v
mkfifo temp2.a
mkfifo temp2.v
mkfifo all.a
mkfifo all.v
ffmpeg -i input1.flv -vn -f u16le -acodec pcm_s16le -ac 2 -ar 44100 - > temp1.a < /dev/null &
ffmpeg -i input2.flv -vn -f u16le -acodec pcm_s16le -ac 2 -ar 44100 - > temp2.a < /dev/null &
ffmpeg -i input1.flv -an -f yuv4mpegpipe - > temp1.v < /dev/null &
{ ffmpeg -i input2.flv -an -f yuv4mpegpipe - < /dev/null | tail -n +2 > temp2.v ; } &
cat temp1.a temp2.a > all.a &
cat temp1.v temp2.v > all.v &
ffmpeg -f u16le -acodec pcm_s16le -ac 2 -ar 44100 -i all.a \
-f yuv4mpegpipe -i all.v \
-sameq -y output.flv
rm temp[12].[av] all.[av]
This one almost worked once, but I think the framerate and size of both videos must be identical. Also seems like some cruft was left lying around, so it didn't work the seconds time.
Recipes
for iPod Touch
ffmpeg -i INPUT -acodec libfaac -ac 2 -ar 44100 -ab 128k -s 320x240 -vcodec libx264 -b 300k -flags +loop -cmp +chroma -partitions+parti4x4+partp8x8+partb8x8 -me umh -subq 5 -trellis 1 -refs 1 -coder 0 -me_range 16 -g 300 -keyint_min 25 -sc_threshold 40 -i_qfactor 0.71 -bt 300k -maxrate 300k -bufsize 300k -rc_eq 'blurCplx^(1-qComp)' -qcomp 0.6 -qmin 15 -qmax 51 -qdiff 4 -level 30 -aspect 320:240 OUTPUT.mp4
AtomicParsley OUTPUT.mp4 --DeepScan --iPod-uuid 1200 --overWrite --title "THE MOVIE TITLE";
===========
ffpresets files in the ffmpeg/ffpresets subdir
Default libx264 settings
------------------------
coder=1
flags=+loop
cmp=+chroma
partitions=+parti8x8+parti4x4+partp8x8+partb8x8
me=hex
subq=5
me_range=16
g=250
keyint_min=25
sc_threshold=40
i_qfactor=0.71
b_strategy=1
qcomp=0.6
qmin=10
qmax=51
qdiff=4
directpred=1
flags2=+fastpskip
threads=0
Fast First Pass
---------------
coder=1
flags=+loop
cmp=+chroma
partitions=-parti8x8-parti4x4-partp8x8-partp4x4-partb8x8
me=dia
subq=1
me_range=16
g=250
keyint_min=25
sc_threshold=40
i_qfactor=0.71
b_strategy=1
qcomp=0.6
qmin=10
qmax=51
qdiff=4
refs=1
directpred=1
bidir_refine=0
trellis=0
flags2=-bpyramid-wpred-brdo-mixed_refs-dct8x8+fastpskip
threads=0
Dark Shikari’s Q55 preset
-------------------------
coder=1
flags=+loop
cmp=+chroma
partitions=+parti8x8+parti4x4+partp8x8+partb8x8
me=hex
subq=6
me_range=16
g=250
keyint_min=25
sc_threshold=40
i_qfactor=0.71
b_strategy=1
qcomp=0.6
qmin=10
qmax=51
qdiff=4
bf=16
refs=2
directpred=3
bidir_refine=1
trellis=0
flags2=+bpyramid+wpred+dct8x8+fastpskip
threads=0
Dark Shikari’s Q75 preset
-------------------------
coder=1
flags=+loop
cmp=+chroma
partitions=+parti8x8+parti4x4+partp8x8+partb8x8
me=umh
subq=7
me_range=16
g=250
keyint_min=25
sc_threshold=40
i_qfactor=0.71
b_strategy=1
qcomp=0.6
qmin=10
qmax=51
qdiff=4
bf=16
refs=4
directpred=3
bidir_refine=1
trellis=1
flags2=+bpyramid+wpred+brdo+mixed_refs+dct8x8+fastpskip
threads=0
all options maxed out
---------------------
coder=1
flags=+loop
cmp=+chroma
partitions=+parti8x8+parti4x4+partp8x8+partp4x4+partb8x8
me=tesa
subq=7
me_range=32
g=250
keyint_min=25
sc_threshold=40
i_qfactor=0.71
b_strategy=1
qcomp=0.6
qmin=10
qmax=51
qdiff=4
bf=16
refs=16
directpred=3
bidir_refine=1
trellis=2
flags2=+bpyramid+wpred+brdo+mixed_refs+dct8x8-fastpskip
threads=0
==========
768kbit/s 320×240 H.264
1 pass
ffmpeg -i INPUT -acodec libfaac -ab 128k -s WIDTHxHEIGHT -vcodec libx264 -b BIT_RATE -bt BIT_RATE -level 13 -title SOME_TITLE OUTPUT.mp4
coder=0
flags=+loop
cmp=+chroma
partitions=+parti4x4+partp8x8+partb8x8
me= umh
subq=5
me_range=16
g=250
keyint_min=25
sc_threshold= ??? (40)
i_qfactor=0.71
b_strategy= ??? (1)
qcomp=0.6
qmin=10
qmax=51
qdiff=4
bf= ??? (16)
refs=5
directpred= ??? (3)
bidir_refine= ??? (1)
trellis=1
flags2=+mixed_refs
threads=0
*** added ***
maxrate=768k
bufsize=2M
rc_eq='blurCplx^(1-qComp)'
http://itbroadcastanddigitalcinema.com/ffmpeg_howto.html
Visual Hub Encoding
Differences: size, frame rate (1/2 rate or full rate)
All Devices - Tiny - h.264: -s <480 wide> -aspect <480 wide> -r <half> -vcodec h264
-g 150 -qmin 29 -b 300k -level 30 -loop 1 -sc_threshold 40 -partp4x4 1 -rc_eq 'blurCplx^(1-qComp)' -refs 2 -qmax 51 -maxrate 1450k -keyint_min 40
-async 50 -acodec libfaac -ar 11025 -ac 1 -ab 16k
All Devices - Tiny: -s <480 wide> -aspect <480 wide> -r <half> -vcodec mpeg4
-g 150 -qmin 7 -b 500k -maxrate 2400k -qmax 31 -bufsize 1221k
-async 50 -acodec libfaac -ar 11025 -ac 1 -ab 16k
All Devices - Low - h.264: -s 624x352 -aspect 624:352 -r <full> -vcodec h264
-g 150 -qmin 32 -b 600k -level 30 -loop 1 -sc_threshold 40 -partp4x4 1 -rc_eq 'blurCplx^(1-qComp)' -refs 2 -qmax 51 -maxrate 1450k -keyint_min 40
-async 50 -acodec libfaac -ar 48000 -ac 2 -ab 128k
All Devices - Low: -s 624x352 -aspect 624:352 -r ntsc-film -vcodec mpeg4
-g 150 -qmin 8 -b 700k -maxrate 2400k -qmax 31 -bufsize 1221k
-async 50 -acodec libfaac -ar 44100 -ac 2 -ab 128k
All Devices - Standard - h.264: -s 1440x1080 -aspect 1440:1080 -r pal -vcodec h264
-g 150 -qmin 25 -b 1000k -level 30 -loop 1 -sc_threshold 40 -partp4x4 1 -rc_eq 'blurCplx^(1-qComp)' -refs 2 -qmax 51 -maxrate 1450k -keyint_min 40
-async 50 -acodec libfaac -ar 48000 -ac 2 -ab 128k
All Devices - High - h.264: -s 1440x1080 -aspect 1440:1080 -r pal -vcodec h264
-g 150 -qmin 20 -b 1200k -level 30 -loop 1 -sc_threshold 40 -partp4x4 1 -rc_eq 'blurCplx^(1-qComp)' -refs 2 -qmax 51 -maxrate 1450k -keyint_min 40
-async 50 -acodec libfaac -ar 48000 -ac 2 -ab 128k
All Devices - Go Nuts - h.264: -s 1440x1080 -aspect 1440:1080 -r pal -vcodec h264
-g 150 -qmin 8 -b 1400k -level 30 -loop 1 -sc_threshold 40 -partp4x4 1 -rc_eq 'blurCplx^(1-qComp)' -refs 2 -qmax 51 -maxrate 1450k -keyint_min 40
-async 50 -acodec libfaac -ar 48000 -ac 2 -ab 128k
iPod 5G - Tiny - h.264: -s 1440x1080 -aspect 1440:1080 -r pal -vcodec h264 -g 150 -qmin 29 -b 150k -level 13 -loop 1 -sc_threshold 40 -partp4x4 1 -rc_eq 'blurCplx^(1-qComp)' -refs 3 -qmax 51 -maxrate 700k -keyint_min 40 -async 50 -acodec libfaac -ar 11025 -ac 1 -ab 16k
AVI (Original 480x272, 23.98 fps, h.264, bitrate 636k, mp4)
unless noted otherwise audio is: -async 50 -acodec mp3 -ar 48000 -ac 2 -ab 128k
---
no 320 wide, no profile, standard quality: -s 480x272 -r 23.98 -vcodec mpeg4 -vtag DX50 -g 200 -qmin 5 -b 870k
320 wide, no profile, standard quality: -s 320x176 -r 23.98 -vcodec mpeg4 -vtag DX50 -g 200 -qmin 5 -b 375k
no 320 wide, no profile, go nuts quality: -s 480x272 -r 23.98 -vcodec mpeg4 -vtag DX50 -g 200 -b 2611k
no 320 wide, Home Theater profile, standard quality: -s 480x272 -r 23.98 -vcodec mpeg4 -vtag DX50 -bf 1 -g 200 -qmin 5 -b 870k
no 320 wide, Portable profile, standard quality: -s 480x272 -r 23.98 -vcodec mpeg4 -vtag DX50 -bf 1 -g 200 -qmin 5 -b 870k
no 320 wide, Simple profile, standard quality: -s 320x176 -r 23.98 -vcodec mpeg4 -vtag DX50 -g 200 -qmin 5 -b 375k
no 320 wide, Best Compat. profile, standard quality: -s 320x176 -r 23.98 -vcodec mpeg4 -vtag DX50 -g 200 -qmin 5 -b 375k
no 320 wide, Wii profile, standard quality: -s 320x176 -r 23.98 -vcodec mjpeg -g 200 -qmin 5 -b 750k
(audio: -async 50 -acodec pcm_u8 -ar 48000 -ac 2 -ab 128k)
*************************************************
*************************************************
*************************************************
*************************************************
Maybe commands.xml should be structured to decode generic file types. There would be a tables for:
File/Container type: MP4, AVI, DV, WMV, MPEG, FLV, SWF
Video encoder: MP4, X.264, DV, WMV, FLV
Audio encoder: MP3, AAC, PCM/WAV, WMA, FLV
Then you'd supply tables for quality, performance, etc. mapping.
Then each specific device section would select from the menu of encoders, supply params, and go.
*************************************************
*************************************************
*************************************************
*************************************************
ffprobe mediainfo
------- ---------
sample.avi
audio 1 (2nd) same
video 0 (1st) same
sample.mov
audio 0 (1st) 1 (2nd) Different
video 1 (2nd) 2 (1st) Different
audiosync.mp4
audio 1 (2nd) 2 (2nd) Different
video 0 (1st) 1 (1st) Different
Dead...mkv
audio 1 (2nd) 2 (2nd) Different
video 0 (1st) 1 (1st) Different
niceday.asf
audio 0 (1st)
video 1 (2nd)
niceday.wmv
audio 0 (1st)
video 1 (2nd)
test.mkv
audio 0 (1st)
video 1 (2nd)
WMV
---
Works:
"/Users/cmarrin/personal/Projects/git/videomonkey/build/Debug/VideoMonkey.app/Contents/Resources/bin/ffmpeg" -threads 2 -y -i "/Users/cmarrin/personal/Projects/git/videomonkey/samples/audiosync.mp4"
-s 240x128 -aspect 240:128 -r 10 -vcodec wmv1 -threads 1 -pix_fmt yuv420p -g 15 -qmin 7 -b 2326k
-async 50 -acodec wmav2 -ar 48000 -ac 2 -ab 128000 "/Users/cmarrin/personal/Projects/git/videomonkey/samples/audiosync_1.wmv"
Does not work
"/Users/cmarrin/personal/Projects/git/videomonkey/build/Debug/VideoMonkey.app/Contents/Resources/bin/ffmpeg" -threads 2 -y -i "/Users/cmarrin/personal/Projects/git/videomonkey/samples/audiosync.mp4"
-s 240x128 -aspect 240:128 -r 10 -vcodec wmv1 -b 20000 -maxrate 24k -bufsize 5k -qmin 9
-async 50 -acodec wmav2 -ar 48000 -ac 2 -ab 128000 "/Users/cmarrin/personal/Projects/git/videomonkey/samples/audiosync_1.wmv"
works:
-s 848x480 -r 29.97 -pix_fmt yuv420p -g 300 -qmin 5 -b 1628k -async 50 -acodec libmp3lame -ar 44100 -ac 2 -ab 128k '/Users/cmarrin/personal/Projects/git/videomonkey/samples/'/'audiosync.mp4'.temp.swf
does not work:
-threads 2 -y -i "/Users/cmarrin/personal/Projects/git/videomonkey/samples/audiosync.wmv" -s 240x128 -aspect 240:128 -r 29.97 -b 307202.45 -g 30 -maxrate 34k -bufsize 5k -qmin 5 -async 50 -acodec libmp3lame -ar 11025 -ac 1 -ab 16000 "/Users/cmarrin/personal/Projects/git/videomonkey/samples/audiosync_1.mp4"
AVI:
-s 720x544 -r 29.97 -vcodec mpeg4 -b 4000000 -g 200 -qmin 2 -async 50 -acodec libmp3lame -ar 44100 -ac 2 -ab 128000 "/Users/cmarrin/personal/Projects/git/videomonkey/samples/sample_hd_9.avi"
2nd gen apple tv:
-s 960x720 -aspect 960:720 -r 25 -vcodec libx264 -b 5000000 -async 50 -acodec libfaac -ar 48000 -ac 2 -ab 128000 -vpre ffpresets/libx264-medium -vpre ffpresets/libx264-main "/Users/cmarrin/personal/Projects/git/videomonkey/samples/sample_hd_8.mp4"
DVD Authoring
=============
Create VOB files for each input video:
ffmpeg -y -i <input file> -threads 4 -t 120 -target ntsc-dvd -s 720x480 -aspect 16:9 -r ntsc -g 15
-sc_threshold 1000000000 -flags cgop -flags2 sgop -bf 2 -async 50 -ar 48000 -ab 192k -ac 2 -f vob <temp file>.vob
Make DVD structure:
dvdauthor -t <temp file 1>.vob <temp file 2>.vob ... -o <DVD Directory> -v 16:9+nopanscan
Make iso file (using mkisofs)
mkisofs -dvd-video -o <iso file>.iso -V <Disk name (13 char max?)> <DVD Directory>
Can we use hdiutil instead of mkisofs?
I was successful making a DVD directory with this:
ffmpeg -i av_out_of_sync.mov -target pal-dvd av_out_of_sync.vob
ffmpeg -i sample.mp4 -target pal-dvd sample.vob
dvdauthor -o MY_DVD -x dvd.xml
dvd.xml
=======
<dvdauthor>
<vmgm />
<titleset>
<titles>
<pgc>
<vob file="av_out_of_sync.vob" />
<vob file="sample.vob" />
</pgc>
</titles>
</titleset>
</dvdauthor>
=====
I used pal-dvd because that's what the example used. ntsc-dvd will probably work the same
Then I used this to make the iso file:
hdiutil makehybrid -udf -udf-volume-name MY_DVD -o MY_DVD.iso MY_DVD
Then I did this to burn it:
hdiutil burn -puppetstrings MY_DVD.iso
The spew looked like this:
PERCENT:0.000000
PERCENT:-1.000000
MESSAGE:Preparing data for burn
PERCENT:-1.000000
MESSAGE:Opening session
PERCENT:-1.000000
MESSAGE:Opening track
PERCENT:-1.000000
MESSAGE:Writing track
PERCENT:0.652133
PERCENT:1.844606
PERCENT:5.422023
PERCENT:7.806969
PERCENT:11.384386
PERCENT:14.961803
PERCENT:18.539221
PERCENT:22.116638
PERCENT:25.694057
PERCENT:29.271475
PERCENT:32.848892
PERCENT:36.426308
PERCENT:40.003727
PERCENT:43.581142
PERCENT:47.158562
PERCENT:50.735981
PERCENT:54.313396
PERCENT:54.313396
MESSAGE:Closing track
PERCENT:54.313396
MESSAGE:Closing session
PERCENT:57.890816
PERCENT:61.468231
PERCENT:65.045647
PERCENT:68.623062
PERCENT:72.200485
PERCENT:75.777901
PERCENT:79.355316
PERCENT:82.932732
PERCENT:86.510155
PERCENT:90.087578
PERCENT:93.664993
PERCENT:-1.000000
PERCENT:-1.000000
PERCENT:-1.000000
MESSAGE:Finishing burn
PERCENT:0.000000
MESSAGE:Verifying burn…
MESSAGE:Verifying
PERCENT:0.000000
PERCENT:0.000000
PERCENT:9.539780
PERCENT:19.079559
PERCENT:28.619341
PERCENT:38.159119
PERCENT:47.698898
PERCENT:57.238682
PERCENT:66.778465
PERCENT:76.318237
PERCENT:85.858025
PERCENT:95.397797
PERCENT:100.000000
PERCENT:100.000000
MESSAGE:Burn completed successfully
PERCENT:100.000000
MESSAGE:hdiutil: burn: completed
If a burnable disk is not inserted a line will spew:
Please insert a disc:
if the disk inserted is not blank a line will spew:
Media is not writable
PERCENT:-1.000000 mean 'indeterminate', progress bar should show barber pole