Advertisement
Guest User

Untitled

a guest
Jun 28th, 2016
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.73 KB | None | 0 0
  1.  @Test
  2.     public void testConvertWebm() throws Exception {
  3.         final String webmFormat = "webm";
  4.         final String webmAudioCodec = "libvorbis";
  5.         final String webmVideoCodec = "libvpx";
  6.  
  7.         final FFmpeg ffmpeg = new FFmpeg(ffmpegPath);
  8.         final FFprobe ffprobe = new FFprobe(ffprobePath);
  9.  
  10.         ExecutorService pool = Executors.newFixedThreadPool(5);
  11.         for (int i = 0; i < 5; ++i) {
  12.             final int x = i;
  13.             pool.submit(new Runnable() {
  14.                 @Override
  15.                 public void run() {
  16.                     String outputVideoPath = System.getProperty("java.io.tmpdir") + "/output" + x + ".webm";
  17.                     try {
  18.                         FFmpegBuilder builder = new FFmpegBuilder()
  19.                                 .setInput(inputTestVideo)
  20.                                 .overrideOutputFiles(true)
  21.                                 .addOutput(outputVideoPath)
  22.                                 .setFormat(webmFormat)
  23.                                 .setAudioCodec(webmAudioCodec)
  24.                                 .setVideoCodec(webmVideoCodec)
  25.                                 .setVideoResolution(422, 240)
  26.                                 .done();
  27.                         FFmpegExecutor executor = new FFmpegExecutor(ffmpeg, ffprobe);
  28.                         executor.createJob(builder).run();
  29.                     } finally {
  30.                         File outputVideo = new File(outputVideoPath);
  31.                         if (!outputVideo.exists()) {
  32.                             fail();
  33.                         } else {
  34.                             outputVideo.delete();
  35.                         }
  36.                     }
  37.                 }
  38.             });
  39.         }
  40.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement