首页 文章

压缩的mp4视频播放时间太长(exoplayer)

提问于
浏览
0

视频(mp4)从Android摄像头录制并发送到后端,这里我使用ffmpeg包装器压缩视频[44mb视频到5.76mb] . 压缩效果很好,但是当我在android(exo播放器)发送视频播放时,开始时间太长 .

下面是我要压缩的代码:

FFmpegBuilder builder = new FFmpegBuilder()
                   .setInput("D:/dummyVideos/myvideo.mp4")     // Filename, or a FFmpegProbeResult
                   .overrideOutputFiles(true) // Override the output if it exists
                   .addOutput("D:/dummyVideos/myvideo_ffmpeg.mp4")   // Filename for the destination
                   .setFormat("mp4")       // Format is inferred from filename, or can be set
                   .disableSubtitle()       // No subtiles
                   .setAudioChannels(1)         // Mono audio
                   .setAudioCodec("aac")       // using the aac codec
                   .setAudioSampleRate(48_000) // at 48KHz
                   .setAudioBitRate(32768)     // at 32 kbit/s
                   .setVideoCodec("libx264")     // Video using x264
                   .setVideoFrameRate(24, 1)     // at 24 frames per second 
                   .setVideoResolution(1280, 720) // at 640x480 resolution
                   .setVideoBitRate(762800)
                   .setStrict(FFmpegBuilder.Strict.EXPERIMENTAL) // Allow FFmpeg to use experimental specs
                   .done();

任何人都可以告诉我为什么视频在exo播放器中播放时间太长?压缩有什么不对吗?

1 回答

  • 0

    根据我在这里写的评论,由于"moov"原子视频需要很长时间才能播放,以下是描述的博客:https://rigor.com/blog/2016/01/optimizing-mp4-video-for-fast-streaming

    代码是:

    try{
            QtFastStart.fastStart(inputFile, outputFile); // Adds moov to your input
                       // Now your output file is ready to stream!
            }catch (QtFastStart.MalformedFileException m){
                logger.error("QT", m);
            }catch (QtFastStart.UnsupportedFileException q){
                logger.error("QT", q);
            }catch (IOException i){
                logger.error("QT", i);              
            }
    

相关问题