FFMPEG:向视频添加字体会出错 [英] FFMPEG : Adding font to Video gives error

查看:2161
本文介绍了FFMPEG:向视频添加字体会出错的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在android上执行ffmpeg。我也成功执行了2-3个命令。但是,我坚持一点,其中我正在向视频添加文本



这是我正在执行的命令。



NOT WORKING :因为文本参数之间有一个空格话。

  - 我+ path +out.mp4 -vf drawtext = fontfile =+ path +f1.ttf:text = 'Stack OverFlow'-y -c:v libx264 -c:a copy -movflags + faststart+ path +output.mp4

WORKING:刚刚删除空格

  -  i+ path +out.mp4 -vf drawtext = fontfile =+ path +f1.ttf:text ='StackOverFlow'-y -c:v libx264 -c:a copy -movflags + faststart+ path + output.mp4

这里路径包含我的外部Sd卡的路径。 out.mp4 f1.ttf 存在于我的文件夹中。



这是我获得的堆栈跟踪。

 失败与输出:警告:链接器:/data/data/com.github.hiteshsondhi88.sampleffmpeg/files/ffmpeg有文本重定位。这是浪费记忆,防止安全性加强。请修复
ffmpeg版本n3.0.1版权所有(c)2000-2016 FFmpeg开发人员
内置gcc 4.8(GCC)
配置:--target-os = linux --cross-prefix = home / vagrant / SourceCode / ffmpeg-android / toolchain-android / bin / i686-linux-android- --arch = x86 --cpu = i686 --enable-runtime-cpudetect --sysroot = / home / vagrant / SourceCode / ffmpeg-android / toolchain-android / sysroot --enable-pic --enable-libx264 --enable-libass --enable-libfreetype --enable-libfribidi --enable-libmp3lame --enable-fontconfig --enable-pthreads - -disable-debug --disable-ffserver --enable-version3 --enable-hardcoded-tables --disable-ffplay --disable-ffprobe --enable-gpl --enable-yasm --disable-doc --disable-共享--enable-static --pkg-config = / home / vagrant / SourceCode / ffmpeg-android / ffmpeg-pkg-config --prefix = / home / vagrant / SourceCode / ffmpeg-android / build / x86 --extra- cflags =' - 我/ home / vagrant / SourceCode / ffmpeg-android / toolchain-android / include -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE = 2 -fno-strict-overflow -fstack-protector-all -march = i686'--extra-ldflags =' - L / home / vagrant / SourceCode / ffmpeg-android / toolchain-android / lib -Wl,-z,relro -Wl,-z,now -pie'--extra-libs = '-lpng -lexpat -lm'--extra-cxxflags =
libavutil 55. 17.103 / 55. 17.103
libavcodec 57. 24.102 / 57. 24.102
libavformat 57. 25.100 / 57. 25.100
libavdevice 57. 0.101 / 57. 0.101
libavfilter 6. 31.100 / 6. 31.100
libswscale 4. 0.100 / 4. 0.100
libswresample 2. 0.101 / 2. 0.101
libpostproc 54. 0.100 / 54. 0.100
从'/storage/emulated/0/Testing/out.mp4'输入#0,mov,mp4,m4a,3gp,3g2,mj2:
元数据:
major_brand:isom
minor_version:512
compatible_brands:isomiso2avc1mp41
编码器:Lavf57.25.100
持续时间:00:00:05.00,开始:0.000000,比特率: 117 kb / s
流#0:0(und):视频:h264(高)(avc1 / 0x31637661),yuv420p,300x300 [SAR 40:33 DAR 40:33],113 kb / s,25 fps ,25 tbr,12800 tbn,50 tbc(默认值)
元数据:
handler_name:VideoHandler
[NULL @ 0xb585f000]无法为'text ='Stack'找到合适的输出格式
text ='Stack:无效参数

为什么说无效参数。如果有任何ffmpeg专家可以指导我在这里做错什么会很棒。



我已经提到了这个SO的问题:视频上的文字ffmpeg

解决方案

SOLVED



我使用文本文件在ffmpeg命令中的字符之间插入 space 。因为直接空间不能正常工作,因为我说的话。



所以建立一个文本文件 text.txt 。内容将是你想要的视频文本。



