ffmpeg - 在android中使用过滤器 [英] ffmpeg - Use filter in android

查看:196
本文介绍了ffmpeg - 在android中使用过滤器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用ffmpeg在我的Android项目中使用电影过滤器。我使用保护项目的一个叉子: Cheers-dev



它使用最近版本的ffmpeg(〜15天大atm)。我添加了选项 - enable-filter = movie 来激活过滤器。



我使用这个命令行我的Android项目:

  ffmpeg -i input.mp4 -vfmovie = watermark.png [watermark]; [in] [水印] overlay = main_w-overlay_w-10:main_h-overlay_h-10 [out]--strict -2 outputvideo.mp4 

它完美地与我的桌面版本Debian Wheezy。但是不可能让我在Android上工作。所有其他命令都可以正常工作。



这里出现错误:没有这样的过滤器:'movie' p>

我还使用选项 -filter_complex 测试了一个有点不同的错误:

  $ ffmpeg -y -loglevel debug -i /storage/sdcard0/test/hsgjr_export.mp4 -i /storage/sdcard0/test/watermark.png -filter_complex[0 :v] [1:v] overlay = main_w-overlay_w-10:main_h-overlay_h-10 [out]-map [out] -map 0:a -codec:a copy /storage/sdcard0/test/hsgjr_watermark.mp4 

