Skip to content

Commit 9126b54

Browse files
committed
- [+] add test transcoding of different target types
1 parent 7ffde03 commit 9126b54

4 files changed

Lines changed: 224 additions & 24 deletions

File tree

ffcvt.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -196,9 +196,10 @@ cut_ok:
196196
// calculate (finished) percentage for each video
197197
n := len(vidCol.videos)
198198
if n > 0 {
199-
totalSize := vidCol.videos[n-1].sum
199+
totalSize := vidCol.sum
200200
for i, _ := range vidCol.videos {
201-
vidCol.videos[i].pct = int(vidCol.videos[i].sum * 100 / totalSize)
201+
vidCol.videos[i].pct =
202+
int((vidCol.videos[i].sum*1000/totalSize + 5) / 10)
202203
}
203204
}
204205
//fmt.Printf("%v", vidCol)

test/ffcvt_test.txt

Lines changed: 106 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -140,14 +140,78 @@ Details:
140140
work directory that hold output files
141141

142142
To reduce output, use `-debug 0`, e.g., `ffcvt -force -debug 0 -f testf.mp4 ...`
143+
- Test transcoding single file
143144

144145
== Transcoding: StreamSample.mkv
145146
ffcvt: to execute -
146147
ffmpeg -i StreamSample.mkv -c:v libvpx-vp9 -b:v 0 -crf 42 -c:a libopus -b:a 64k -c:s copy /tmp/StreamSample.mkv
147148

149+
Transcoding completed in xxx ms
148150
Org Size: 0 MB
149151
New Size: 0 MB
150152
Saved: 0%
153+
- Test transcoding different target types
154+
155+
== Transcoding: StreamSample.mkv
156+
] ffmpeg -i StreamSample.mkv -c:v libvpx-vp9 -b:v 0 -crf 42 -c:a libopus -b:a 64k -c:s copy /tmp/StreamSample.mkv
157+
ffcvt: to execute -
158+
ffmpeg -i StreamSample.mkv -c:v libvpx-vp9 -b:v 0 -crf 42 -c:a libopus -b:a 64k -c:s copy /tmp/StreamSample.mkv
159+
160+
Transcoding completed in xxx ms
161+
Org Size: 0 MB
162+
New Size: 0 MB
163+
Saved: 0%
164+
165+
== Transcoding: StreamSample.mkv
166+
] ffmpeg -i StreamSample.mkv -c:v libx265 -x265-params crf=28 -c:a libopus -b:a 64k /tmp/StreamSample.mkv
167+
ffcvt: to execute -
168+
ffmpeg -i StreamSample.mkv -c:v libx265 -x265-params crf=28 -c:a libopus -b:a 64k /tmp/StreamSample.mkv
169+
170+
Transcoding completed in xxx ms
171+
Org Size: 0 MB
172+
New Size: 0 MB
173+
Saved: 0%
174+
175+
== Transcoding: StreamSample.mkv
176+
] ffmpeg -i StreamSample.mkv -c:v libx264 -x264-params crf=23 -c:a libmp3lame -b:a 256k -q:a 3 /tmp/StreamSample.mp4
177+
ffcvt: to execute -
178+
ffmpeg -i StreamSample.mkv -c:v libx264 -x264-params crf=23 -c:a libmp3lame -b:a 256k -q:a 3 /tmp/StreamSample.mp4
179+
180+
Transcoding completed in xxx ms
181+
Org Size: 0 MB
182+
New Size: 0 MB
183+
Saved: 0%
184+
185+
== Transcoding: StreamSample.mkv
186+
] ffmpeg -i StreamSample.mkv -c:v libx264 -x264-params crf=33 -c:a aac -b:a 48k -q:a 3 /tmp/StreamSample.m4v
187+
ffcvt: to execute -
188+
ffmpeg -i StreamSample.mkv -c:v libx264 -x264-params crf=33 -c:a aac -b:a 48k -q:a 3 /tmp/StreamSample.m4v
189+
190+
Transcoding completed in xxx ms
191+
Org Size: 0 MB
192+
New Size: 0 MB
193+
Saved: 0%
194+
195+
== Transcoding: StreamSample.mkv
196+
] ffmpeg -i StreamSample.mkv -c:v libx264 -x264-params crf=20 -pix_fmt yuv420p -c:a libvorbis -q:a 5 /tmp/StreamSample.avi
197+
ffcvt: to execute -
198+
ffmpeg -i StreamSample.mkv -c:v libx264 -x264-params crf=20 -pix_fmt yuv420p -c:a libvorbis -q:a 5 /tmp/StreamSample.avi
199+
200+
Transcoding completed in xxx ms
201+
Org Size: 0 MB
202+
New Size: 0 MB
203+
Saved: 0%
204+
205+
== Transcoding: StreamSample.mkv
206+
] ffmpeg -i StreamSample.mkv -c:v copy -c:a copy -b:a 64k -c:s copy /tmp/StreamSample.mkv
207+
ffcvt: to execute -
208+
ffmpeg -i StreamSample.mkv -c:v copy -c:a copy -b:a 64k -c:s copy /tmp/StreamSample.mkv
209+
210+
Transcoding completed in xxx ms
211+
Org Size: 0 MB
212+
New Size: 0 MB
213+
Saved: 0%
214+
- Test -sym control
151215
] None-video file './ffcvt_test.txt' duplicated to dest dir.
152216
] None-video file './test-all.sh' duplicated to dest dir.
153217
] Skip symlink file: ./test1.avi
@@ -159,37 +223,49 @@ Saved: 0%
159223
] ffmpeg -i ./StreamSample.mkv -c:v libx265 -x265-params crf=28 -c:a libopus -b:a 64k ./StreamSample_.mkv
160224
ffcvt: to execute -
161225
ffmpeg -i ./StreamSample.mkv -c:v libx265 -x265-params crf=28 -c:a libopus -b:a 64k ./StreamSample_.mkv
226+
Time taken so far xxx ms
227+
Finishing the remaining 0% in xxx ms
162228

