视频压缩(存疑)

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/zsp_android_com/article/details/81706695

资料

官网
FFmpeg
参考一
参考二

FFmpegLibrary

使用

gradle(module)

allprojects {
    repositories {
        google()
        jcenter()
        maven { url "https://jitpack.io" }
    }
}

gradle(app)

implementation 'com.github.kui92:FFmpegLibrary:3.2'

主代码

videoCompress(videoFile.getAbsolutePath());

/**
 * 视频压缩(10:1)
 *
 * @param videoPath 视频路径
 */
public void videoCompress(final String videoPath) {
    ExecutorService executorService = Executors.newFixedThreadPool(3);
    final FfmpegTool ffmpegTool = FfmpegTool.getInstance(this);
    File file = new File(videoPath);
    if (file.exists()) {
        LogUtils.e("视频压缩中");
        executorService.execute(new Runnable() {
            @Override
            public void run() {
                // 压缩存路径
                String path = Environment.getExternalStorageDirectory().getAbsolutePath() + File.separator + "dfs" + File.separator + "VideoCompress";
                File file1 = new File(path);
                if (!file1.exists()) {
                    file1.mkdirs();
                }
                ffmpegTool.compressVideo(videoPath, path + File.separator, 3, new FfmpegTool.VideoResult() {
                    @Override
                    public void clipResult(int i, String s, String s1, boolean b, int i1) {
                        if (!b) {
                            LogUtils.e("视频压缩失败");
                        }
                        String[] dataStr = s1.split("/");
                        StringBuilder stringBuilder = new StringBuilder(Environment.getExternalStorageDirectory().getAbsolutePath());
                        for (int ii = 4; ii < dataStr.length; ii++) {
                            stringBuilder.append("/").append(dataStr[ii]);
                        }
                        LogUtils.e("视频压缩成功" + stringBuilder);
                        LogUtils.e("压缩前视频", s);
                        LogUtils.e("压缩后视频", s1);
                    }
                });
            }
        });
    } else {
        toastShort("未找到视频,重新操作");
    }
}

问题

相机录制视频后于APP选已录视频压缩正常

标识符
content://com.android.providers.media.documents/document/video%3A695716
路径
/storage/emulated/0/video/video:695717

APP调相机录视频后压缩失败

标识符
content://com.self.zsp.dfs.fileprovider/temp/Movies/DfsVideo/20180816_095008.mp4

日志

08-16 16:16:16.180 12137-12137/com.self.zsp.dfs A/libc: Fatal signal 11 (SIGSEGV), code 1, fault addr 0x8 in tid 12137 (om.self.zsp.dfs)
08-16 16:16:16.231 2228-4226/? E/HsmCoreServiceImpl: onTransact in code is: 103
08-16 16:16:16.265 12859-12859/? A/DEBUG: *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
    Build fingerprint: 'HONOR/DUK-TL30/HWDUK:8.0.0/HUAWEIDUK-TL30/350(C01):user/release-keys'
    Revision: '0'
    ABI: 'arm64'
    pid: 12137, tid: 12137, name: om.self.zsp.dfs  >>> com.self.zsp.dfs <<<
    signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0x8
    Cause: null pointer dereference
        x0   0000000000000000  x1   00000078dcab1a3e  x2   0000007fdc7fa2d4  x3   0000007fdc7fa2d4
        x4   8020080280200802  x5   8080808080808080  x6   3831ff08fefeff0f  x7   0000000000000008
        x8   00000078e88e9390  x9   ea7af9904e6f7ed5  x10  0000000000000001  x11  0000000000000000
        x12  0000000000000000  x13  00000078eda4b990  x14  000000790c5f5a74  x15  0000000000000000
        x16  00000078dc9624b8  x17  00000078dca0a3f4  x18  00000000000000bc  x19  0000000000000000
        x20  00000078dc963090  x21  00000078edfca300  x22  00000078c4b73820  x23  0000000000000000
        x24  00000078dc963088  x25  00000078dc963098  x26  00000078edebb400  x27  00000078c4b73780
        x28  00000078eda1d400  x29  0000007fdc7fbf00  x30  00000078dc92dd5c
        sp   0000007fdc7fa930  pc   00000078dca0a40c  pstate 0000000060000000
