[英]Compress video with ffmpeg4android library
我试图关注ffmpeg4android库 ,我在压缩视频时遇到问题,如下面的日志图片。
我使用intent转移到Compressing Media类,
Intent intent = new Intent(this, CompressingMedia.class);
intent.putExtra("file_path", mLlItems.get(0).getPath());
startActivity(intent);
这个班被转移到:
public class CompressingMedia extends BaseWizard {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Intent intent = getIntent();
Log.d(Prefs.TAG, "path " + intent.getExtras().getString("file_path"));
// /storage/emulated/0/DCIM/Camera/VID_20140312_090612.mp4
String command = "ffmpeg -y -i " + intent.getExtras().getString("file_path") +
" -strict experimental -s 320x240 -r 15 -aspect 3:4 -ab 12288 -vcodec mpeg4 -b 2097152 -sample_fmt s16 /sdcard/out.mp4";
// if you want to change the default work location (/sdcard/videokit/) use the uncomment the below method.
// It must be defined before calling the copyLicenseAndDemoFilesFromAssetsToSDIfNeeded method,
// in order for this method to copy the assets to the correct location.
// setWorkingFolder("/sdcard/videokit/");
// this will copy the license file and the demo video file.
// to the videokit work folder location.
// without the license file the library will not work.
copyLicenseAndDemoFilesFromAssetsToSDIfNeeded();
commandStr = command;
setCommand(commandStr);
runTranscoing();
}
}
虽然我收到了Transcoding Successfully的通知,但看起来压缩后文件的容量总是为0.(图像底部的日志)
我不知道结果,因为下面的图像是好还是不好,我无法得到预期的结果 - 视频被完全压缩成功。
有人知道压缩文件后为什么总是0,请告诉我。 谢谢。
这是Log Cat:
03-13 14:49:45.655:I / ActivityManager(6065):时间轴:Activity_launch_request id:app.cloudstringers time:38212359
03-13 14:49:45.665:V / Home(6065):全球ID为000400010007;卖出为3
03-13 14:49:45.770:D / ffmpeg4android(6065):path /storage/emulated/0/videokit/out.mp4
03-13 14:49:45.770:I / ffmpeg4android(6065):workingFolderPath:/ sdcard / videokit /
03-13 14:49:45.775:D / ffmpeg4android(6065):存在工作目录,不存在复制声明(许可文件和演示视频)
03-13 14:49:45.785:D / ffmpeg4android(6065):输出目录存在。
03-13 14:49:45.785:I / ffmpeg4android(6065):命令已设置
03-13 14:49:45.785:I / ffmpeg4android(6065):set remoteNotificationIconId:0
03-13 14:49:45.785:D / ffmpeg4android(6065):客户端无法取消绑定 - 服务未绑定
03-13 14:49:45.785:D / ffmpeg4android(6065):客户端stopService()
03-13 14:49:45.790:W / ContextImpl(6065):使用startService的隐式意图不安全:Intent {act = com.netcompss.ffmpeg4android.FFMpegRemoteServiceBridge} android.content.ContextWrapper.stopService:499 com.netcompss.ffmpeg4android_client .BaseWizard.stopService:451 com.netcompss.ffmpeg4android_client.BaseWizard.runTranscoing:285
03-13 14:49:45.795:I / ffmpeg4android(6065):!!!!!!!!!!!!!!!!!! services.size():1
03-13 14:49:45.795:I / ffmpeg4android(6065):放置Base分类
03-13 14:49:45.810:D / ffmpeg4android(6065):已启动:com.netcompss.ffmpeg4android.FFMpegRemoteServiceBridge
03-13 14:49:45.810:D / ffmpeg4android(6065):客户端startService()
03-13 14:49:45.810:D / ffmpeg4android(6065):调用bindService()
03-13 14:49:45.815:W / ContextImpl(6065):使用startService的隐式意图不安全:Intent {act = com.netcompss.ffmpeg4android.FFMpegRemoteServiceBridge} android.content.ContextWrapper.bindService:517 com.netcompss.ffmpeg4android_client .BaseWizard.bindService:462 com.netcompss.ffmpeg4android_client.BaseWizard.runTranscoing:288
03-13 14:49:45.820:D / ffmpeg4android(6065):客户端bindService()
03-13 14:49:45.935:I / ffmpeg4android(6616):======= service onCreate():停止forground(克服2.3.x bug)
03-13 14:49:45.935:I / ffmpeg4android(6616):======= service onBind()=======
03-13 14:49:45.940:I / ffmpeg4android(6616):=== onStartCommand被调用
03-13 14:49:45.940:I / ffmpeg4android(6616):=== onStartCommand cat:Base
03-13 14:49:45.940:D / ffmpeg4android(6616):onStartCommand,START_STICKY,base命令
03-13 14:49:45.955:I / ffmpeg4android(6616):get remoteNotificationIconId:0
03-13 14:49:45.955:I / ffmpeg4android(6616):notifIcon已设置
03-13 14:49:45.955:I / ffmpeg4android(6616):启动RemoteService,通知ID:5326
03-13 14:49:45.965:I / ffmpeg4android(6616):运行调用。
03-13 14:49:45.965:D / ffmpeg4android(6616):睡觉,等待命令
03-13 14:49:45.970:D / ffmpeg4android(6065):客户端onServiceConnected()
03-13 14:49:45.970:I / ffmpeg4android(6065):调用了invokeService
03-13 14:49:45.970:I / Videokit(6065):licenseCheck in path:/ sdcard / videokit
03-13 14:49:45.970:I / Videokit(6065):isLicExistsComplex ...
03-13 14:49:45.970:I / Videokit(6065):试图打开/sdcard/videokit/ffmpeglicense.lic
03-13 14:49:45.970:I / Videokit(6065):找到许可证文件...
03-13 14:49:45.970:I / Videokit(6065):时间解码:1394535283
03-13 14:49:45.970:I / Videokit(6065):timeStrDec 1394535283是一个有效数字。
03-13 14:49:45.970:I / Videokit(6065):时差:161702
03-13 14:49:45.970:I / Videokit(6065):您在15个试用期中使用了1个。
03-13 14:49:45.970:I / ffmpeg4android(6065):设置远程通知信息
03-13 14:49:45.970:D / ffmpeg4android(6616):命令项目数:21
03-13 14:49:45.970:D / ffmpeg4android(6616):command:ffmpeg -y -i /storage/emulated/0/videokit/out.mp4 -strict experimental -s 320x240 -r 15 -sepect 3:4 - ab 12288 -vcodec mpeg4 -b 2097152 -sample_fmt s16 /sdcard/out.mp4
03-13 14:49:45.970:D / ffmpeg4android(6616):来自远程的workingFolder:/ sdcard / videokit
03-13 14:49:45.970:D / ffmpeg4android(6065):删除:/sdcard/videokit/vk.log isdeleted:true
03-13 14:49:45.975:D / ffmpeg4android(6065):删除:/sdcard/videokit/ffmpeg4android.log isdeleted:false
03-13 14:49:45.975:D / ffmpeg4android(6065):删除:/sdcard/videokit/videokit.log isdeleted:true
03-13 14:49:45.980:D / ffmpeg4android(6065):客户端invokeService()
03-13 14:49:45.980:D / ffmpeg4android(6065):获取唤醒锁
03-13 14:49:46.265:D / ffmpeg4android(6616):睡觉,等待命令
03-13 14:49:46.295:D / ffmpeg4android(6065):TranscodeBackground doInBackground已启动
03-13 14:49:46.295:I / ffmpeg4android(6616):=======远程服务runTranscoding ======
03-13 14:49:46.340:V / HomeAsync(6065):TOTAL_SPACE为1; AVAILABLE_SPACE为0.451
03-13 14:49:46.345:I / ActivityManager(6065):时间轴:Activity_idle id:android.os.BinderProxy@423deed8 time:38213045
03-13 14:49:46.345:I / ActivityManager(6065):时间轴:Activity_idle id:android.os.BinderProxy@420323a0 time:38213045
03-13 14:49:46.565:D / dalvikvm(6616):尝试加载lib /data/app-lib/app.cloudstringers-2/libvideokit.so 0x41b285f0
03-13 14:49:46.570:D / dalvikvm(6616):添加了共享库/data/app-lib/app.cloudstringers-2/libvideokit.so 0x41b285f0
03-13 14:49:46.570:I / Videokit(6616):加载本地图书馆编译于2013年10月23日21:59:53
03-13 14:49:46.575:I / ffmpeg4android(6616):===============从线程路径运行命令:/ sdcard / videokit
03-13 14:49:46.575:I / Videokit(6616):vk ffmpeg sdcardPath:/ sdcard / videokit
03-13 14:49:46.575:I / Videokit(6616):licenseCheck in path:/ sdcard / videokit
03-13 14:49:46.575:I / Videokit(6616):isLicExistsComplex ......
03-13 14:49:46.575:I / Videokit(6616):试图打开/sdcard/videokit/ffmpeglicense.lic
03-13 14:49:46.575:I / Videokit(6616):找到许可证文件...
03-13 14:49:46.575:I / ffmpeg4android(6616):======= ProgressBackgroundRemote doInBackground =========
03-13 14:49:46.575:I / Videokit(6616):时间解码:1394535283
03-13 14:49:46.575:I / Videokit(6616):timeStrDec 1394535283是一个有效数字。
03-13 14:49:46.575:I / Videokit(6616):时差:161703
03-13 14:49:46.575:I / Videokit(6616):您在15个试用日中使用了1个。
03-13 14:49:46.575:D / Videokit(6616):执照检查rc:0
03-13 14:49:46.575:D / Videokit(6616):run()名为verion 2.0
03-13 14:49:46.575:D / Videokit(6616):跑去主干()
03-13 14:49:46.800:D / ffmpeg4android(6065):onServiceDisconnected
03-13 14:49:48.640:I / ffmpeg4android(6065):实际持续时间:00:00:07.78
03-13 14:49:48.640:I / ffmpeg4android(6065):====从VK获取currentVkLogSize
03-13 14:49:48.640:D / ffmpeg4android(6065):currentVkLogSize:5751
03-13 14:49:48.645:I / ffmpeg4android(6065):没有ffmpeg4android_log文件,使用vk日志
03-13 14:49:48.645:I / line(6065):_rate,rate,width或height
03-13 14:49:48.650:I / line(6065):统计:0寻求,0写出
03-13 14:49:48.650:I / line(6065):统计:72873字节读取,2搜索
03-13 14:49:48.650:D / ffmpeg4android(6065):currentTimeStr:退出
03-13 14:49:48.650:D / ffmpeg4android(6065):============在日志中找到退出令牌之一============
03-13 14:49:48.650:I / ffmpeg4android(6065):onProgressUpdate:100
03-13 14:49:48.650:D / ffmpeg4android(6065):释放唤醒锁定
03-13 14:49:48.650:D / ffmpeg4android(6065):TranscodeBackground onPostExecute
03-13 14:49:48.700:D / ffmpeg4android(6065):/ sdcard / videokit / null长度(字节):0
03-13 14:49:48.700:D / ffmpeg4android(6065):showNotifications
03-13 14:49:48.700:W / ffmpeg4android(6065):未设置输出文件使用setOutputFilePath方法设置完整输出文件路径
03-13 14:49:48.705:I / ffmpeg4android(6065):FFMPEG结束了。
03-13 14:49:48.710:D / ffmpeg4android(6065):releaseService()
03-13 14:49:48.710:D / ffmpeg4android(6065):客户端stopService()
03-13 14:49:48.710:W / ContextImpl(6065):使用startService的隐式意图不安全:Intent {act = com.netcompss.ffmpeg4android.FFMpegRemoteServiceBridge} android.content.ContextWrapper.stopService:499 com.netcompss.ffmpeg4android_client .BaseWizard.stopService:451 com.netcompss.ffmpeg4android_client.BaseWizard.handleServiceFinished:513
您也可以考虑从原始来源使用真实(和免费!)FFmpeg for Android: http : //trac.ffmpeg.org/wiki/How%20to%20compile%20FFmpeg%20for%20Android而不是使用某些第三方来自一个似乎违反FFmpeg LGPL许可证的人的汇编。
根据您的日志,您使用的命令不正确。 您的视频文件可能与您使用的大小和方面参数不对应。
请在此处查看您的日志行:03-13 14:49:48.645:I / line(6065):_rate,rate,width或height
最好的方法是发布输入视频文件的链接,以便我可以检查它。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.