- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在尝试使用 FFMPEG 和这个库压缩视频:https://github.com/guardianproject/android-ffmpeg-java
我将 ffmpeglib 作为模块导入到我的项目中。这是用于压缩的代码:
public class MainActivity extends Activity {
private ArrayList<Object> listVideoPaths = new ArrayList<>();
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
getGalleryVideos();
File videoFolderFile = new File("/storage/emulated/0/DCIM/Camera/");
if(videoFolderFile.exists())
Log.e("TEST FFMPEG", "video folder exist");
else
Log.e("TEST FFMPEG", "video folder DON'T exist");
File videoInputFile = new File(listVideoPaths.get(0).toString());
if(videoInputFile.exists())
Log.e("TEST FFMPEG", "video input file exist");
else
Log.e("TEST FFMPEG", "video input file DON'T exist");
File videoOutputFile = new File(videoFolderFile,"output.mp4");
if(videoOutputFile.exists())
Log.e("TEST FFMPEG", "video output file exist");
else
Log.e("TEST FFMPEG", "video output file DON'T exist");
FfmpegController ffmpegController;
try {
ffmpegController = new FfmpegController(this,videoFolderFile);
Clip mediaIn = new Clip();
mediaIn.path = videoInputFile.getAbsolutePath();
mediaIn.videoFps = "25";
ffmpegController.convertToMPEG(mediaIn, videoOutputFile.getAbsolutePath(), new ShellUtils.ShellCallback() {
@Override
public void shellOut(String shellLine) {
Log.e("TEST FFMPEG", "shellOut - " + shellLine);
}
@Override
public void processComplete(int exitValue) {
Log.e("TEST FFMPEG", "proccess complete - " + exitValue);
}
});
} catch (IOException e) {
e.printStackTrace();
} catch (Exception e) {
e.printStackTrace();
}finally {
if(videoOutputFile.exists())
Log.e("TEST FFMPEG", "finished ffmpeg ---> video output file exist");
else
Log.e("TEST FFMPEG", "finished ffmpeg ---> video output file DON'T exist");
}
}
private void getGalleryVideos(){
Cursor videoCursor = null;
try {
final String[] columns = { Media.DATA,
Media._ID,
Media.DATE_ADDED };
final String orderBy = Media.DATE_ADDED;
videoCursor = getContentResolver().query(
MediaStore.Video.Media.EXTERNAL_CONTENT_URI, columns,
null, null, orderBy);
if (videoCursor != null && videoCursor.getCount() > 0) {
while (videoCursor.moveToNext()) {
int dataColumnIndex = videoCursor
.getColumnIndex(Media.DATA);
listVideoPaths.add(videoCursor
.getString(dataColumnIndex));
}
}
Collections.sort(listVideoPaths,new Comparator());
} catch (Exception e) {
e.printStackTrace();
} finally {
if (videoCursor != null) {
if (!videoCursor.isClosed()) {
videoCursor.close();
}
}
}
}
}
3096-3096/douglasanunciacao.androidffmpegjavateste E/TESTE FFMPEG﹕ video folder exist 07-30 14:31:57.389
3096-3096/douglasanunciacao.androidffmpegjavateste E/TESTE FFMPEG﹕ video input file exist 07-30 14:31:57.389
3096-3096/douglasanunciacao.androidffmpegjavateste E/TESTE FFMPEG﹕ video output file DON'T exist 07-30 14:31:58.363
3096-3096/douglasanunciacao.androidffmpegjavateste E/TESTE FFMPEG﹕ shellOut - /data/data/douglasanunciacao.androidffmpegjavateste/app_bin/ffmpeg -y -i /storage/emulated/0/DCIM/Camera/VID_20150730_142330563.mp4 -f mpeg /storage/emulated/0/DCIM/Camera/output.mp4 07-30 14:31:58.385
3096-3182/douglasanunciacao.androidffmpegjavateste E/TESTE FFMPEG﹕ shellOut - WARNING: linker: /data/data/douglasanunciacao.androidffmpegjavateste/app_bin/ffmpeg has text relocations. This is wasting memory and prevents security hardening. Please fix. 07-30 14:31:58.390
3096-3182/douglasanunciacao.androidffmpegjavateste E/TESTE FFMPEG﹕ shellOut - ffmpeg version 0.11.1 Copyright (c) 2000-2012 the FFmpeg developers 07-30 14:31:58.391
3096-3182/douglasanunciacao.androidffmpegjavateste E/TESTE FFMPEG﹕ shellOut - built on Dec 22 2014 12:52:34 with gcc 4.6 20120106 (prerelease) 07-30 14:31:58.391
3096-3182/douglasanunciacao.androidffmpegjavateste E/TESTE FFMPEG﹕ shellOut - configuration: --arch=arm --cpu=cortex-a8 --target-os=linux --enable-runtime-cpudetect --prefix=/data/data/info.guardianproject.ffmpeg/app_opt --enable-pic --disable-shared --enable-static --cross-prefix=/home/n8fr8/dev/android/ndk/toolchains/arm-linux-androideabi-4.6/prebuilt/linux-x86_64/bin/arm-linux-androideabi- --sysroot=/home/n8fr8/dev/android/ndk/platforms/android-16/arch-arm --extra-cflags='-I../x264 -mfloat-abi=softfp -mfpu=neon -fPIE -pie' --extra-ldflags='-L../x264 -fPIE -pie' --enable-version3 --enable-gpl --disable-doc --enable-yasm --enable-decoders --enable-encoders --enable-muxers --enable-demuxers --enable-parsers --enable-protocols --enable-filters --enable-avresample --enable-libfreetype --disable-indevs --enable-indev=lavfi --disable-outdevs --enable-hwaccels --enable-ffmpeg --disable-ffplay --disable-ffprobe --disable-ffserver --disable-network --enable-libx264 --enable-zlib 07-30 14:31:58.391
3096-3182/douglasanunciacao.androidffmpegjavateste E/TESTE FFMPEG﹕ shellOut - libavutil 51. 54.100 / 51. 54.100 07-30 14:31:58.391 3096-3182/douglasanunciacao.androidffmpegjavateste E/TESTE FFMPEG﹕ shellOut - libavcodec 54. 23.100 / 54. 23.100 07-30 14:31:58.391 3096-3182/douglasanunciacao.androidffmpegjavateste E/TESTE FFMPEG﹕ shellOut - libavformat 54. 6.100 / 54. 6.100 07-30 14:31:58.391 3096-3182/douglasanunciacao.androidffmpegjavateste E/TESTE FFMPEG﹕ shellOut - libavdevice 54. 0.100 / 54. 0.100 07-30 14:31:58.391 3096-3182/douglasanunciacao.androidffmpegjavateste E/TESTE FFMPEG﹕ shellOut - libavfilter 2. 77.100 / 2. 77.100 07-30 14:31:58.391 3096-3182/douglasanunciacao.androidffmpegjavateste E/TESTE FFMPEG﹕ shellOut - libswscale 2. 1.100 / 2. 1.100 07-30 14:31:58.391 3096-3182/douglasanunciacao.androidffmpegjavateste E/TESTE FFMPEG﹕ shellOut - libswresample 0. 15.100 / 0. 15.100 07-30 14:31:58.391 3096-3182/douglasanunciacao.androidffmpegjavateste E/TESTE FFMPEG﹕ shellOut - libpostproc 52. 0.100 / 52. 0.100 07-30 14:31:58.868 3096-3182/douglasanunciacao.androidffmpegjavateste E/TESTE FFMPEG﹕ shellOut - Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '/storage/emulated/0/DCIM/Camera/VID_20150730_142330563.mp4': 07-30 14:31:58.869 3096-3182/douglasanunciacao.androidffmpegjavateste E/TESTE FFMPEG﹕ shellOut - Metadata: 07-30 14:31:58.869
3096-3182/douglasanunciacao.androidffmpegjavateste E/TESTE FFMPEG﹕ shellOut - major_brand : mp42 07-30 14:31:58.870
3096-3182/douglasanunciacao.androidffmpegjavateste E/TESTE FFMPEG﹕ shellOut - minor_version : 0 07-30 14:31:58.871
3096-3182/douglasanunciacao.androidffmpegjavateste E/TESTE FFMPEG﹕ shellOut - compatible_brands: isommp42 07-30 14:31:58.872
3096-3182/douglasanunciacao.androidffmpegjavateste E/TESTE FFMPEG﹕ shellOut - creation_time : 2015-07-30 17:23:34 07-30 14:31:58.873 3096-3182/douglasanunciacao.androidffmpegjavateste E/TESTE FFMPEG﹕ shellOut - Duration: 00:00:01.89, start: 0.000000, bitrate: 17571 kb/s 07-30 14:31:58.874
3096-3182/douglasanunciacao.androidffmpegjavateste E/TESTE FFMPEG﹕ shellOut - Stream #0:0(eng): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 1920x1080, 15874 kb/s, SAR 65536:65536 DAR 16:9, 23.90 fps, 23.92 tbr, 90k tbn, 180k tbc 07-30 14:31:58.875 3096-3182/douglasanunciacao.androidffmpegjavateste E/TESTE FFMPEG﹕ shellOut - Metadata: 07-30 14:31:58.876
3096-3182/douglasanunciacao.androidffmpegjavateste E/TESTE FFMPEG﹕ shellOut - rotate : 270 07-30 14:31:58.877
3096-3182/douglasanunciacao.androidffmpegjavateste E/TESTE FFMPEG﹕ shellOut - creation_time : 2015-07-30 17:23:34 07-30 14:31:58.878 3096-3182/douglasanunciacao.androidffmpegjavateste E/TESTE FFMPEG﹕ shellOut - handler_name : VideoHandle 07-30 14:31:58.878 3096-3182/douglasanunciacao.androidffmpegjavateste E/TESTE FFMPEG﹕ shellOut - Stream #0:1(eng): Audio: aac (mp4a / 0x6134706D), 48000 Hz, stereo, s16, 127 kb/s 07-30 14:31:58.878
3096-3182/douglasanunciacao.androidffmpegjavateste E/TESTE FFMPEG﹕ shellOut - Metadata: 07-30 14:31:58.878
3096-3182/douglasanunciacao.androidffmpegjavateste E/TESTE FFMPEG﹕ shellOut - creation_time : 2015-07-30 17:23:34 07-30 14:31:58.878 3096-3182/douglasanunciacao.androidffmpegjavateste E/TESTE FFMPEG﹕ shellOut - handler_name : SoundHandle 07-30 14:31:58.882 3096-3182/douglasanunciacao.androidffmpegjavateste E/TESTE FFMPEG﹕ shellOut - [buffer @ 0xb5cce0a0] w:1920 h:1080 pixfmt:yuv420p tb:1/90000 sar:65536/65536 sws_param:flags=2 07-30 14:31:58.882 3096-3182/douglasanunciacao.androidffmpegjavateste E/TESTE FFMPEG﹕ shellOut - [buffersink @ 0xb5cce0d0] No opaque field provided 07-30 14:31:58.891
3096-3182/douglasanunciacao.androidffmpegjavateste E/TESTE FFMPEG﹕ shellOut - [mpeg @ 0xb5c3df00] VBV buffer size not set, muxing may fail 07-30 14:31:58.892
3096-3182/douglasanunciacao.androidffmpegjavateste E/TESTE FFMPEG﹕ shellOut - Output #0, mpeg, to '/storage/emulated/0/DCIM/Camera/output.mp4': 07-30 14:31:58.894
3096-3182/douglasanunciacao.androidffmpegjavateste E/TESTE FFMPEG﹕ shellOut - Metadata: 07-30 14:31:58.895
3096-3182/douglasanunciacao.androidffmpegjavateste E/TESTE FFMPEG﹕ shellOut - major_brand : mp42 07-30 14:31:58.896
3096-3182/douglasanunciacao.androidffmpegjavateste E/TESTE FFMPEG﹕ shellOut - minor_version : 0 07-30 14:31:58.896
3096-3182/douglasanunciacao.androidffmpegjavateste E/TESTE FFMPEG﹕ shellOut - compatible_brands: isommp42 07-30 14:31:58.897
3096-3182/douglasanunciacao.androidffmpegjavateste E/TESTE FFMPEG﹕ shellOut - creation_time : 2015-07-30 17:23:34 07-30 14:31:58.898 3096-3182/douglasanunciacao.androidffmpegjavateste E/TESTE FFMPEG﹕ shellOut - encoder : Lavf54.6.100 07-30 14:31:58.898 3096-3182/douglasanunciacao.androidffmpegjavateste E/TESTE FFMPEG﹕ shellOut - Stream #0:0(eng): Video: mpeg1video, yuv420p, 1920x1080 [SAR 65536:65536 DAR 16:9], q=2-31, 200 kb/s, 90k tbn, 23.98 tbc 07-30 14:31:58.899
3096-3182/douglasanunciacao.androidffmpegjavateste E/TESTE FFMPEG﹕ shellOut - Metadata: 07-30 14:31:58.899
3096-3182/douglasanunciacao.androidffmpegjavateste E/TESTE FFMPEG﹕ shellOut - rotate : 270 07-30 14:31:58.900
3096-3182/douglasanunciacao.androidffmpegjavateste E/TESTE FFMPEG﹕ shellOut - creation_time : 2015-07-30 17:23:34 07-30 14:31:58.901 3096-3182/douglasanunciacao.androidffmpegjavateste E/TESTE FFMPEG﹕ shellOut - handler_name : VideoHandle 07-30 14:31:58.906 3096-3182/douglasanunciacao.androidffmpegjavateste E/TESTE FFMPEG﹕ shellOut - Stream #0:1(eng): Audio: mp2, 48000 Hz, stereo, s16, 128 kb/s 07-30 14:31:58.906
3096-3182/douglasanunciacao.androidffmpegjavateste E/TESTE FFMPEG﹕ shellOut - Metadata: 07-30 14:31:58.906
3096-3182/douglasanunciacao.androidffmpegjavateste E/TESTE FFMPEG﹕ shellOut - creation_time : 2015-07-30 17:23:34 07-30 14:31:58.906 3096-3182/douglasanunciacao.androidffmpegjavateste E/TESTE FFMPEG﹕ shellOut - handler_name : SoundHandle 07-30 14:31:58.906 3096-3182/douglasanunciacao.androidffmpegjavateste E/TESTE FFMPEG﹕ shellOut - Stream mapping: 07-30 14:31:58.906
3096-3182/douglasanunciacao.androidffmpegjavateste E/TESTE FFMPEG﹕ shellOut - Stream #0:0 -> #0:0 (h264 -> mpeg1video) 07-30 14:31:58.906 3096-3182/douglasanunciacao.androidffmpegjavateste E/TESTE FFMPEG﹕ shellOut - Stream #0:1 -> #0:1 (aac -> mp2) 07-30 14:31:58.906 3096-3182/douglasanunciacao.androidffmpegjavateste E/TESTE FFMPEG﹕ shellOut - Press [q] to stop, [?] for help 07-30 14:31:59.824 3096-3182/douglasanunciacao.androidffmpegjavateste E/TESTE FFMPEG﹕ shellOut - frame= 4 fps=0.0 q=2.0 size= 0kB time=00:00:00.08 bitrate= 0.0kbits/s 07-30 14:32:02.029
3096-3182/douglasanunciacao.androidffmpegjavateste E/TESTE FFMPEG﹕ shellOut - frame= 8 fps=2.7 q=10.5 size= 4kB time=00:00:00.25 bitrate= 130.9kbits/s 07-30 14:32:02.536
3096-3182/douglasanunciacao.androidffmpegjavateste E/TESTE FFMPEG﹕ shellOut - frame= 13 fps=3.7 q=25.2 size= 696kB time=00:00:00.45 bitrate=12427.3kbits/s 07-30 14:32:03.045
3096-3182/douglasanunciacao.androidffmpegjavateste E/TESTE FFMPEG﹕ shellOut - frame= 18 fps=4.4 q=31.0 size= 750kB time=00:00:00.66 bitrate=9206.8kbits/s 07-30 14:32:03.582
3096-3182/douglasanunciacao.androidffmpegjavateste E/TESTE FFMPEG﹕ shellOut - frame= 23 fps=5.0 q=31.0 size= 786kB time=00:00:00.87 bitrate=7351.4kbits/s 07-30 14:32:04.140
3096-3182/douglasanunciacao.androidffmpegjavateste E/TESTE FFMPEG﹕ shellOut - frame= 28 fps=5.5 q=31.0 size= 862kB time=00:00:01.08 bitrate=6511.8kbits/s 07-30 14:32:05.239
3096-3182/douglasanunciacao.androidffmpegjavateste E/TESTE FFMPEG﹕ shellOut - frame= 30 fps=4.8 q=31.0 size= 876kB time=00:00:01.16 bitrate=6144.9kbits/s 07-30 14:32:05.746
3096-3182/douglasanunciacao.androidffmpegjavateste E/TESTE FFMPEG﹕ shellOut - frame= 35 fps=5.2 q=31.0 size= 910kB time=00:00:01.37 bitrate=5416.2kbits/s 07-30 14:32:06.317
3096-3182/douglasanunciacao.androidffmpegjavateste E/TESTE FFMPEG﹕ shellOut - frame= 41 fps=5.6 q=31.0 size= 972kB time=00:00:01.62 bitrate=4895.2kbits/s 07-30 14:32:06.832
3096-3182/douglasanunciacao.androidffmpegjavateste E/TESTE FFMPEG﹕ shellOut - frame= 45 fps=5.7 q=31.0 Lsize= 1022kB time=00:00:01.83 bitrate=4562.1kbits/s 07-30 14:32:06.832
3096-3182/douglasanunciacao.androidffmpegjavateste E/TESTE FFMPEG﹕ shellOut - video:984kB audio:30kB global headers:0kB muxing overhead 0.756932% 07-30 14:32:06.858 3096-3096/douglasanunciacao.androidffmpegjavateste E/TESTE FFMPEG﹕ proccess complete - 0 07-30 14:32:06.858
3096-3096/douglasanunciacao.androidffmpegjavateste E/TESTE FFMPEG﹕ terminou o ffmpeg ---> video output file exist
最佳答案
我通过替换以下代码成功解决了这个问题:
Clip mediaIn = new Clip();
mediaIn.path = videoInputFile.getAbsolutePath();
mediaIn.videoFps = "30";
mediaIn.videoCodec = "mpeg4";
mediaIn.width = 640;
mediaIn.height = 352;
mediaIn.videoBitrate = 1000;
// "ffmpeg -y -i /sdcard/DCIM/Camera/VID_20150728_150045662.mp4 " +
// "-strict experimental -s 640x352 -r 30 -vcodec mpeg4 -ab 48000 " +
// "-ac 2 -ar 22050 -b 1000k /sdcard/DCIM/Camera/output2.mp4";
ffmpegController.convertToMPEG(mediaIn, videoOutputFile.getAbsolutePath(), new ShellUtils.ShellCallback() {
@Override
public void shellOut(String shellLine) {
Log.e("TEST FFMPEG", "shellOut - " + shellLine);
}
@Override
public void processComplete(int exitValue) {
Log.e("TEST FFMPEG", "proccess complete - " + exitValue);
}
});
Clip clipIn = new Clip(videoInputFile.getAbsolutePath());
Clip clipOut = new Clip(videoOutputFile.getAbsolutePath());
clipOut.videoCodec = "mpeg4";
clipOut.videoFps = "30"; // tailor this to your needs
clipOut.videoBitrate = 512; // 512 kbps - tailor this to your needs
clipOut.audioChannels = 1;
clipOut.width = 640;
clipOut.height = 352;
clipOut.duration = 2;
ffmpegController.processVideo(clipIn, clipOut, true, new ShellUtils.ShellCallback() {
@Override
public void shellOut(String shellLine) {
Log.e("TEST FFMPEG", "shellOut - " + shellLine);
}
@Override
public void processComplete(int exitValue) {
Log.e("TEST FFMPEG", "proccess complete - " + exitValue);
}
});
关于android - 压缩视频FFMPEG不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31730588/
我有点想做 the reverse of this. 我不想解压缩并将收集文件添加到 S3 应用户要求: 生成一堆xml文件 使用一些图像(托管在 s3 上的预先存在的图像)压缩 xml 文件 下载
将此添加到域的虚拟主机后 AddOutputFilterByType DEFLATE application/javascript text/javascript text/css 响应头不包含任何内
在 Apache Im 中,通过将以下内容添加到我的 .htaccess 文件来启用输出压缩: # compress text, html, javascript, css, xml: AddOutp
是否可以以压缩格式将请求数据从浏览器发送到服务器? 如果是,我们该怎么做? 最佳答案 压缩从浏览器发送到服务器的数据是不受 native 支持 在浏览器中。 您必须找到一种解决方法,使用客户端语言(可
我正在寻找可以压缩JavaScript源代码的工具。我发现一些网络工具只能删除空格字符?但也许存在更好的工具,可以压缩用户的函数名称、字段名称、删除未使用的字段等。 最佳答案 经常用来压缩JS代码的工
使用赛马博彩场景,假设我有许多单独的投注来预测比赛的前 4 名选手 (superfecta)。 赌注如下... 1/2/3/4 1/2/3/5 1/2/4/3 1/2/4/5 1/2/5/3
我是一名实习生,被要求对 SQL 2008 数据压缩进行一些研究。我们想将 Outlook 电子邮件的几个部分存储在一个表中。问题是我们想将整个电子邮件正文存储在一个字段中,然后又想压缩它。使用 Ch
我目前有一个系统,用户可以在其中上传 MP4 文件,并且可以在移动设备上下载该文件。但有时,这些视频的大小超过 5MB,在我国,大多数人使用 2G。因此,下载大型视频通常需要 15-20 分钟。 有什
假设我有一个带有类型列的简单文档表: Documents Id Type 1 A 2 A 3 B 4 C 5 C 6 A 7 A 8 A 9 B 10 C 用户
我有一个较大字符串中的(子)字符串位置的 data.frame。数据包含(子)字符串的开头及其长度。可以很容易地计算出(子)字符串的结束位置。 data1 start length end #>
我想知道是否 文件加密算法可以设计成它也可以执行文件压缩的事件(任何活生生的例子?)。 我也可以将它集成到移动短信服务中,我的意思是短信吗? 另外我想知道二进制文件...如果纯文本文件以二进制编码
关闭。这个问题不满足Stack Overflow guidelines .它目前不接受答案。 想改善这个问题吗?更新问题,使其成为 on-topic对于堆栈溢出。 7年前关闭。 Improve thi
我们有几个具有大量 JavaScript 的 Java 项目,目前我们使用的是旧版本的 YUICompressor (2.4.2)。然而,我在这篇博文中发现 YUICompressor 正在 depr
从之前关于尝试提高网站性能的文章中,我一直在研究 HTTP 压缩。我读过有关在 IIS 中设置它的信息,但它似乎是所有 IIS 应用程序池的全局事物,我可能不允许这样做,因为还有另一个站点在其上运行。
我有一个 REST 服务,它返回一大块 XML,大约值(value) 150k。 例如http://xmlservice.com/services/RestService.svc/GetLargeXM
我正在尝试获取一个简单的 UglifyJS (v2.3.6) 示例来处理压缩。 具体来说,“未使用”选项,如果从未使用过,变量和函数将被删除。 这是我在命令行上的尝试: echo "function
我正在开发一个项目,如果我的磁盘出现问题,我将在使用 ZLIB 压缩内存块后将其发送到另一个磁盘。然后我计划下载该转储并用于进一步调试。这种压缩和上传将一次完成一个 block - 比如说 1024
LZW 压缩算法在压缩后增加了位大小: 这是压缩函数的代码: // compression void compress(FILE *inputFile, FILE *outputFile) {
我的问题与如何在 3D 地形上存储大量信息有关。这些信息应该是 secret 的,因为它们非常庞大,也应该被压缩。我选择了文件存储,现在我想知道将对象数据加密/压缩(或压缩/加密)到文件的最佳做法。
我使用以下代码来压缩我的文件并且效果很好,但我只想压缩子文件夹而不是在压缩文件中显示树的根。 public boolean zipFileAtPath(String sourcePath, Strin
我是一名优秀的程序员,十分优秀!