229+
Transcoding completed in xxx ms
163230
Org Size: 0 MB
164231
New Size: 0 MB
165232
Saved: 0%
166233
] None-video file './ffcvt_test.txt' duplicated to dest dir.
167234
] None-video file './test-all.sh' duplicated to dest dir.
168235

169-
== Transcoding [1/4] (99%): 'StreamSample.mkv'
236+
== Transcoding [1/4] (100%): 'StreamSample.mkv'
170237
under .
171238
] ffmpeg -i ./StreamSample.mkv -c:v libx265 -x265-params crf=28 -c:a libopus -b:a 64k ./StreamSample_.mkv
172239
ffcvt: to execute -
173240
ffmpeg -i ./StreamSample.mkv -c:v libx265 -x265-params crf=28 -c:a libopus -b:a 64k ./StreamSample_.mkv
241+
Time taken so far xxx ms
242+
Finishing the remaining 0% in xxx ms
174243

175-
== Transcoding [2/4] (99%): 'test1.avi'
244+
== Transcoding [2/4] (100%): 'test1.avi'
176245
under .
177246
] ffmpeg -i ./test1.avi -c:v libx265 -x265-params crf=28 -c:a libopus -b:a 64k ./test1_.mkv
178247
ffcvt: to execute -
179248
ffmpeg -i ./test1.avi -c:v libx265 -x265-params crf=28 -c:a libopus -b:a 64k ./test1_.mkv
249+
Time taken so far xxx ms
250+
Finishing the remaining 0% in xxx ms
180251

181-
== Transcoding [3/4] (99%): 'test2.avi'
252+
== Transcoding [3/4] (100%): 'test2.avi'
182253
under .
183254
] ffmpeg -i ./test2.avi -c:v libx265 -x265-params crf=28 -c:a libopus -b:a 64k ./test2_.mkv
184255
ffcvt: to execute -
185256
ffmpeg -i ./test2.avi -c:v libx265 -x265-params crf=28 -c:a libopus -b:a 64k ./test2_.mkv
257+
Time taken so far xxx ms
258+
Finishing the remaining 0% in xxx ms
186259

187260
== Transcoding [4/4] (100%): 'test3.webm'
188261
under .
189262
] ffmpeg -i ./test3.webm -c:v libx265 -x265-params crf=28 -c:a libopus -b:a 64k ./test3_.mkv
190263
ffcvt: to execute -
191264
ffmpeg -i ./test3.webm -c:v libx265 -x265-params crf=28 -c:a libopus -b:a 64k ./test3_.mkv
265+
Time taken so far xxx ms
266+
Finishing the remaining 0% in xxx ms
192267