08-16 16:16:16.290 12859-12859/? A/DEBUG: backtrace:
        #00 pc 000000000008540c  /data/app/com.self.zsp.dfs-V6XhBaQ5JrAy25Mku1c45g==/lib/arm64/libavfilter.so (av_buffersink_get_frame_rate+24)
        #01 pc 0000000000015d58  /data/app/com.self.zsp.dfs-V6XhBaQ5JrAy25Mku1c45g==/lib/arm64/libjxffmpegrun.so
        #02 pc 0000000000013e60  /data/app/com.self.zsp.dfs-V6XhBaQ5JrAy25Mku1c45g==/lib/arm64/libjxffmpegrun.so (jxRun+536)
        #03 pc 000000000002b5a0  /data/app/com.self.zsp.dfs-V6XhBaQ5JrAy25Mku1c45g==/lib/arm64/libjxffmpegrun.so (Java_com_esay_ffmtool_FfmpegTool_cmdRun+196)
        #04 pc 0000000000512700  /system/lib64/libart.so (art_quick_generic_jni_trampoline+144)
        #05 pc 0000000000509638  /system/lib64/libart.so (art_quick_invoke_static_stub+600)
        #06 pc 00000000000d80b4  /system/lib64/libart.so (_ZN3art9ArtMethod6InvokeEPNS_6ThreadEPjjPNS_6JValueEPKc+260)
        #07 pc 00000000002821dc  /system/lib64/libart.so (_ZN3art11interpreter34ArtInterpreterToCompiledCodeBridgeEPNS_6ThreadEPNS_9ArtMethodEPKNS_7DexFile8CodeItemEPNS_11ShadowFrameEPNS_6JValueE+352)
        #08 pc 000000000027c8a4  /system/lib64/libart.so (_ZN3art11interpreter6DoCallILb0ELb0EEEbPNS_9ArtMethodEPNS_6ThreadERNS_11ShadowFrameEPKNS_11InstructionEtPNS_6JValueE+672)
        #09 pc 00000000004f2130  /system/lib64/libart.so (MterpInvokeStatic+468)
        #10 pc 00000000004fae94  /system/lib64/libart.so (ExecuteMterpImpl+14612)
        #11 pc 000000000025d620  /system/lib64/libart.so (_ZN3art11interpreterL7ExecuteEPNS_6ThreadEPKNS_7DexFile8CodeItemERNS_11ShadowFrameENS_6JValueEb+444)
        #12 pc 0000000000263d20  /system/lib64/libart.so (_ZN3art11interpreter33ArtInterpreterToInterpreterBridgeEPNS_6ThreadEPKNS_7DexFile8CodeItemEPNS_11ShadowFrameEPNS_6JValueE+212)
        #13 pc 000000000027c884  /system/lib64/libart.so (_ZN3art11interpreter6DoCallILb0ELb0EEEbPNS_9ArtMethodEPNS_6ThreadERNS_11ShadowFrameEPKNS_11InstructionEtPNS_6JValueE+640)
        #14 pc 00000000004f0b0c  /system/lib64/libart.so (MterpInvokeVirtual+612)
        #15 pc 00000000004fad14  /system/lib64/libart.so (ExecuteMterpImpl+14228)
        #16 pc 000000000025d620  /system/lib64/libart.so (_ZN3art11interpreterL7ExecuteEPNS_6ThreadEPKNS_7DexFile8CodeItemERNS_11ShadowFrameENS_6JValueEb+444)
        #17 pc 0000000000263d20  /system/lib64/libart.so (_ZN3art11interpreter33ArtInterpreterToInterpreterBridgeEPNS_6ThreadEPKNS_7DexFile8CodeItemEPNS_11ShadowFrameEPNS_6JValueE+212)
        #18 pc 000000000027c884  /system/lib64/libart.so (_ZN3art11interpreter6DoCallILb0ELb0EEEbPNS_9ArtMethodEPNS_6ThreadERNS_11ShadowFrameEPKNS_11InstructionEtPNS_6JValueE+640)
        #19 pc 00000000004f0b0c  /system/lib64/libart.so (MterpInvokeVirtual+612)
        #20 pc 00000000004fad14  /system/lib64/libart.so (ExecuteMterpImpl+14228)
        #21 pc 000000000025d620  /system/lib64/libart.so (_ZN3art11interpreterL7ExecuteEPNS_6ThreadEPKNS_7DexFile8CodeItemERNS_11ShadowFrameENS_6JValueEb+444)
