| | |
| | | int framerate = config != null && config.framerate > 0 ? config.framerate : DEFAULT_FRAME_RATE; |
| | | h264Encoder.setEncoderParams(width, height, framerate, DEFAULT_BITRATE); |
| | | |
| | | long timeFile = System.currentTimeMillis()/1000*1000;//Date是秒,所以为了跟下发的Date starttime一致,此处除以1000 秒 |
| | | SimpleDateFormat bcdFormat = new SimpleDateFormat("yyMMddHHmmss"); |
| | | String str = bcdFormat.format(timeFile); |
| | | Timber.i("文件名:%s", str); |
| | | // 设置输出文件 |
| | | String fileName = "h264_" + timeFile+ ".h264"; |
| | | File outputFile = new File(outputFileDirectory, fileName); |
| | | h264Encoder.setOutputFile(outputFile.getAbsolutePath()); |
| | | // 设置输出文件目录(H264Encoder会自动管理文件创建,每分钟一个文件) |
| | | // 使用一个临时文件名来设置目录,H264Encoder会在初始化时创建第一个文件 |
| | | File tempFile = new File(outputFileDirectory, "temp.h264"); |
| | | h264Encoder.setOutputFile(tempFile.getAbsolutePath()); |
| | | h264Encoder.setEnableFileOutput(true); // 启用文件输出 |
| | | |
| | | // 禁用网络传输 |
| | |
| | | Timber.d("Applied saved watermark info to encoder"); |
| | | } |
| | | h264Encoder.start(); |
| | | Timber.d("File encode started successfully, output file: %s, resolution: %dx%d, framerate: %d", |
| | | outputFile.getAbsolutePath(), width, height, framerate); |
| | | Timber.d("File encode started successfully, output directory: %s, resolution: %dx%d, framerate: %d", |
| | | outputFileDirectory, width, height, framerate); |
| | | return 0; // 成功 |
| | | } else { |
| | | Timber.e("Failed to initialize encoder"); |
| | |
| | | int framerate = config != null && config.framerate > 0 ? config.framerate : DEFAULT_FRAME_RATE; |
| | | h264Encoder.setEncoderParams(width, height, framerate, DEFAULT_BITRATE); |
| | | |
| | | long timeFile = System.currentTimeMillis()/1000*1000; |
| | | SimpleDateFormat bcdFormat = new SimpleDateFormat("yyMMddHHmmss"); |
| | | String str = bcdFormat.format(timeFile); |
| | | Timber.i("startNetworkEncode 文件名:%s", str); |
| | | // 设置输出文件 |
| | | String fileName = "h264_" + timeFile+ ".h264"; |
| | | File outputFile = new File(outputFileDirectory, fileName); |
| | | h264Encoder.setOutputFile(outputFile.getAbsolutePath()); |
| | | // 设置输出文件目录(H264Encoder会自动管理文件创建,每分钟一个文件) |
| | | // 使用一个临时文件名来设置目录,H264Encoder会在初始化时创建第一个文件 |
| | | File tempFile = new File(outputFileDirectory, "temp.h264"); |
| | | h264Encoder.setOutputFile(tempFile.getAbsolutePath()); |
| | | h264Encoder.setEnableFileOutput(true); // 启用文件输出 |
| | | |
| | | |