268+
Transcoding completed in xxx ms
193269
Org Size: 0 MB
194270
New Size: 0 MB
195271
Saved: 0%
@@ -204,68 +280,89 @@ Saved: 0%
204280
] ffmpeg -i ./StreamSample.mkv -c:v libvpx-vp9 -b:v 0 -crf 42 -c:a libopus -b:a 64k -c:s copy ./StreamSample_.mkv
205281
ffcvt: to execute -
206282
ffmpeg -i ./StreamSample.mkv -c:v libvpx-vp9 -b:v 0 -crf 42 -c:a libopus -b:a 64k -c:s copy ./StreamSample_.mkv
283+
Time taken so far xxx ms
284+
Finishing the remaining 0% in xxx ms
207285

286+
Transcoding completed in xxx ms
208287
Org Size: 0 MB
209288
New Size: 0 MB
210289
Saved: 0%
211290
] None-video file './ffcvt_test.txt' duplicated to dest dir.
212291
] None-video file './test-all.sh' duplicated to dest dir.
213292

214-
== Transcoding [1/4] (99%): 'StreamSample.mkv'
293+
== Transcoding [1/4] (100%): 'StreamSample.mkv'
215294
under .
216295
] ffmpeg -i ./StreamSample.mkv -c:v libvpx-vp9 -b:v 0 -crf 42 -c:a libopus -b:a 64k -c:s copy ./StreamSample_.mkv
217296
ffcvt: to execute -
218297
ffmpeg -i ./StreamSample.mkv -c:v libvpx-vp9 -b:v 0 -crf 42 -c:a libopus -b:a 64k -c:s copy ./StreamSample_.mkv
298+
Time taken so far xxx ms
299+
Finishing the remaining 0% in xxx ms
219300

220-
== Transcoding [2/4] (99%): 'test1.avi'
301+
== Transcoding [2/4] (100%): 'test1.avi'
221302
under .
222303
] ffmpeg -i ./test1.avi -c:v libvpx-vp9 -b:v 0 -crf 42 -c:a libopus -b:a 64k -c:s copy ./test1_.mkv
223304
ffcvt: to execute -
224305
ffmpeg -i ./test1.avi -c:v libvpx-vp9 -b:v 0 -crf 42 -c:a libopus -b:a 64k -c:s copy ./test1_.mkv
306+
Time taken so far xxx ms
307+
Finishing the remaining 0% in xxx ms
225308

226-
== Transcoding [3/4] (99%): 'test2.avi'
309+
== Transcoding [3/4] (100%): 'test2.avi'
227310
under .
228311
] ffmpeg -i ./test2.avi -c:v libvpx-vp9 -b:v 0 -crf 42 -c:a libopus -b:a 64k -c:s copy ./test2_.mkv
229312
ffcvt: to execute -
230313
ffmpeg -i ./test2.avi -c:v libvpx-vp9 -b:v 0 -crf 42 -c:a libopus -b:a 64k -c:s copy ./test2_.mkv
314+
Time taken so far xxx ms
315+
Finishing the remaining 0% in xxx ms
231316

232317
== Transcoding [4/4] (100%): 'test3.webm'
233318
under .
234319
] ffmpeg -i ./test3.webm -c:v libvpx-vp9 -b:v 0 -crf 42 -c:a libopus -b:a 64k -c:s copy ./test3_.mkv
235320
ffcvt: to execute -
236321
ffmpeg -i ./test3.webm -c:v libvpx-vp9 -b:v 0 -crf 42 -c:a libopus -b:a 64k -c:s copy ./test3_.mkv
322+
Time taken so far xxx ms
323+
Finishing the remaining 0% in xxx ms
237324

325+
Transcoding completed in xxx ms
238326
Org Size: 0 MB
239327
New Size: 0 MB
240328
Saved: 0%
241329
] Transcoding to /tmp/test
242330
] None-video file './ffcvt_test.txt' duplicated to dest dir.
243331
] None-video file './test-all.sh' duplicated to dest dir.
244332

245-
== Transcoding [1/4] (99%): 'StreamSample.mkv'
333+
== Transcoding [1/4] (100%): 'StreamSample.mkv'
246334
under .
247335
] ffmpeg -i ./StreamSample.mkv -c:v libvpx-vp9 -b:v 0 -crf 42 -c:a libopus -b:a 64k -c:s copy /tmp/test/StreamSample.mkv
248336
ffcvt: to execute -
249337
ffmpeg -i ./StreamSample.mkv -c:v libvpx-vp9 -b:v 0 -crf 42 -c:a libopus -b:a 64k -c:s copy /tmp/test/StreamSample.mkv
338+
Time taken so far xxx ms
339+
Finishing the remaining 0% in xxx ms
250340

