ffmpeg不在java应用程序中转换整个视频

时间:2017-12-12 06:39:51

标签: java video ffmpeg

我的代码将视频转换为不同的格式(160p到2160p)。需要更改带有旋转标签90的视频编解码器。下面是id的代码,适用于所有视频直到日期。

log_wfm.debug("Changing the codec video for file [" + orgFileName + "] and name of source file ["
                    + srcFileName + "]");
            String codecFlipCommand = "ffmpeg -i " + orgFileName + " -c:v libx264 -preset ultrafast " + srcFileName;

            log_wfm.info("Executing command to change the codec of video!");
            fp = Runtime.getRuntime().exec(codecFlipCommand);

            inputStream = new BufferedReader(new InputStreamReader(fp.getInputStream()));
            outputStream = new BufferedReader(new InputStreamReader(fp.getErrorStream()));

            StringBuffer output = new StringBuffer();
            String line;
            while ((line = inputStream.readLine()) != null) {
                output.append(line).append('\n');
            }
            log_wfm.debug("stdInputForCodecChange: " + output);

            output = new StringBuffer();
            while ((line = outputStream.readLine()) != null) {
                output.append(line).append('\n');
            }
            log_wfm.debug("stdErrorForCodecChange: " + output);

现在有一个1.5Gb大小的文件。视频不会使用更改的编解码器创建文件。创建大小为848.5 MB的文件,然后程序挂起(没有异常或错误日志) 请提供一些方法来完成此编解码器更改过程。
ffmpeg命令转换视频,但是通过java应用程序,进程挂起
日志通过commandLine进行转换时:
    ffmpeg version N-83433-ge87a4a8 Copyright (c) 2000-2017 the FFmpeg developers built with gcc 6.3.1 (GCC) 20161221 (Red Hat 6.3.1-1) configuration: --prefix=/root/ffmpeg_build --extra-cflags=-I/root/ffmpeg_build/include --extra-ldflags='-L/root/ffmpeg_build/lib -ldl' --bindir=/root/bin --pkg-config-flags=--static --enable-gpl --enable-nonfree --enable-libfdk_aac --enable-libfreetype --enable-libmp3lame --enable-libopus --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libx265 libavutil 55. 46.100 / 55. 46.100 libavcodec 57. 75.100 / 57. 75.100 libavformat 57. 66.101 / 57. 66.101 libavdevice 57. 2.100 / 57. 2.100 libavfilter 6. 73.100 / 6. 73.100 libswscale 4. 3.101 / 4. 3.101 libswresample 2. 4.100 / 2. 4.100 libpostproc 54. 2.100 / 54. 2.100 Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '/home/urvashi/test/SachinSagaGameLaunchEvent.mp4': Metadata: major_brand : mp42 minor_version : 0 compatible_brands: isommp42 creation_time : 2017-12-07T06:26:23.000000Z com.android.version: 7.1.1 Duration: 00:14:16.02, start: 0.000000, bitrate: 14231 kb/s Stream #0:0(eng): Video: h264 (High) (avc1 / 0x31637661), yuv420p(tv, bt709), 1920x1080, 13971 kb/s, SAR 1:1 DAR 16:9, 29.94 fps, 29.92 tbr, 90k tbn, 180k tbc (default) Metadata: rotate : 90 creation_time : 2017-12-07T06:26:23.000000Z handler_name : VideoHandle Side data: displaymatrix: rotation of -90.00 degrees Stream #0:1(eng): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 256 kb/s (default) Metadata: creation_time : 2017-12-07T06:26:23.000000Z handler_name : SoundHandle [libx264 @ 0x4601a20] using SAR=1/1 [libx264 @ 0x4601a20] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX FMA3 AVX2 LZCNT BMI2 [libx264 @ 0x4601a20] profile Constrained Baseline, level 4.0 [libx264 @ 0x4601a20] 264 - core 148 - H.264/MPEG-4 AVC codec - Copyleft 2003-2017 - http://www.videolan.org/x264.html - options: cabac=0 ref=1 deblock=0:0:0 analyse=0:0 me=dia subme=0 psy=1 psy_rd=1.00:0.00 mixed_ref=0 me_range=16 chroma_me=1 trellis=0 8x8dct=0 cqm=0 deadzone=21,11 fast_pskip=1 chroma_qp_offset=0 threads=6 lookahead_threads=1 sliced_threads=0 nr=0 decimate=1 interlaced=0 bluray_compat=0 constrained_intra=0 bframes=0 weightp=0 keyint=250 keyint_min=25 scenecut=0 intra_refresh=0 rc=crf mbtree=0 crf=23.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 ip_ratio=1.40 aq=0 Output #0, mp4, to '/home/urvashi/test/Manual_SachinSagaGameLaunchEvent.mp4': Metadata: major_brand : mp42 minor_version : 0 compatible_brands: isommp42 com.android.version: 7.1.1 encoder : Lavf57.66.101 Stream #0:0(eng): Video: h264 (libx264) ([33][0][0][0] / 0x0021), yuv420p, 1080x1920 [SAR 1:1 DAR 9:16], q=-1--1, 29.92 fps, 11488 tbn, 29.92 tbc (default) Metadata: handler_name : VideoHandle creation_time : 2017-12-07T06:26:23.000000Z encoder : Lavc57.75.100 libx264 Side data: cpb: bitrate max/min/avg: 0/0/0 buffer size: 0 vbv_delay: -1 Stream #0:1(eng): Audio: aac (LC) ([64][0][0][0] / 0x0040), 48000 Hz, stereo, fltp, 128 kb/s (default) Metadata: creation_time : 2017-12-07T06:26:23.000000Z handler_name : SoundHandle encoder : Lavc57.75.100 aac Stream mapping: Stream #0:0 -> #0:0 (h264 (native) -> h264 (libx264)) Stream #0:1 -> #0:1 (aac (native) -> aac (native)) Press [q] to stop, [?] for help Past duration 0.600212 too large 48193kB time=00:00:27.26 bitrate=14479.2kbits/s speed=2.07x Past duration 0.998863 too large frame=25611 fps= 55 q=-1.0 Lsize= 1721466kB time=00:14:16.04 bitrate=16473.7kbits/s dup=0 drop=17 speed=1.85x video:1707295kB audio:13453kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.041757% [libx264 @ 0x4601a20] frame I:103 Avg QP:22.16 size:242916 [libx264 @ 0x4601a20] frame P:25508 Avg QP:25.17 size: 67557

先谢谢。

0 个答案:

没有答案