我正在使用ffmpeg终端从MP4视频中提取帧图像.
我使用了命令:
ffmpeg -i Video.MP4 Pictures%d.bmp
Run Code Online (Sandbox Code Playgroud)
问题是提取的图像大小为4.5-5MB!我想要更小的图像,比如大约1-2 MB.如何限制输出图像的大小?
请考虑以下数据:
d = data.frame(
experiment = as.factor(c("foo", "foo", "foo", "bar", "bar")),
si = runif(5),
ti = runif(5)
)
Run Code Online (Sandbox Code Playgroud)
我想为进行相关测试si,并ti为每个experiment因子水平.所以我以为我会跑:
ddply(d, .(experiment), cor.test)
Run Code Online (Sandbox Code Playgroud)
但我怎么传递的价值观si和ti对cor.test通话?我试过这个:
> ddply(d, .(experiment), cor.test, x = si, y = ti)
Error in .fun(piece, ...) : object 'si' not found
> ddply(d, .(experiment), cor.test, si, ti)
Error in match.arg(alternative) :
'arg' must be NULL or a character vector
Run Code Online (Sandbox Code Playgroud)
有什么明显我想念的吗?该plyr文件不包括给我的例子.我看到的大多数命令只涉及summarize函数调用,但是我常常做的summarize事情不起作用,如上所示.
假设我有一个Date类似的Ruby数组:
2011-01-20
2011-01-23
2011-02-01
2011-02-15
2011-03-21
Run Code Online (Sandbox Code Playgroud)
什么是一种简单易用的Ruby方式创建一个Hash,按年和月分组Date元素,如:
{
2011 => {
1 => [2011-01-20, 2011-01-23],
2 => [2011-02-01, 2011-02-15],
3 => [2011-03-21],
}
}
Run Code Online (Sandbox Code Playgroud)
我可以通过迭代所有内容并提取数年,数月等来实现这一点,然后将它们组合起来.
Ruby为Arrays和Hashes提供了很多方法和块,必须有一个更简单的方法吗?
这有点奇怪.
我有一条路线:
match "program/:program_id" => "program#details"
Run Code Online (Sandbox Code Playgroud)
在调用它时,一切正常:
/program/1
Run Code Online (Sandbox Code Playgroud)
但是,我使用的程序ID不仅仅是数字.它们实际上是这样的URL:crid://blah.com/d1e5
如何通过RESTful方法传递URL作为参数?
显然,调用它不起作用:
/program/crid://blah.com/d1e5
/program/crid%3A%2F%2Fblah.com%2Fd1e5
Run Code Online (Sandbox Code Playgroud) 我想将多个文件附加到电子邮件中.
首先,我准备了一份清单Uri.
void prepareListOfUri()
{
listOfUri = new ArrayList<Uri>();
File fileTemp = new File(android.os.Environment.getExternalStorageDirectory(), "BuyNowImages");
fileTemp.mkdirs();
for (int i = 0; i < listOfImageView.size(); i++)
{
try
{
ByteArrayOutputStream bos = new ByteArrayOutputStream();
Drawable drawable = listOfImageView.get(i).getDrawable();
Bitmap bitmapPicked = ((BitmapDrawable) drawable).getBitmap();
bitmapPicked.compress(CompressFormat.JPEG, 75, bos);
byte[] image = bos.toByteArray();
File file = new File(fileTemp, "buynow_product" + i + ".jpg");
file.createNewFile();
// write the bytes in file
FileOutputStream fo = new FileOutputStream(file);
fo.write(image);
Uri uri = Uri.parse("file://" + file.getAbsolutePath()); …Run Code Online (Sandbox Code Playgroud) 我正在使用ffmpeg从几个视频文件中获取图像。我ffmpeg准备好了代码,但是当我exec编写代码时出现以下错误。
ffmpeg version 0.8.6-4:0.8.6-0ubuntu0.12.04.1, Copyright (c) 2000-2013 the Libav developers
built on Apr 2 2013 17:02:36 with gcc 4.6.3
*** THIS PROGRAM IS DEPRECATED ***
This program is only provided for compatibility and will be removed in a future release. Please use avconv instead.
//files info...
//files info...
Incompatible pixel format 'yuv420p' for codec 'mjpeg', auto-selecting format 'yuvj420p'
//file info...
[buffer @ 0x1513c40] Buffering several frames is not supported. Please consume all available frames …Run Code Online (Sandbox Code Playgroud) 我无法弄清楚如何使C#正则表达式IsMatch匹配a <keyword>后跟行尾或空格.
我目前有[\s]+keyword[\s]+哪些适用于空间,但不适用于keyword<end of string>或<start of string>keyword.
我试过了[\s^]+keyword[\s$]+,但是这使它无法与空格匹配,并且在字符串的结尾或开头不起作用.
这是我试过的代码:
string pattern = string.Format("[\\s^]+{0}[\\s$]+",keyword);
if(Regex.IsMatch(Text, pattern, RegexOptions.IgnoreCase))
Run Code Online (Sandbox Code Playgroud) 我正在尝试使用Cygwin和Python 2.7并行运行一些ffmpeg命令.
这大致是我所拥有的:
import subprocess
processes = set()
commands = ["ffmpeg -i input.mp4 output.avi", "ffmpeg -i input2.mp4 output2.avi"]
for cmd in commands:
processes.add(
subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True)
)
for process in processes:
if process.poll() is None:
process.wait()
Run Code Online (Sandbox Code Playgroud)
现在,一旦我在这段代码的末尾,整个程序就会等待.创建了所有ffmpeg进程,但它们处于空闲状态,即使用0%CPU.而Python程序一直在等待.只有当我按下Ctrl-C时,它才会突然开始编码.
我究竟做错了什么?我是否必须向流程"发送"一些内容才能启动它们?
我有一张表(d.tab),里面有一个调查问答对.其中一些是单选答案,一些是多项选择.我想从数值中查找单选答案的文本值.为此,我有一个查找表(d.lookup).
我试过merge这些,但它有点难看,因为我现在必须过滤掉所有的行value != answer_id.有没有更漂亮的方法,可能使用plyr或dplyr或tidyr?
tab = '
question_id question_type subject value
1 single-choice 1 1
2 multiple-choice 1 2
3 single-choice 1 2
1 single-choice 2 2
2 multiple-choice 2 3,4
3 single-choice 2 2
'
lookup = '
question_id answer_id answer_text
1 1 female
1 2 male
3 1 no
3 2 yes
'
d.tab = read.table(text = tab, header = TRUE)
d.lookup = read.table(text …Run Code Online (Sandbox Code Playgroud) 是)我有的:
我有一个如下所示的数据框:
sequence foo model output real
1 3 a 12 12
1 3 b 29 12
1 3 c 10 12
1 3 d 38 12
1 3 e 10 12
2 3 a 38 15
2 3 b 10 15
2 3 c 29 15
2 3 d 56 15
2 3 e 10 15
Run Code Online (Sandbox Code Playgroud)
由...制作:
d.test = data.frame(
sequence = c(1, 1, 1, 1, 1, 2, 2, 2, 2, 2),
foo = c(3, 3, 3, 3, 3, …Run Code Online (Sandbox Code Playgroud)