251-
== Transcoding [2/4] (99%): 'test1.avi'
341+
== Transcoding [2/4] (100%): 'test1.avi'
252342
under .
253343
] ffmpeg -i ./test1.avi -c:v libvpx-vp9 -b:v 0 -crf 42 -c:a libopus -b:a 64k -c:s copy /tmp/test/test1.mkv
254344
ffcvt: to execute -
255345
ffmpeg -i ./test1.avi -c:v libvpx-vp9 -b:v 0 -crf 42 -c:a libopus -b:a 64k -c:s copy /tmp/test/test1.mkv
346+
Time taken so far xxx ms
347+
Finishing the remaining 0% in xxx ms
256348

257-
== Transcoding [3/4] (99%): 'test2.avi'
349+
== Transcoding [3/4] (100%): 'test2.avi'
258350
under .
259351
] ffmpeg -i ./test2.avi -c:v libvpx-vp9 -b:v 0 -crf 42 -c:a libopus -b:a 64k -c:s copy /tmp/test/test2.mkv
260352
ffcvt: to execute -
261353
ffmpeg -i ./test2.avi -c:v libvpx-vp9 -b:v 0 -crf 42 -c:a libopus -b:a 64k -c:s copy /tmp/test/test2.mkv
354+
Time taken so far xxx ms
355+
Finishing the remaining 0% in xxx ms
262356

263357
== Transcoding [4/4] (100%): 'test3.webm'
264358
under .
265359
] ffmpeg -i ./test3.webm -c:v libvpx-vp9 -b:v 0 -crf 42 -c:a libopus -b:a 64k -c:s copy /tmp/test/test3.mkv
266360
ffcvt: to execute -
267361
ffmpeg -i ./test3.webm -c:v libvpx-vp9 -b:v 0 -crf 42 -c:a libopus -b:a 64k -c:s copy /tmp/test/test3.mkv
362+
Time taken so far xxx ms
363+
Finishing the remaining 0% in xxx ms
268364

365+
Transcoding completed in xxx ms
269366
Org Size: 0 MB
270367
New Size: 0 MB
271368
Saved: 0%

test/test-all.sh

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,19 @@ echo
1313
echo '- Test (config.go) cli help output'
1414
$FFCVT > /tmp/ffcvt_test.txt 2>&1
1515

16-
echo - Test transcoding single file
16+
echo - Test transcoding single file | tee -a /tmp/ffcvt_test.txt
1717
$FFCVT -n -debug 0 -f StreamSample.mkv -w /tmp >> /tmp/ffcvt_test.txt 2>&1
1818

19-
echo - Test -sym control
19+
echo - Test transcoding different target types | tee -a /tmp/ffcvt_test.txt
20+
$FFCVT -t webm -n -f StreamSample.mkv -w /tmp >> /tmp/ffcvt_test.txt 2>&1
21+
$FFCVT -t x265-opus -n -f StreamSample.mkv -w /tmp >> /tmp/ffcvt_test.txt 2>&1
22+
$FFCVT -t x264-mp3 -n -f StreamSample.mkv -w /tmp >> /tmp/ffcvt_test.txt 2>&1
23+
$FFCVT -t wx -n -f StreamSample.mkv -w /tmp >> /tmp/ffcvt_test.txt 2>&1
24+
$FFCVT -t youtube -n -f StreamSample.mkv -w /tmp >> /tmp/ffcvt_test.txt 2>&1
25+
$FFCVT -t copy -n -f StreamSample.mkv -w /tmp >> /tmp/ffcvt_test.txt 2>&1
26+
27+
28+
echo - Test -sym control | tee -a /tmp/ffcvt_test.txt
2029
$FFCVT -t x265-opus -n -d . >> /tmp/ffcvt_test.txt 2>&1
2130
$FFCVT -t x265-opus -n -d . -sym >> /tmp/ffcvt_test.txt 2>&1
2231

@@ -25,8 +34,8 @@ $FFCVT -n -d . -sym >> /tmp/ffcvt_test.txt 2>&1
2534

2635
$FFCVT -n -sym -debug 2 -d . -w /tmp >> /tmp/ffcvt_test.txt 2>&1
2736

28-
echo - 'Compare test results (0 means AOK)'
29-
sed -i '/ [0-9.]*[nmµ]*s$/d' /tmp/ffcvt_test.txt
37+
echo - 'Compare test results, 0 means AOK:'
38+
sed -i '/ [0-9.]*[nmµ]*s$/s// xxx ms/' /tmp/ffcvt_test.txt
3039
diff -wU 1 ffcvt_test.txt /tmp/ffcvt_test.txt
3140

3241
ret=$?

0 commit comments

Comments
 (0)