然后构建如下命令:

  -  i+ path +out.mp4 -vf drawtext = fontfile =+ path +f1.ttf:textfile =+ path +text.ttf -y -c:v libx264 -c :a copy -movflags + faststart+ path +output.mp4

它将运行成功。


I am trying to execute ffmpeg on android. I have successfully executed 2-3 commands also. But i am stuck at one point where i am adding text to the video.

Here is the command i am executing.

NOT WORKING : because the text argument has a space between two words.

"-i "+path+"out.mp4 -vf drawtext=fontfile="+path+"f1.ttf:text='Stack OverFlow' -y -c:v libx264 -c:a copy -movflags +faststart "+path+"output.mp4"

WORKING : just removed space.

"-i "+path+"out.mp4 -vf drawtext=fontfile="+path+"f1.ttf:text='StackOverFlow' -y -c:v libx264 -c:a copy -movflags +faststart "+path+"output.mp4"

Here path contains my external Sd card's path. out.mp4 and f1.ttf exists in my folder.

My Question is why it is not working with space.

Here is the stack trace i am getting.

FAILED with output : WARNING: linker: /data/data/com.github.hiteshsondhi88.sampleffmpeg/files/ffmpeg has text relocations. This is wasting memory and prevents security hardening. Please fix.
ffmpeg version n3.0.1 Copyright (c) 2000-2016 the FFmpeg developers
built with gcc 4.8 (GCC)
configuration: --target-os=linux --cross-prefix=/home/vagrant/SourceCode/ffmpeg-android/toolchain-android/bin/i686-linux-android- --arch=x86 --cpu=i686 --enable-runtime-cpudetect --sysroot=/home/vagrant/SourceCode/ffmpeg-android/toolchain-android/sysroot --enable-pic --enable-libx264 --enable-libass --enable-libfreetype --enable-libfribidi --enable-libmp3lame --enable-fontconfig --enable-pthreads --disable-debug --disable-ffserver --enable-version3 --enable-hardcoded-tables --disable-ffplay --disable-ffprobe --enable-gpl --enable-yasm --disable-doc --disable-shared --enable-static --pkg-config=/home/vagrant/SourceCode/ffmpeg-android/ffmpeg-pkg-config --prefix=/home/vagrant/SourceCode/ffmpeg-android/build/x86 --extra-cflags='-I/home/vagrant/SourceCode/ffmpeg-android/toolchain-android/include -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 -fno-strict-overflow -fstack-protector-all -march=i686' --extra-ldflags='-L/home/vagrant/SourceCode/ffmpeg-android/toolchain-android/lib -Wl,-z,relro -Wl,-z,now -pie' --extra-libs='-lpng -lexpat -lm' --extra-cxxflags=
libavutil      55. 17.103 / 55. 17.103
libavcodec     57. 24.102 / 57. 24.102
libavformat    57. 25.100 / 57. 25.100
libavdevice    57.  0.101 / 57.  0.101
libavfilter     6. 31.100 /  6. 31.100
libswscale      4.  0.100 /  4.  0.100
libswresample   2.  0.101 /  2.  0.101
libpostproc    54.  0.100 / 54.  0.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '/storage/emulated/0/Testing/out.mp4':
Metadata:
major_brand     : isom
minor_version   : 512
compatible_brands: isomiso2avc1mp41
encoder         : Lavf57.25.100
Duration: 00:00:05.00, start: 0.000000, bitrate: 117 kb/s
Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 300x300 [SAR 40:33 DAR 40:33], 113 kb/s, 25 fps, 25 tbr, 12800 tbn, 50 tbc (default)
Metadata:
handler_name    : VideoHandler
[NULL @ 0xb585f000] Unable to find a suitable output format for 'text='Stack'
text='Stack: Invalid argument

Why it is saying invalid argument. It will be great if any ffmpeg expert can guide me in what i am doing wrong here.

I have refered this Question of SO : Text on video ffmpeg

解决方案

SOLVED

I used text file for inserting space between characters in ffmpeg command. As the direct space was not working as i said in question.

So build a text file text.txt. The contents will be the text you want on your video.

Then build the command like this :

"-i "+path+"out.mp4 -vf drawtext=fontfile="+path+"f1.ttf:textfile="+path+"text.ttf -y -c:v libx264 -c:a copy -movflags +faststart "+path+"output.mp4"

It will get run successfully.

这篇关于FFMPEG:向视频添加字体会出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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