08-16 16:16:16.291 12859-12859/? A/DEBUG:     #22 pc 0000000000263d20  /system/lib64/libart.so (_ZN3art11interpreter33ArtInterpreterToInterpreterBridgeEPNS_6ThreadEPKNS_7DexFile8CodeItemEPNS_11ShadowFrameEPNS_6JValueE+212)
        #23 pc 000000000027c884  /system/lib64/libart.so (_ZN3art11interpreter6DoCallILb0ELb0EEEbPNS_9ArtMethodEPNS_6ThreadERNS_11ShadowFrameEPKNS_11InstructionEtPNS_6JValueE+640)
        #24 pc 00000000004f0b0c  /system/lib64/libart.so (MterpInvokeVirtual+612)
        #25 pc 00000000004fad14  /system/lib64/libart.so (ExecuteMterpImpl+14228)
        #26 pc 000000000025d620  /system/lib64/libart.so (_ZN3art11interpreterL7ExecuteEPNS_6ThreadEPKNS_7DexFile8CodeItemERNS_11ShadowFrameENS_6JValueEb+444)
        #27 pc 0000000000263d20  /system/lib64/libart.so (_ZN3art11interpreter33ArtInterpreterToInterpreterBridgeEPNS_6ThreadEPKNS_7DexFile8CodeItemEPNS_11ShadowFrameEPNS_6JValueE+212)
        #28 pc 000000000027c884  /system/lib64/libart.so (_ZN3art11interpreter6DoCallILb0ELb0EEEbPNS_9ArtMethodEPNS_6ThreadERNS_11ShadowFrameEPKNS_11InstructionEtPNS_6JValueE+640)
        #29 pc 00000000004f0b0c  /system/lib64/libart.so (MterpInvokeVirtual+612)
        #30 pc 00000000004fad14  /system/lib64/libart.so (ExecuteMterpImpl+14228)
        #31 pc 000000000025d620  /system/lib64/libart.so (_ZN3art11interpreterL7ExecuteEPNS_6ThreadEPKNS_7DexFile8CodeItemERNS_11ShadowFrameENS_6JValueEb+444)
        #32 pc 0000000000263d20  /system/lib64/libart.so (_ZN3art11interpreter33ArtInterpreterToInterpreterBridgeEPNS_6ThreadEPKNS_7DexFile8CodeItemEPNS_11ShadowFrameEPNS_6JValueE+212)
        #33 pc 000000000027c884  /system/lib64/libart.so (_ZN3art11interpreter6DoCallILb0ELb0EEEbPNS_9ArtMethodEPNS_6ThreadERNS_11ShadowFrameEPKNS_11InstructionEtPNS_6JValueE+640)
        #34 pc 00000000004f1e78  /system/lib64/libart.so (MterpInvokeDirect+504)
        #35 pc 00000000004fae14  /system/lib64/libart.so (ExecuteMterpImpl+14484)
        #36 pc 000000000025d620  /system/lib64/libart.so (_ZN3art11interpreterL7ExecuteEPNS_6ThreadEPKNS_7DexFile8CodeItemERNS_11ShadowFrameENS_6JValueEb+444)
        #37 pc 0000000000263d20  /system/lib64/libart.so (_ZN3art11interpreter33ArtInterpreterToInterpreterBridgeEPNS_6ThreadEPKNS_7DexFile8CodeItemEPNS_11ShadowFrameEPNS_6JValueE+212)
        #38 pc 000000000027c884  /system/lib64/libart.so (_ZN3art11interpreter6DoCallILb0ELb0EEEbPNS_9ArtMethodEPNS_6ThreadERNS_11ShadowFrameEPKNS_11InstructionEtPNS_6JValueE+640)
        #39 pc 00000000004f1e78  /system/lib64/libart.so (MterpInvokeDirect+504)
        #40 pc 00000000004fae14  /system/lib64/libart.so (ExecuteMterpImpl+14484)
        #41 pc 000000000025d620  /system/lib64/libart.so (_ZN3art11interpreterL7ExecuteEPNS_6ThreadEPKNS_7DexFile8CodeItemERNS_11ShadowFrameENS_6JValueEb+444)
        #42 pc 0000000000263d20  /system/lib64/libart.so (_ZN3art11interpreter33ArtInterpreterToInterpreterBridgeEPNS_6ThreadEPKNS_7DexFile8CodeItemEPNS_11ShadowFrameEPNS_6JValueE+212)
        #43 pc 000000000027c884  /system/lib64/libart.so (_ZN3art11interpreter6DoCallILb0ELb0EEEbPNS_9ArtMethodEPNS_6ThreadERNS_11ShadowFrameEPKNS_11InstructionEtPNS_6JValueE+640)
        #44 pc 00000000004f2130  /system/lib64/libart.so (MterpInvokeStatic+468)
        #45 pc 00000000004fae94  /system/lib64/libart.so (ExecuteMterpImpl+14612)
        #46 pc 000000000025d620  /system/lib64/libart.so (_ZN3art11interpreterL7ExecuteEPNS_6ThreadEPKNS_7DexFile8CodeItemERNS_11ShadowFrameENS_6JValueEb+444)
        #47 pc 0000000000263d20  /system/lib64/libart.so (_ZN3art11interpreter33ArtInterpreterToInterpreterBridgeEPNS_6ThreadEPKNS_7DexFile8CodeItemEPNS_11ShadowFrameEPNS_6JValueE+212)
        #48 pc 000000000027c884  /system/lib64/libart.so (_ZN3art11interpreter6DoCallILb0ELb0EEEbPNS_9ArtMethodEPNS_6ThreadERNS_11ShadowFrameEPKNS_11InstructionEtPNS_6JValueE+640)
        #49 pc 00000000004f0b0c  /system/lib64/libart.so (MterpInvokeVirtual+612)
        #50 pc 00000000004fad14  /system/lib64/libart.so (ExecuteMterpImpl+14228)
        #51 pc 000000000025d620  /system/lib64/libart.so (_ZN3art11interpreterL7ExecuteEPNS_6ThreadEPKNS_7DexFile8CodeItemERNS_11ShadowFrameENS_6JValueEb+444)
        #52 pc 0000000000263d20  /system/lib64/libart.so (_ZN3art11interpreter33ArtInterpreterToInterpreterBridgeEPNS_6ThreadEPKNS_7DexFile8CodeItemEPNS_11ShadowFrameEPNS_6JValueE+212)
        #53 pc 000000000027c884  /system/lib64/libart.so (_ZN3art11interpreter6DoCallILb0ELb0EEEbPNS_9ArtMethodEPNS_6ThreadERNS_11ShadowFrameEPKNS_11InstructionEtPNS_6JValueE+640)
        #54 pc 00000000004f0b0c  /system/lib64/libart.so (MterpInvokeVirtual+612)
        #55 pc 00000000004fad14  /system/lib64/libart.so (ExecuteMterpImpl+14228)
        #56 pc 000000000025d620  /system/lib64/libart.so (_ZN3art11interpreterL7ExecuteEPNS_6ThreadEPKNS_7DexFile8CodeItemERNS_11ShadowFrameENS_6JValueEb+444)
        #57 pc 0000000000263d20  /system/lib64/libart.so (_ZN3art11interpreter33ArtInterpreterToInterpreterBridgeEPNS_6ThreadEPKNS_7DexFile8CodeItemEPNS_11ShadowFrameEPNS_6JValueE+212)
        #58 pc 000000000027c884  /system/lib64/libart.so (_ZN3art11interpreter6DoCallILb0ELb0EEEbPNS_9ArtMethodEPNS_6ThreadERNS_11ShadowFrameEPKNS_11InstructionEtPNS_6JValueE+640)
        #59 pc 00000000004f2130  /system/lib64/libart.so (MterpInvokeStatic+468)
        #60 pc 00000000004fae94  /system/lib64/libart.so (ExecuteMterpImpl+14612)
        #61 pc 000000000025d620  /system/lib64/libart.so (_ZN3art11interpreterL7ExecuteEPNS_6ThreadEPKNS_7DexFile8CodeItemERNS_11ShadowFrameENS_6JValueEb+444)
        #62 pc 00000000004e4a88  /system/lib64/libart.so (artQuickToInterpreterBridge+1468)
        #63 pc 000000000051281c  /system/lib64/libart.so (art_quick_to_interpreter_bridge+92)

弥补

方式生视频压缩正常。

猜你喜欢

转载自blog.csdn.net/zsp_android_com/article/details/81706695