From 5e1db34a57256e8764b83023e670842d14ee0de6 Mon Sep 17 00:00:00 2001 From: xufuji456 <839789740@qq.com> Date: Sat, 30 Jan 2021 21:44:15 +0800 Subject: [PATCH] change entity to kotlin --- .../ffmpeg/activity/VideoHandleActivity.kt | 6 +- .../com/frank/ffmpeg/model/AudioBean.java | 56 ---------- .../java/com/frank/ffmpeg/model/AudioBean.kt | 24 +++++ .../com/frank/ffmpeg/model/MediaBean.java | 83 --------------- .../java/com/frank/ffmpeg/model/MediaBean.kt | 27 +++++ .../com/frank/ffmpeg/model/VideoBean.java | 100 ------------------ .../java/com/frank/ffmpeg/model/VideoBean.kt | 36 +++++++ 7 files changed, 90 insertions(+), 242 deletions(-) delete mode 100644 app/src/main/java/com/frank/ffmpeg/model/AudioBean.java create mode 100644 app/src/main/java/com/frank/ffmpeg/model/AudioBean.kt delete mode 100644 app/src/main/java/com/frank/ffmpeg/model/MediaBean.java create mode 100644 app/src/main/java/com/frank/ffmpeg/model/MediaBean.kt delete mode 100644 app/src/main/java/com/frank/ffmpeg/model/VideoBean.java create mode 100644 app/src/main/java/com/frank/ffmpeg/model/VideoBean.kt diff --git a/app/src/main/java/com/frank/ffmpeg/activity/VideoHandleActivity.kt b/app/src/main/java/com/frank/ffmpeg/activity/VideoHandleActivity.kt index 9a8eff8..5df9aa1 100644 --- a/app/src/main/java/com/frank/ffmpeg/activity/VideoHandleActivity.kt +++ b/app/src/main/java/com/frank/ffmpeg/activity/VideoHandleActivity.kt @@ -358,9 +358,9 @@ class VideoHandleActivity : BaseActivity() { //probe width and height of the selected video val probeResult = FFmpegCmd.executeProbeSynchronize(FFmpegUtil.probeFormat(selectedPath)) val mediaBean = JsonParseTool.parseMediaFormat(probeResult) - if (mediaBean != null && mediaBean.videoBean != null) { - width = mediaBean.videoBean.width - height = mediaBean.videoBean.height + if (mediaBean?.videoBean != null) { + width = mediaBean.videoBean!!.width + height = mediaBean.videoBean!!.height Log.e(TAG, "width=$width--height=$height") } val transformCmd2 = FFmpegUtil.transformVideoWithEncode(appendPath, width, height, outputPath2) diff --git a/app/src/main/java/com/frank/ffmpeg/model/AudioBean.java b/app/src/main/java/com/frank/ffmpeg/model/AudioBean.java deleted file mode 100644 index 398801b..0000000 --- a/app/src/main/java/com/frank/ffmpeg/model/AudioBean.java +++ /dev/null @@ -1,56 +0,0 @@ -package com.frank.ffmpeg.model; - -/** - * the model of audio data - * Created by frank on 2020/1/7. - */ -public class AudioBean { - - //"codec_tag_string": "mp4a" - private String audioCodec; - - //"sample_rate": "44100" - private int sampleRate; - - //"channels": 2 - private int channels; - - //"channel_layout": "stereo" - private String channelLayout; - - public String getAudioCodec() { - if ("[0][0][0][0]".equals(audioCodec)) { - return null; - } - return audioCodec; - } - - public void setAudioCodec(String audioCodec) { - this.audioCodec = audioCodec; - } - - public int getSampleRate() { - return sampleRate; - } - - public void setSampleRate(int sampleRate) { - this.sampleRate = sampleRate; - } - - public int getChannels() { - return channels; - } - - public void setChannels(int channels) { - this.channels = channels; - } - - public String getChannelLayout() { - return channelLayout; - } - - public void setChannelLayout(String channelLayout) { - this.channelLayout = channelLayout; - } - -} diff --git a/app/src/main/java/com/frank/ffmpeg/model/AudioBean.kt b/app/src/main/java/com/frank/ffmpeg/model/AudioBean.kt new file mode 100644 index 0000000..47361a0 --- /dev/null +++ b/app/src/main/java/com/frank/ffmpeg/model/AudioBean.kt @@ -0,0 +1,24 @@ +package com.frank.ffmpeg.model + +/** + * the model of audio data + * Created by frank on 2020/1/7. + */ +class AudioBean { + + //"codec_tag_string": "mp4a" + var audioCodec: String? = null + get() = if ("[0][0][0][0]" == field) { + null + } else field + + //"sample_rate": "44100" + var sampleRate: Int = 0 + + //"channels": 2 + var channels: Int = 0 + + //"channel_layout": "stereo" + var channelLayout: String? = null + +} diff --git a/app/src/main/java/com/frank/ffmpeg/model/MediaBean.java b/app/src/main/java/com/frank/ffmpeg/model/MediaBean.java deleted file mode 100644 index 81e89d5..0000000 --- a/app/src/main/java/com/frank/ffmpeg/model/MediaBean.java +++ /dev/null @@ -1,83 +0,0 @@ -package com.frank.ffmpeg.model; - -/** - * the model of media data - * Created by frank on 2020/1/7. - */ -public class MediaBean { - - private VideoBean videoBean; - - private AudioBean audioBean; - - // "duration": "313.330000" - private long duration; - - // "size": "22160429" - private long size; - - // "bit_rate": "565804" - private int bitRate; - - // "format_name": "mov,mp4,m4a,3gp,3g2,mj2" - private String formatName; - - // "nb_streams": 2 - private int streamNum; - - public VideoBean getVideoBean() { - return videoBean; - } - - public void setVideoBean(VideoBean videoBean) { - this.videoBean = videoBean; - } - - public AudioBean getAudioBean() { - return audioBean; - } - - public void setAudioBean(AudioBean audioBean) { - this.audioBean = audioBean; - } - - public long getDuration() { - return duration; - } - - public void setDuration(long duration) { - this.duration = duration; - } - - public long getSize() { - return size; - } - - public void setSize(long size) { - this.size = size; - } - - public int getBitRate() { - return bitRate; - } - - public void setBitRate(int bitRate) { - this.bitRate = bitRate; - } - - public String getFormatName() { - return formatName; - } - - public void setFormatName(String formatName) { - this.formatName = formatName; - } - - public int getStreamNum() { - return streamNum; - } - - public void setStreamNum(int streamNum) { - this.streamNum = streamNum; - } -} diff --git a/app/src/main/java/com/frank/ffmpeg/model/MediaBean.kt b/app/src/main/java/com/frank/ffmpeg/model/MediaBean.kt new file mode 100644 index 0000000..e28be18 --- /dev/null +++ b/app/src/main/java/com/frank/ffmpeg/model/MediaBean.kt @@ -0,0 +1,27 @@ +package com.frank.ffmpeg.model + +/** + * the model of media data + * Created by frank on 2020/1/7. + */ +class MediaBean { + + var videoBean: VideoBean? = null + + var audioBean: AudioBean? = null + + // "duration": "313.330000" + var duration: Long = 0 + + // "size": "22160429" + var size: Long = 0 + + // "bit_rate": "565804" + var bitRate: Int = 0 + + // "format_name": "mov,mp4,m4a,3gp,3g2,mj2" + var formatName: String? = null + + // "nb_streams": 2 + var streamNum: Int = 0 +} diff --git a/app/src/main/java/com/frank/ffmpeg/model/VideoBean.java b/app/src/main/java/com/frank/ffmpeg/model/VideoBean.java deleted file mode 100644 index c7eeef3..0000000 --- a/app/src/main/java/com/frank/ffmpeg/model/VideoBean.java +++ /dev/null @@ -1,100 +0,0 @@ -package com.frank.ffmpeg.model; - -/** - * the model of video data - * Created by frank on 2020/1/7. - */ -public class VideoBean { - - //"codec_tag_string": "avc1" - private String videoCodec; - - //"width": 640 - private int width; - - //"height": 360 - private int height; - - //"display_aspect_ratio": "16:9" - private String displayAspectRatio; - - //"pix_fmt": "yuv420p" - private String pixelFormat; - - //"profile": "578" - private String profile; - - //"level": 30 - private int level; - - //"r_frame_rate": "24000/1001" - private int frameRate; - - public String getVideoCodec() { - if ("[0][0][0][0]".equals(videoCodec)) { - return null; - } - return videoCodec; - } - - public void setVideoCodec(String videoCodec) { - this.videoCodec = videoCodec; - } - - public int getWidth() { - return width; - } - - public void setWidth(int width) { - this.width = width; - } - - public int getHeight() { - return height; - } - - public void setHeight(int height) { - this.height = height; - } - - public String getDisplayAspectRatio() { - return displayAspectRatio; - } - - public void setDisplayAspectRatio(String displayAspectRatio) { - this.displayAspectRatio = displayAspectRatio; - } - - public String getPixelFormat() { - return pixelFormat; - } - - public void setPixelFormat(String pixelFormat) { - this.pixelFormat = pixelFormat; - } - - public String getProfile() { - return profile; - } - - public void setProfile(String profile) { - this.profile = profile; - } - - public int getLevel() { - return level; - } - - public void setLevel(int level) { - this.level = level; - } - - public int getFrameRate() { - return frameRate; - } - - public void setFrameRate(int frameRate) { - this.frameRate = frameRate; - } - -} diff --git a/app/src/main/java/com/frank/ffmpeg/model/VideoBean.kt b/app/src/main/java/com/frank/ffmpeg/model/VideoBean.kt new file mode 100644 index 0000000..aa34f26 --- /dev/null +++ b/app/src/main/java/com/frank/ffmpeg/model/VideoBean.kt @@ -0,0 +1,36 @@ +package com.frank.ffmpeg.model + +/** + * the model of video data + * Created by frank on 2020/1/7. + */ +class VideoBean { + + //"codec_tag_string": "avc1" + var videoCodec: String? = null + get() = if ("[0][0][0][0]" == field) { + null + } else field + + //"width": 640 + var width: Int = 0 + + //"height": 360 + var height: Int = 0 + + //"display_aspect_ratio": "16:9" + var displayAspectRatio: String? = null + + //"pix_fmt": "yuv420p" + var pixelFormat: String? = null + + //"profile": "578" + var profile: String? = null + + //"level": 30 + var level: Int = 0 + + //"r_frame_rate": "24000/1001" + var frameRate: Int = 0 + +}