diff --git a/app/CMakeLists.txt b/app/CMakeLists.txt index ed4ba6b..d0f5beb 100644 --- a/app/CMakeLists.txt +++ b/app/CMakeLists.txt @@ -31,7 +31,7 @@ add_library( # Sets the name of the library. src/main/cpp/ffmpeg_pusher.cpp src/main/cpp/video_filter.c src/main/cpp/ffprobe_cmd.cpp - src/main/cpp/cut_video.cpp + src/main/cpp/video_cutting.cpp src/main/cpp/visualizer/fft.cpp src/main/cpp/visualizer/fixed_fft.cpp src/main/cpp/visualizer/block_queue.c diff --git a/app/src/main/cpp/cut_video.cpp b/app/src/main/cpp/video_cutting.cpp similarity index 99% rename from app/src/main/cpp/cut_video.cpp rename to app/src/main/cpp/video_cutting.cpp index 70d6262..8d57f66 100644 --- a/app/src/main/cpp/cut_video.cpp +++ b/app/src/main/cpp/video_cutting.cpp @@ -2,7 +2,7 @@ // Created by xu fulong on 2022/5/13. // -#include +#include #ifdef __ANDROID__ #include diff --git a/app/src/main/cpp/cut_video.h b/app/src/main/cpp/video_cutting.h similarity index 100% rename from app/src/main/cpp/cut_video.h rename to app/src/main/cpp/video_cutting.h diff --git a/app/src/main/java/com/frank/ffmpeg/activity/AudioHandleActivity.kt b/app/src/main/java/com/frank/ffmpeg/activity/AudioHandleActivity.kt index e026f3e..36e3688 100644 --- a/app/src/main/java/com/frank/ffmpeg/activity/AudioHandleActivity.kt +++ b/app/src/main/java/com/frank/ffmpeg/activity/AudioHandleActivity.kt @@ -123,8 +123,8 @@ class AudioHandleActivity : BaseActivity() { getString(R.string.audio_add_equalizer), getString(R.string.audio_silence), getString(R.string.audio_volume), - getString(R.string.audio_encode), - getString(R.string.pcm_concat)) + getString(R.string.audio_waveform), + getString(R.string.audio_encode)) layoutAudioHandle = findViewById(R.id.list_audio_item) val layoutManager = StaggeredGridLayoutManager(2, StaggeredGridLayoutManager.VERTICAL) @@ -181,8 +181,7 @@ class AudioHandleActivity : BaseActivity() { } }.start() } - 1 //cut audio, it's best not include special characters - -> { + 1 -> { //cut audio, it's best not include special characters val suffix = FileUtil.getFileSuffix(srcFile) if (suffix == null || suffix.isEmpty()) { return @@ -190,16 +189,14 @@ class AudioHandleActivity : BaseActivity() { outputPath = PATH + File.separator + "cutAudio" + suffix commandLine = FFmpegUtil.cutAudio(srcFile, 10.5f, 15.0f, outputPath) } - 2 //concat audio - -> { + 2 -> { //concat audio if (!FileUtil.checkFileExist(appendFile)) { return } concatAudio(srcFile) return } - 3 //mix audio - -> { + 3 -> { //mix audio if (!FileUtil.checkFileExist(appendFile)) { return } @@ -215,39 +212,33 @@ class AudioHandleActivity : BaseActivity() { FFmpegUtil.mergeAudio(srcFile, appendFile, outputPath) } } - 4 //use AudioTrack to play audio - -> { + 4 -> { //use AudioTrack to play audio val audioIntent = Intent(this@AudioHandleActivity, AudioPlayActivity::class.java) audioIntent.data = Uri.parse(srcFile) startActivity(audioIntent) return } - 5 //change audio speed - -> { + 5 -> { //change audio speed val speed = 2.0f // funny effect, range from 0.5 to 100.0 outputPath = PATH + File.separator + "speed.mp3" commandLine = FFmpegUtil.changeAudioSpeed(srcFile, outputPath, speed) } - 6 //echo effect - -> { + 6 -> { //echo effect val echo = 1000 // echo effect, range from 0 to 90000 outputPath = PATH + File.separator + "echo.mp3" commandLine = FFmpegUtil.audioEcho(srcFile, echo, outputPath) } - 7 //tremolo effect - -> { + 7 -> { //tremolo effect val frequency = 5 // range from 0.1 to 20000.0 val depth = 0.9f // range from 0 to 1 outputPath = PATH + File.separator + "tremolo.mp3" commandLine = FFmpegUtil.audioTremolo(srcFile, frequency, depth, outputPath) } - 8 //audio denoise - -> { + 8 -> { //audio denoise outputPath = PATH + File.separator + "denoise.mp3" commandLine = FFmpegUtil.audioDenoise(srcFile, outputPath) } - 9 // equalizer plus - -> { + 9 -> { // equalizer plus // key:band value:gain=[0-20] val bandList = arrayListOf() bandList.add("6b=5") @@ -259,18 +250,20 @@ class AudioHandleActivity : BaseActivity() { outputPath = PATH + File.separator + "equalize.mp3" commandLine = FFmpegUtil.audioEqualizer(srcFile, bandList, outputPath) } - 10 //silence detect - -> { + 10 -> { //silence detect commandLine = FFmpegUtil.audioSilenceDetect(srcFile) } - 11 // modify volume - -> { + 11 -> { // modify volume val volume = 0.5f // 0.0-1.0 outputPath = PATH + File.separator + "volume.mp3" commandLine = FFmpegUtil.audioVolume(srcFile, volume, outputPath) } - 12 //audio encode - -> { + 12 -> { // audio waveform + outputPath = PATH + File.separator + "waveform.png" + val resolution = "1280x720" + commandLine = FFmpegUtil.showAudioWaveform(srcFile, resolution, outputPath) + } + 13 -> { //audio encode val pcmFile = PATH + File.separator + "raw.pcm" outputPath= PATH + File.separator + "convert.mp3" //sample rate, normal is 8000/16000/44100 @@ -279,20 +272,6 @@ class AudioHandleActivity : BaseActivity() { val channel = 2 commandLine = FFmpegUtil.encodeAudio(pcmFile, outputPath, sampleRate, channel) } - 13 //concat PCM streams - -> { - val srcPCM = PATH + File.separator + "audio.pcm" - val appendPCM = PATH + File.separator + "audio.pcm" - val concatPCM = PATH + File.separator + "concat.pcm" - if (!FileUtil.checkFileExist(srcPCM) || !FileUtil.checkFileExist(appendPCM)) { - return - } - - mHandler.obtainMessage(MSG_BEGIN).sendToTarget() - FileUtil.concatFile(srcPCM, appendPCM, concatPCM) - mHandler.obtainMessage(MSG_FINISH).sendToTarget() - return - } else -> { } } diff --git a/app/src/main/java/com/frank/ffmpeg/util/FFmpegUtil.java b/app/src/main/java/com/frank/ffmpeg/util/FFmpegUtil.java index 7994ef8..91b300f 100644 --- a/app/src/main/java/com/frank/ffmpeg/util/FFmpegUtil.java +++ b/app/src/main/java/com/frank/ffmpeg/util/FFmpegUtil.java @@ -359,7 +359,7 @@ public class FFmpegUtil { */ public static String[] jointVideo(String fileListPath, String outputPath) { // ffmpeg -f concat -safe 0 -i %s -c copy %s - String jointVideoCmd = "ffmpeg -f concat -safe 0 -i -c copy"; + String jointVideoCmd = "ffmpeg -f concat -safe 0 -i file.txt -c copy %s"; return insert(jointVideoCmd.split(" "), 6, fileListPath, outputPath); } @@ -820,4 +820,11 @@ public class FFmpegUtil { return insert(trimCmd.split(" "), 2, inputPath, outputPath); } + public static String[] showAudioWaveform(String inputPath, String resolution, String outputPath) { + String waveformCmd = "ffmpeg -i -filter_complex showwavespic=s=%s"; + waveformCmd = String.format(Locale.getDefault(), waveformCmd, resolution); + return insert(waveformCmd.split(" "), 2, inputPath, outputPath); + } + + // ffmpeg -i beyond.mp4 -vf stereo3d=sbsl:arbg -y left3d.mp4 } diff --git a/app/src/main/res/layout/activity_audio_handle.xml b/app/src/main/res/layout/activity_audio_handle.xml index 7e82aa5..d4ea432 100644 --- a/app/src/main/res/layout/activity_audio_handle.xml +++ b/app/src/main/res/layout/activity_audio_handle.xml @@ -64,14 +64,6 @@ android:layout_marginTop="10dp" android:visibility="gone"/> -