我有两个不同的视频,我正在尝试加载到VideoView
使用中
videoView.setVideoURI(Uri.parse(url));
Run Code Online (Sandbox Code Playgroud)
这两个视频,即视频1和视频2,具有以下规格(使用提取ffmpeg -i
); 实际上,它们是同一视频的两种不同编码:
视频1:
Seems stream 0 codec frame rate differs from container frame rate: 180000.00 (180000/1) -> 90000.00 (180000/2)
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '4fbfd5ece4b0932236fc234d.mp4':
Metadata:
major_brand : mp42
minor_version : 0
compatible_brands: mp42isomavc1
creation_time : 2011-12-03 04:43:46
genre : Trailer
artist : Paramount Pictures
title : Captain America: The First Avenger - Theatrical Trailer #2
encoder : HandBrake 4344svn 2011111001
date : 2011
Duration: 00:02:30.67, start: 0.000000, bitrate: 6738 …
Run Code Online (Sandbox Code Playgroud)我的情况是我不应该打扰现有的CMakeLists.txt文件,但我仍然应该在我的构建中添加一些g ++系统包含目录.
换句话说,我需要-isystem /path/to/my/include
添加到我的编译器标志,但在调用类似的东西时cmake ..
.
也许是这样的cmake .. -DCMAKE_CXX_FLAGS="$CMAKE_CXX_FLAGS -isystem /path/to/my/include"
?有没有办法做到这一点?
与Android不同,我对GL/libgdx相对较新.我需要解决的任务,即将Android相机的YUV-NV21预览图像实时渲染到libgdx内部的屏幕背景是多方面的.以下是主要关注点:
Android相机的预览图像仅保证在YUV-NV21空间中(在类似的YV12空间中,U和V通道不交错但分组).假设大多数现代设备提供隐式RGB转换是非常错误的,例如最新的Samsung Note 10.1 2014版本仅提供YUV格式.由于除非是RGB格式,否则无法在OpenGL中向屏幕绘制任何内容,因此必须以某种方式转换颜色空间.
libgdx文档(集成libgdx和设备摄像头)中的示例使用Android表面视图,该视图低于使用GLES 1.1绘制图像的所有内容.自2014年3月初以来,由于过时而几乎所有设备都支持GLES 2.0,因此从libgdx中删除了OpenGLES 1.x支持.如果您使用GLES 2.0尝试相同的样本,则在图像上绘制的3D对象将是半透明的.由于背后的表面与GL无关,因此无法真正控制.禁用BLENDING/TRANSLUCENCY不起作用.因此,渲染此图像必须完全在GL中完成.
这必须是实时完成的,因此色彩空间转换必须非常快.使用Android位图的软件转换可能会太慢.
作为侧面功能,必须可以从Android代码访问摄像机图像,以执行除在屏幕上绘制之外的其他任务,例如通过JNI将其发送到本机图像处理器.
问题是,这项任务如何正确,尽可能快地完成?
在我的应用程序中,我从HttpGet请求获取两个cookie并将它们存储在CookieManager中,如下所示:
//Clear old cookies
CookieManager.getInstance().removeAllCookie();
CookieSyncManager.getInstance().sync();
//Save the two cookies: auth token and session info
List<Cookie> cookies = httpclient.getCookieStore().getCookies();
if (cookies != null) {
for (Cookie cookie : cookies) {
String cookieString = cookie.getName() + "=" + cookie.getValue() + "; Domain=" + cookie.getDomain();
CookieManager.getInstance().setCookie("http://alpha.mydomainname.com", cookieString);
}
System.out.println(CookieManager.getInstance().hasCookies()); //Prints false in 2.3, true in 4.0.3
CookieSyncManager.getInstance().sync();
System.out.println(CookieManager.getInstance().hasCookies()); //Also prints false in 2.3 and true in 4.0.3
}
Run Code Online (Sandbox Code Playgroud)
我在两个不同的设备中测试相同的代码,有趣的是,在4.0.3中正确设置了cookie(并且在应用程序的启动之间也是如此),而不是在2.3.3中.当我说它们没有设置时,我的意思是hasCookies()返回false,并且当我提供URL时getCookie()返回null.
我在调用setCookie时尝试了Cookie URL的所有可能组合:"http://alpha.mydomainname.com","http://www.mydomainname.com","http://mydomainname.com"," mydomainname.com","alpha.mydomainname.com",".mydomainname.com","www.mydomainname.com",它们都不起作用.请帮忙.
用Qt创建dir有问题.我想在文档中创建一个目录,所以,我做了一些类似的事情:
QString path("C:/Users/Me/Documents/MyApp/profiles/");
Qdir dir = QDir::root();
dir.mkdir(path);
Run Code Online (Sandbox Code Playgroud)
但这不起作用!我用"/"和"\"测试分隔符,但在两种情况下不起作用.
我怎么能创造我的目录?
谢谢.
我想用以下内容标记文件的一部分:
// clang-format -style="{ SomeSetting: NewValue }"
...
// clang-format -style="{ SomeSetting: OldValue }"
Run Code Online (Sandbox Code Playgroud)
这将覆盖根文件中的全局设置.clang-format
。如果不可能,也可以对单个文件进行特定格式设置,因为我可以通过在自己的文件中隔离需要特定格式设置的部分来解决此问题。我有一个 git 预提交钩子,可以对暂存文件以及clang-format
独立运行的 IDE 插件进行格式化,但我不想在这些地方标记特定文件和特定设置。
我现在能做的最好的事情就是使用自定义设置格式化文件,在该部分周围放置// clang-format off
,// clang-format on
保护并恢复设置,从长远来看,这是不可持续的。有更好的解决方案吗?
我可以以任何方式使用模板类型作为插槽或信号参数吗?作为一个例子,我试图定义以下内容:
void exampleSignal(std::map<non_template_type_1,non_template_type_2> arg);
void exampleSlot(std::map<non_template_type_1,non_template_type_2> arg);
Run Code Online (Sandbox Code Playgroud)
这会在运行时导致以下结果:
QObject::connect: Cannot queue arguments of type
'std::map<non_template_type_1,non_template_type_2>'
(Make sure 'std::map<non_template_type_1,non_template_type_2>'
is registered using qRegisterMetaType().)
Run Code Online (Sandbox Code Playgroud)
试图注册std::map<non_template_type_1,non_template_type_2>
与Q_DECLARE_METATYPE()
在编译失败的结果,显然不支持.
作为一种解决方法,我正在使用QVariantMap
而不是std::map
.但我真的想知道解决这个问题的正确方法; 一个无法修改模板类的地方.
编辑:我忘了提到信号和插槽是在不同的线程中发出和接收的.显然,单线程方案中不会发生运行时错误.
我想做的是在c ++中使用以下枚举:
class MyClass : public QQuickItem {
Q_OBJECT
Q_PROPERTY(MyEnum enumValue READ getEnumValue)
public:
enum MyEnum{
MyEnumElement = 0
};
Q_ENUM(MyEnum)
slots:
MyEnum getEnumValue(){
return enumValue;
}
private:
MyEnum enumValue = MyEnumElement;
};
Run Code Online (Sandbox Code Playgroud)
在QML中以这种方式:
MyClass {
id: myClass
}
Text {
text: "enumValue is: " + myClass.enumValue
}
Run Code Online (Sandbox Code Playgroud)
这将导致enumValue is MyEnumElement
,而不是enumValue is 0
它现在的情况。我现在拥有的解决方案如下,但比较小巧:
class MyClass : public QQuickItem {
Q_OBJECT
Q_PROPERTY(MyEnum enumValue READ getEnumValue)
public:
enum MyEnum{
MyEnumElement = 0
};
Q_ENUM(MyEnum)
QMetaEnum MyEnum_MetaEnum = QMetaEnum::fromType<MyEnum>(); …
Run Code Online (Sandbox Code Playgroud) 我想定义以下普通的宏:
#define MY_ENUM enum MyEnum{ \
myVal0, \ //Describes this situation
myVal2 \ //Describes that situation
}
Run Code Online (Sandbox Code Playgroud)
令我惊讶的是,这不起作用error: stray ‘\’ in program
.反斜杠导致后甚至是一些空格warning: backslash and newline separated by space
.正如这个答案所指出的那样,反斜杠必须是该行的最后一个字符.这个答案指出在处理注释之前会发生行拼接.之所以选择这个订单,对我来说绝对没有意义; 我可以想象这样做的唯一原因是允许多行评论,如下所示:
//This is a comment which \
follows in the next line
Run Code Online (Sandbox Code Playgroud)
这看起来非常危险,因为这样的事情可能只会吞噬下一行中的任何代码.相反的顺序,即在拼接线之前用单个空格替换每个注释听起来像是一个更明智的选择.有人可以解释为什么做出这个选择吗?
我可以通过以下方法解决原始问题:
#define MY_ENUM enum MyEnum{ \
myVal1, /*Describes this situation*/ \
myVal2 /*Describes that situation*/ \
}
Run Code Online (Sandbox Code Playgroud)
我做这个笨拙的枚举宏定义的目的是这个宏必须在c ++(由于Qt绝对必须是一个类成员)和c之间共享.定义一个这样的宏看起来像是我的唯一解决方案,但上面的解决方案看起来很难看,我绝对不想让枚举取消注释.我接近这个问题了吗?
我最近将远程重命名为新别名,旧别名(及其重命名之前的所有提交)仍然在日志中可见,因此 gitk. 跑步
$ git remote show old-alias
Run Code Online (Sandbox Code Playgroud)
显然返回:
fatal: 'old-alias' does not appear to be a git repository
Run Code Online (Sandbox Code Playgroud)
这很烦人。如何彻底删除这些引用?我手动删除可以吗
.git/logs/refs/remotes/old-alias/
.git/refs/remotes/old-alias/
Run Code Online (Sandbox Code Playgroud)
目录?
编辑:
这是git remote -v
输出:
origin git@github.com:my-user/our-repo (fetch)
origin git@github.com:my-user/our-repo (push)
upstream git@github.com:upstream-user/our-repo (fetch)
upstream git@github.com:upstream-user/our-repo (push)
Run Code Online (Sandbox Code Playgroud)
这是git log --oneline --graph --decorate
输出:
* 692d53f (HEAD, origin/somebranch, somebranch) Commit message
* 9a4e794 Commit message
* 419376b Commit message
* 9a945bd (origin/someotherbranch, someotherbranch) Commit message
* 9a0fe3b Commit message
* 021d553 Commit message
* fa60dba Commit …
Run Code Online (Sandbox Code Playgroud) 我的标题中有一堆#pragma message("A message")
s config.h
,它们包含在项目的许多地方;目标是告知在构建过程中选择了哪些配置选项。标头受到#ifndef #define
样式标头保护的保护。问题是每次包含此标头时,都会打印该消息。有没有更好的方法来做到这一点,以便在构建过程中仅打印一次消息?
编辑:我知道构建选项通常是使用 cmake、qmake、autotools 等构建工具来操作和查看的。但由于项目的性质,我实际上对构建工具没有选择。
我在c ++中定义了以下QML对象:
class MyObj : public QQuickItem {
Q_OBJECT
Q_PROPERTY(QVariant func MEMBER func)
public slots:
void callFunc(){
//Call function pointed by "func" somehow
}
private:
QVariant func;
};
Run Code Online (Sandbox Code Playgroud)
在QML中我使用MyObj
如下:
MyObj{
func: function test(){ console.log("Hi!"); }
Button{
text: "Call func"
onClicked: parent.callFunc()
}
}
Run Code Online (Sandbox Code Playgroud)
我收到以下错误:
Unable to assign a function to a property of any type other than var.
Run Code Online (Sandbox Code Playgroud)
我不明白,是不是一个QVariant
应该是相同的属性property var
?这样做的正确方法是什么?
显然,children
属性被记录为a list<Item>
,没有内置的Javascript indexOf(element)
.以下代码:
Item{
id: exampleParent
Item{ id: exampleChild }
}
Button{
text: "Get index"
onClicked: console.log(exampleParent.children.indexOf(exampleChild))
}
Run Code Online (Sandbox Code Playgroud)
会抛出TypeError: Property 'indexOf' of object [object Object] is not a function
错误.
为什么会这样,有什么具体原因吗?有没有比手动遍历children
阵列更好的解决方案?