RxFFmpeg icon indicating copy to clipboard operation
RxFFmpeg copied to clipboard

hls视频切片,定义hls_segment_filename,执行出错

Open feng99721480 opened this issue 5 years ago • 3 comments

请教下大佬,下面ffmpet命令我在cmd里执行是没问题的,在android里执行就回调IFFmpegListener的onFinish,这是为什么? ffmpeg命令的目的是把rtsp流切片到本地,每个ts以时间戳命名,谢大佬。 private String[] getCutCommand(String rtspAddress, String second, String m3u8Path) {

    //20201202-0000.ts
    //ffmpeg -re -i rtsp://192.168.10.13/RK_100000030.sdp -codec copy -f hls -hls_list_size 0 -hls_wrap 10 -hls_time 10
    // -use_localtime 1 -hls_flags second_level_segment_index -hls_segment_filename %Y%m%d-%%04d.ts output.m3u8

    RxFFmpegCommandList cmdlist = new RxFFmpegCommandList();
    cmdlist.append("-re");
    cmdlist.append("-i");
    cmdlist.append(rtspAddress);
    cmdlist.append("-codec");
    cmdlist.append("copy");
    cmdlist.append("-f");
    cmdlist.append("hls");
    cmdlist.append("-hls_list_size");
    cmdlist.append("0");
    cmdlist.append("-hls_wrap");
    cmdlist.append("10");
    cmdlist.append("-hls_time");
    cmdlist.append(second);
    cmdlist.append("-use_localtime");
    cmdlist.append("1");
    cmdlist.append("-hls_flags");
    cmdlist.append("second_level_segment_index");
    cmdlist.append("-hls_segment_filename");
    cmdlist.append("%Y%m%d-%%04d.ts");
    cmdlist.append(m3u8Path);

    ULog.d(TAG, "getCutCommand === cmdlist.toString:" + cmdlist.toString());

    return cmdlist.build();
}

feng99721480 avatar Dec 02 '20 08:12 feng99721480

我用的是RxFFmpeg:4.8.0-lite

feng99721480 avatar Dec 02 '20 08:12 feng99721480

这是权限导致的吗?可是我读写权限都有啊

2020-12-03 12:32:32.863 15468-15576/fun.unifun.insbot.robot.brain D/TAG_FFMPEG: Successfully opened the file. 2020-12-03 12:32:32.863 15468-15576/fun.unifun.insbot.robot.brain D/TAG_FFMPEG: Parsing a group of options: output url /storage/emulated/0/unifun/video_cut/out.m3u8. 2020-12-03 12:32:32.863 15468-15576/fun.unifun.insbot.robot.brain D/TAG_FFMPEG: Applying option codec (codec name) with argument copy. 2020-12-03 12:32:32.863 15468-15576/fun.unifun.insbot.robot.brain D/TAG_FFMPEG: Applying option f (force format) with argument hls. 2020-12-03 12:32:32.863 15468-15576/fun.unifun.insbot.robot.brain D/TAG_FFMPEG: Successfully parsed a group of options. 2020-12-03 12:32:32.863 15468-15576/fun.unifun.insbot.robot.brain D/TAG_FFMPEG: Opening an output file: /storage/emulated/0/unifun/video_cut/out.m3u8. 2020-12-03 12:32:32.864 15468-15576/fun.unifun.insbot.robot.brain D/TAG_FFMPEG: Successfully opened the file. 2020-12-03 12:32:32.864 15468-15576/fun.unifun.insbot.robot.brain I/TAG_FFMPEG: Opening '20201203-0000.ts' for writing 2020-12-03 12:32:32.864 15468-15576/fun.unifun.insbot.robot.brain D/TAG_FFMPEG: Setting default whitelist 'file,crypto' 2020-12-03 12:32:32.864 15468-15576/fun.unifun.insbot.robot.brain E/TAG_FFMPEG: Could not write header for output file #0 (incorrect codec parameters ?): Read-only file system 2020-12-03 12:32:32.864 15468-15576/fun.unifun.insbot.robot.brain I/TAG_FFMPEG: Stream mapping: 2020-12-03 12:32:32.864 15468-15576/fun.unifun.insbot.robot.brain I/TAG_FFMPEG: Stream #0:0 -> #0:0 2020-12-03 12:32:32.864 15468-15576/fun.unifun.insbot.robot.brain I/TAG_FFMPEG: (copy) 2020-12-03 12:32:32.865 15468-15576/fun.unifun.insbot.robot.brain I/TAG_FFMPEG: Stream #0:1 -> #0:1 2020-12-03 12:32:32.865 15468-15576/fun.unifun.insbot.robot.brain I/TAG_FFMPEG: (copy) 2020-12-03 12:32:32.869 15468-15468/fun.unifun.insbot.robot.brain D/LANPusherCut: MyRxFFmpegSubscriber = onError == 执行出错:转码失败 2020-12-03 12:32:32.869 15468-15576/fun.unifun.insbot.robot.brain D/TAG_FFMPEG: Statistics: 198737 bytes read, 0 seeks 2020-12-03 12:32:32.870 15468-15576/fun.unifun.insbot.robot.brain D/TAG_FFMPEG: Deleting stream...

feng99721480 avatar Dec 03 '20 04:12 feng99721480

搞定了

feng99721480 avatar Dec 03 '20 12:12 feng99721480