ffmpeg版本N-58429-gccdfa3e版权所有(c)2000-2013 FFmpeg开发者
建于2013年12月10日01:12:39与gcc 4.4.3(GCC)
配置:--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 = / opt / android / ndk-r8 / toolchains / arm-linux-androideabi-4.4.3 / prebuilt / linux-x86 / bin / arm-linux-androideabi - --sysroot = / opt / androi d / ndk-r8 / platforms / android-14 / arch-arm --extra-cflags =' - I ../ x264 -I / Android / cheers / android-ffmpeg / data / data / info.guardianproject.ffmpeg / app_opt / include -mfloat-abi = softfp -mfpu = neon'--extra-ldflags =' - L ../ x264 -L / Android / cheers / android-ffmpeg / data / data / info.guardianproject.ffmpeg / app_opt / lib --enable-version3 --enable-gpl --enable-yasm --enable-decoders --enable-encoders --enable-muxers --enable-demuxers --enable-parsers --enable-protocols --enable- filter = movie --enable-avresample --enable-libvorbis --disable-indevs --enable-indev = lavfi
libavutil 52. 54.100 / 52. 54.100
libavcodec 55. 44.100 / 55. 44.100
libavformat 55. 21.101 / 55. 21.101
libavdevice 55. 5.100 / 55. 5.100
libavfilter 3. 91.100 / 3. 91.100
libavresample 1. 1. 0 / 1. 1。 0
libswscale 2. 5.101 / 2. 5.101
libswresample 0. 17.104 / 0. 17.104
libpostproc 52. 3.100 / 52. 3.100
拆分命令行。
读取选项'-y'...与参数'1'匹配为选项'y'(覆盖输出文件)。
读取选项'-loglevel'...与参数'debug'匹配为选项'loglevel'(设置日志记录级别)。
读取选项'-i'...匹配为参数'/storage/sdcard0/test/hsgjr_export.mp4'的输入文件。
读取选项'-i'...匹配为参数'/storage/sdcard0/test/watermark.png'的输入文件。
读取选项'-filter_complex'...匹配为选项'filter_complex'(创建一个复杂的过滤器),参数'[0:v] [1:v] overlay = main_w-overlay_w-10:main_h-overlay_h -10 [OUT]。
读取选项'-map'...匹配为选项'map'(设置输入流映射)与参数'[out]'。
读取选项'-map'...与参数'0:a'匹配为选项'map'(设置输入流映射)。
读取选项'-codec:a'...与参数'copy'匹配为选项'codec'(编解码器名称)。
读取选项'/storage/sdcard0/test/hsgjr_watermark.mp4'...匹配为输出文件。
完成分割命令行。
解析一组选项:全局。
使用参数1应用选项y(覆盖输出文件)。
应用参数调试选项loglevel(设置日志级别)。
使用参数[0:v] [1:v] overlay = main_w-overlay_w-10:main_h-overlay_h-10 [out]应用选项filter_complex(创建复杂的过滤器)。
成功解析了一组选项。
解析一组选项:输入文件/storage/sdcard0/test/hsgjr_export.mp4。
成功解析了一组选项。
打开输入文件:/storage/sdcard0/test/hsgjr_export.mp4。
[mov,mp4,m4a,3gp,3g2,mj2 @ 0x1274cd0]格式mov,mp4,m4a,3gp,3g2,mj2探测大小= 2048,得分= 100
[mov,mp4,m4a ,3gp,3g2,mj2 @ 0x1274cd0] ISO:文件类型主要品牌:isom
[mov,mp4,m4a,3gp,3g2,mj2 @ 0x1274cd0] avformat_find_stream_info()之前的文件位置为1196725
[mov ,mp4,m4a,3gp,3g2,mj2 @ 0x1274cd0]发现所有信息
[mov,mp4,m4a,3gp,3g2,mj2 @ 0x1274cd0] avformat_find_stream_info()之后的文件位置为30451
输入#0 ,mov,mp4,m4a,3gp,3g2,mj2,来自'/storage/sdcard0/test/hsgjr_export.mp4':
元数据:
major_brand:isom
minor_version:512
compatible_brands:isomiso2avc1mp41
编码器:Lavf55.21.101
持续时间:00:00:00.96,开始:0.000000,比特率:9972 kb / s
流#0:0(und) 1/1200000:视频:h264(高)(avc1 / 0x31637661),yuv420p,1920x1080,1/2400000,9830 kb / s,25 fps,25 tbr,1200k tbn,2400k tbc(默认)
元数据:
handler_name:VideoHandler
流#0:1(und),1,1/48000 :音频:aac(mp4a / 0x6134706D),48000 Hz,stereo,fltp,127 kb / s(默认)
元数据:
handler_name:SoundHandler
成功打开该文件。
解析一组选项:输入文件/storage/sdcard0/test/watermark.png。
成功解析了一组选项。
打开输入文件:/storage/sdcard0/test/watermark.png。
[AVIOContext @ 0x12870f0]统计:26515字节读取,0寻找
输入#1,image2,从'/storage/sdcard0/test/watermark.png':
持续时间:00:00 :00.04,开始:0.000000,比特率:N / A
流#1:0,1,1/25:视频:png,rgba,400x170,1/25,25 tbr,25 tbn,25 tbc
成功打开文件。
解析一组选项:输出文件/storage/sdcard0/test/hsgjr_watermark.mp4。
应用选项映射(设置输入流映射)与参数[out]。
应用选项映射(设置输入流映射)与参数0:a。
应用选项编解码器:具有参数副本的(编解码器名称)。
成功解析了一组选项。
打开输出文件:/storage/sdcard0/test/hsgjr_watermark.mp4。
[AVFilterGraph @ 0x127d5f0]没有这样的过滤器:'''
错误配置过滤器
[AVIOContext @ 0x127d2b0]统计:67296字节读取,2寻求

输出比以前更好,但我觉得我缺少某些东西。



解决方案:我从filter_complex参数中删除了引号,它的工作正常。



这是工作命令:

  $ ffmpeg -y -i /storage/sdcard0/test/hsgjr_export.mp4 -i /storage/sdcard0/test/watermark.png -filter_complex [0 :v] [1:v] overlay = main_w-overlay_w-10:main_h-overlay_h-10 [out] -map [out] -map 0:a -codec:a copy /storage/sdcard0/test/hsgjr_watermark.mp4 


解决方案

要解决我的问题,我删除了关于filter_complex参数的双引号这是工作命令:

  $ ffmpeg -y -i /storage/sdcard0/test/hsgjr_export.mp4 -i /存储/ sdcard0 /测试/ waterm ark.png -filter_complex [0:v] [1:v] overlay = main_w-overlay_w-10:main_h-overlay_h-10 [out] -map [out] -map 0:a -codec:a copy / storage / sdcard0 /test/hsgjr_watermark.mp4 


I'm trying to use the movie filter in my android project with ffmpeg. I use a fork of the guardian project : Cheers-dev

It use a recent version of ffmpeg (~15 days old atm). I added the option --enable-filter=movie to activate the filter.

I use this command line in my android project :

ffmpeg -i input.mp4 -vf "movie=watermark.png [watermark]; [in][watermark] overlay=main_w-overlay_w-10:main_h-overlay_h-10 [out]" -strict -2 outputvideo.mp4

It perfectly works with my desktop version on Debian Wheezy. But it's impossible to make it work on my Android. All other commands works.

Here the error when it fails : No such filter: 'movie'.

I also tested with the option -filter_complex with a somewhat different error:

$ ffmpeg -y -loglevel debug -i /storage/sdcard0/test/hsgjr_export.mp4 -i /storage/sdcard0/test/watermark.png -filter_complex "[0:v][1:v]overlay=main_w-overlay_w-10:main_h-overlay_h-10[out]" -map [out] -map 0:a -codec:a copy /storage/sdcard0/test/hsgjr_watermark.mp4

ffmpeg version N-58429-gccdfa3e Copyright (c) 2000-2013 the FFmpeg developers
built on Dec 10 2013 01:12:39 with gcc 4.4.3 (GCC)
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=/opt/android/ndk-r8/toolchains/arm-linux-androideabi-4.4.3/prebuilt/linux-x86/bin/arm-linux-androideabi- --sysroot=/opt/android/ndk-r8/platforms/android-14/arch-arm --extra-cflags='-I../x264 -I/Android/cheers/android-ffmpeg/data/data/info.guardianproject.ffmpeg/app_opt/include -mfloat-abi=softfp -mfpu=neon' --extra-ldflags='-L../x264 -L/Android/cheers/android-ffmpeg/data/data/info.guardianproject.ffmpeg/app_opt/lib' --enable-version3 --enable-gpl --enable-yasm --enable-decoders --enable-encoders --enable-muxers --enable-demuxers --enable-parsers --enable-protocols --enable-filter=movie --enable-avresample --enable-libvorbis --disable-indevs --enable-indev=lavfi
libavutil      52. 54.100 / 52. 54.100
libavcodec     55. 44.100 / 55. 44.100
libavformat    55. 21.101 / 55. 21.101
libavdevice    55.  5.100 / 55.  5.100
libavfilter     3. 91.100 /  3. 91.100
libavresample   1.  1.  0 /  1.  1.  0
libswscale      2.  5.101 /  2.  5.101
libswresample   0. 17.104 /  0. 17.104
libpostproc    52.  3.100 / 52.  3.100
Splitting the commandline.
Reading option '-y' ... matched as option 'y' (overwrite output files) with argument '1'.
Reading option '-loglevel' ... matched as option 'loglevel' (set logging level) with argument 'debug'.
Reading option '-i' ... matched as input file with argument '/storage/sdcard0/test/hsgjr_export.mp4'.
Reading option '-i' ... matched as input file with argument '/storage/sdcard0/test/watermark.png'.
Reading option '-filter_complex' ... matched as option 'filter_complex' (create a complex filtergraph) with argument '"[0:v][1:v]overlay=main_w-overlay_w-10:main_h-overlay_h-10[out]"'.
Reading option '-map' ... matched as option 'map' (set input stream mapping) with argument '[out]'.
Reading option '-map' ... matched as option 'map' (set input stream mapping) with argument '0:a'.
Reading option '-codec:a' ... matched as option 'codec' (codec name) with argument 'copy'.
Reading option '/storage/sdcard0/test/hsgjr_watermark.mp4' ... matched as output file.
Finished splitting the commandline.
Parsing a group of options: global .
Applying option y (overwrite output files) with argument 1.
Applying option loglevel (set logging level) with argument debug.
Applying option filter_complex (create a complex filtergraph) with argument "[0:v][1:v]overlay=main_w-overlay_w-10:main_h-overlay_h-10[out]".
Successfully parsed a group of options.
Parsing a group of options: input file /storage/sdcard0/test/hsgjr_export.mp4.
Successfully parsed a group of options.
Opening an input file: /storage/sdcard0/test/hsgjr_export.mp4.
[mov,mp4,m4a,3gp,3g2,mj2 @ 0x1274cd0] Format mov,mp4,m4a,3gp,3g2,mj2 probed with size=2048 and score=100
[mov,mp4,m4a,3gp,3g2,mj2 @ 0x1274cd0] ISO: File Type Major Brand: isom
[mov,mp4,m4a,3gp,3g2,mj2 @ 0x1274cd0] File position before avformat_find_stream_info() is 1196725
[mov,mp4,m4a,3gp,3g2,mj2 @ 0x1274cd0] All info found
[mov,mp4,m4a,3gp,3g2,mj2 @ 0x1274cd0] File position after avformat_find_stream_info() is 30451
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '/storage/sdcard0/test/hsgjr_export.mp4':
Metadata:
major_brand     : isom
minor_version   : 512
compatible_brands: isomiso2avc1mp41
encoder         : Lavf55.21.101
Duration: 00:00:00.96, start: 0.000000, bitrate: 9972 kb/s
Stream #0:0(und), 1, 1/1200000: Video: h264 (High) (avc1 / 0x31637661), yuv420p, 1920x1080, 1/2400000, 9830 kb/s, 25 fps, 25 tbr, 1200k tbn, 2400k tbc (default)
Metadata:
handler_name    : VideoHandler
Stream #0:1(und), 1, 1/48000: Audio: aac (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 127 kb/s (default)
Metadata:
handler_name    : SoundHandler
Successfully opened the file.
Parsing a group of options: input file /storage/sdcard0/test/watermark.png.
Successfully parsed a group of options.
Opening an input file: /storage/sdcard0/test/watermark.png.
[AVIOContext @ 0x12870f0] Statistics: 26515 bytes read, 0 seeks
Input #1, image2, from '/storage/sdcard0/test/watermark.png':
Duration: 00:00:00.04, start: 0.000000, bitrate: N/A
Stream #1:0, 1, 1/25: Video: png, rgba, 400x170, 1/25, 25 tbr, 25 tbn, 25 tbc
Successfully opened the file.
Parsing a group of options: output file /storage/sdcard0/test/hsgjr_watermark.mp4.
Applying option map (set input stream mapping) with argument [out].
Applying option map (set input stream mapping) with argument 0:a.
Applying option codec:a (codec name) with argument copy.
Successfully parsed a group of options.
Opening an output file: /storage/sdcard0/test/hsgjr_watermark.mp4.
[AVFilterGraph @ 0x127d5f0] No such filter: '"'
Error configuring filters.
[AVIOContext @ 0x127d2b0] Statistics: 67296 bytes read, 2 seeks

The output is better than the previous one but I think I'm missing something.

SOLUTION : I removed the quote from the filter_complex argument and it worked.

Here is the working command :

$ ffmpeg -y -i /storage/sdcard0/test/hsgjr_export.mp4 -i /storage/sdcard0/test/watermark.png -filter_complex [0:v][1:v]overlay=main_w-overlay_w-10:main_h-overlay_h-10[out] -map [out] -map 0:a -codec:a copy /storage/sdcard0/test/hsgjr_watermark.mp4

解决方案

To resolve my problem I removed the double quote around filter_complex argument. Here is the working command :

$ ffmpeg -y -i /storage/sdcard0/test/hsgjr_export.mp4 -i /storage/sdcard0/test/watermark.png -filter_complex [0:v][1:v]overlay=main_w-overlay_w-10:main_h-overlay_h-10[out] -map [out] -map 0:a -codec:a copy /storage/sdcard0/test/hsgjr_watermark.mp4

这篇关于ffmpeg - 在android中使用过滤器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