
Recherche avancée
Autres articles (95)
-
Soumettre bugs et patchs
10 avril 2011Un logiciel n’est malheureusement jamais parfait...
Si vous pensez avoir mis la main sur un bug, reportez le dans notre système de tickets en prenant bien soin de nous remonter certaines informations pertinentes : le type de navigateur et sa version exacte avec lequel vous avez l’anomalie ; une explication la plus précise possible du problème rencontré ; si possibles les étapes pour reproduire le problème ; un lien vers le site / la page en question ;
Si vous pensez avoir résolu vous même le bug (...) -
Les autorisations surchargées par les plugins
27 avril 2010, parMediaspip core
autoriser_auteur_modifier() afin que les visiteurs soient capables de modifier leurs informations sur la page d’auteurs -
Que fait exactement ce script ?
18 janvier 2011, parCe script est écrit en bash. Il est donc facilement utilisable sur n’importe quel serveur.
Il n’est compatible qu’avec une liste de distributions précises (voir Liste des distributions compatibles).
Installation de dépendances de MediaSPIP
Son rôle principal est d’installer l’ensemble des dépendances logicielles nécessaires coté serveur à savoir :
Les outils de base pour pouvoir installer le reste des dépendances Les outils de développements : build-essential (via APT depuis les dépôts officiels) ; (...)
Sur d’autres sites (6042)
-
Error submitting the frame for encoding when submitting NV12 texture
6 mai 2022, par Caio AugustoI'm trying to encode D3D11 NV12 Texture on QSV encoder but getting [h264_qsv @ 00000244ce6f50c0] Error submitting the frame for encoding.


Main :


int width = 1920;
int height = 1080;
FILE* outfile;

fopen_s(&outfile, "D:\\Sources\\D3D11QSV\\x64\\Debug\\outfile.264", "wb");

const AVCodec* codec = avcodec_find_encoder_by_name("h264_qsv");
AVCodecContext* ctx = avcodec_alloc_context3(codec);

ctx->width = width;
ctx->height = height;
ctx->time_base = AVRational{ 1, 60 };
ctx->framerate = AVRational{ 60, 1 };
ctx->slices = 1;

ctx->sw_pix_fmt = AV_PIX_FMT_NV12;
ctx->pix_fmt = AV_PIX_FMT_NV12;
ctx->bit_rate = 400000;
ctx->gop_size = 10;
ctx->max_b_frames = 1;

auto status = avcodec_open2(ctx, codec, NULL);
if (status < 0) {
 std::cout << "Open codec error!\n";
}

AVFrame* sw_frame = av_frame_alloc();
sw_frame->format = ctx->sw_pix_fmt;
sw_frame->width = ctx->width;
sw_frame->height = ctx->height;
status = av_frame_get_buffer(sw_frame, 0);

fill_frame(sw_frame, ctx);



Filling the frame :


auto ret = 0;

if (ret < 0) {
 fprintf(stderr, "Could not allocate the video frame data\n");
 exit(1);
}

int i, y, x, c = 0;
for (i = 0; i < 60; i++) {
 fflush(stdout);

 ret = av_frame_make_writable(frame);
 
 auto texture = create_texture();
 auto desc = (AVD3D11FrameDescriptor*)frame->buf[0]->data;
 desc->texture = (ID3D11Texture2D*)texture;
 desc->index = 0;

 frame->data[0] = (std::uint8_t*)texture;
 frame->data[1] = 0;
 frame->linesize[0] = width * 4;

 frame->pts = i;

 encode(frame, ctx);
}



Creating Texture :


D3D11_TEXTURE2D_DESC const desc = CD3D11_TEXTURE2D_DESC(
 DXGI_FORMAT_NV12, // HoloLens PV camera format, common for video sources
 width, // Width of the video frames
 height, // Height of the video frames
 1, // Number of textures in the array
 1, // Number of miplevels in each texture
 D3D11_BIND_SHADER_RESOURCE, // We read from this texture in the shader
 D3D11_USAGE_DYNAMIC, // Because we'll be copying from CPU memory
 D3D11_CPU_ACCESS_WRITE // We only need to write into the texture
);

ID3D11Device* pd3dDevice = create_d3d11_device();

ID3D11Texture2D* pTexture = NULL;
HRESULT err = pd3dDevice->CreateTexture2D(&desc, nullptr, &pTexture);


if (SUCCEEDED(err)) {
 D3D11_SHADER_RESOURCE_VIEW_DESC SRVDesc = CD3D11_SHADER_RESOURCE_VIEW_DESC(
 pTexture,
 D3D11_SRV_DIMENSION_TEXTURE2D,
 DXGI_FORMAT_R8_UNORM
 );

 ID3D11ShaderResourceView* texSRV = NULL;

 err = pd3dDevice->CreateShaderResourceView(pTexture,
 &SRVDesc, &texSRV);

 D3D11_SHADER_RESOURCE_VIEW_DESC const chrominancePlaneDesc = CD3D11_SHADER_RESOURCE_VIEW_DESC(
 pTexture,
 D3D11_SRV_DIMENSION_TEXTURE2D,
 DXGI_FORMAT_R8G8_UNORM
 );

 ID3D11ShaderResourceView* m_chrominanceView = NULL;

 err = pd3dDevice->CreateShaderResourceView(pTexture,
 &chrominancePlaneDesc, &m_chrominanceView);

}

if (FAILED(err))
{
 fprintf(stderr, "Error creating texture\n");
 exit(1);
}

return pTexture;



Creating D3D11 device :


ID3D11Device* dev11 = NULL;
 ID3D11DeviceContext* devcon11 = NULL;

 D3D_FEATURE_LEVEL featureLevels[]{
 D3D_FEATURE_LEVEL_11_1,
 D3D_FEATURE_LEVEL_11_0,
 D3D_FEATURE_LEVEL_10_1,
 D3D_FEATURE_LEVEL_10_0,
 D3D_FEATURE_LEVEL_9_3,
 D3D_FEATURE_LEVEL_9_2,
 D3D_FEATURE_LEVEL_9_1
 };


 int err = D3D11CreateDevice(
 nullptr,
 D3D_DRIVER_TYPE_HARDWARE,
 nullptr,
 D3D11_CREATE_DEVICE_VIDEO_SUPPORT,
 featureLevels, sizeof(featureLevels) / sizeof(D3D_FEATURE_LEVEL),
 D3D11_SDK_VERSION,
 &dev11,
 nullptr,
 &devcon11);

 return dev11;



Encoding :


auto status = 0;

status = avcodec_send_frame(ctx, frame); //error happening here

AVPacket* pkt;

pkt = av_packet_alloc();

if (status < 0) {
 fprintf(stderr, "Error sending a frame for encoding\n");
 exit(1);
}

while (status >= 0) {
 status = avcodec_receive_packet(ctx, pkt);
 if (status == AVERROR(EAGAIN) || status == AVERROR_EOF)
 return;
 else if (status < 0) {
 fprintf(stderr, "Error during encoding\n");
 exit(1);
 }

 printf("Write packet \n", pkt->pts, pkt->size);
 fwrite(pkt->data, 1, pkt->size, outfile);
 av_packet_unref(pkt);
}



Everything runs well until encoding the frame. I have tried sending a dummy nv12 data (not a d3d11 texture) and it works well.


-
Methods For Retaining State
I jump around between projects. A lot. Over the years, I have employed various methods for retaining state or context as I switch to a different project. Here’s a quick survey and a general classification of their effectiveness.
Good
- Evernote : This is a cloud-based note-taking service that has a web client, Mac and Windows clients, and clients for just about ever mobile platform out there. I have an account and access it via the web interface as as the Windows, iOS, and Android clients. I really like it.
Okay
- Series of text files : I have been doing this for a very long time. I have many little note-filled directories here and there that are consistently migrated to new machines but generally forgotten about. This isn’t a terrible method but can be unwieldy when you work on lots of different machines. I’m still tracking down all these directories and importing them into Evernote.
Bad
- Layout of desktop windows : I have a habit of working on one project in a set of windows on one desktop space and another project in a second set of windows in another space, etc. Oh, this makes me shudder just thinking about it, mostly because of living in constant fear of a power failure or some other inadvertent reset (darn you, default config’d Windows Update) that wipes the state clean (sure, all of the work might have been saved, but I was relying on those windows to be set up in just the right manner to remind me of all the things I was working on). These days, I force myself to reboot at least once a week so I can’t get too deep into this habit. When it’s time to change projects, I write up exactly what I was doing and where I left off and stick it in Evernote.
- Open browser windows : I guess it’s common to have many, many tabs open in one’s web browser in this day and age. Like many, I use open tabs as a stack of items to read. The state problem comes when a few of the open tabs represent TODO items. Then I start living in fear that the browser might crash or be restarted in an unexpected way and I struggle to recall what 3-5 important TODO items were that I had opened in separate tabs (on top of a stack of less important items). Again, I try to shut down the browser frequently in order to break this tendency. TODO items are better filed in Evernote.
- Unsaved data in a text editor : Okay, this is just sloppy on my part, shoving temporary data into a text editor window thinking it’s supremely ephemeral. The problem comes when it’s linked to one of the many tasks on my desktop that might be bumped down a few priority levels ; when finally returning to the context-free data, I’m at a loss to explain what it’s for. Evernote gets it, once more, with a more thorough description of what was going on.
- Email inbox : I make an effort to ensure that my email inbox has the fewest number of messages possible. Once things are dealt with, they get filed away elsewhere. This implies that things in my inbox require action. Some things have a habit of hanging around, though. Longer items now get described in better detail and filed away in Evernote.
- Classic paper : Thanks to Derek in the comments for reminding me of this one. Paper is a reliable standby but it can get unwieldy when Post-It Notes litter your work area. Further, it can be problematic when you have multiple physical work areas.
- Shell history : Another method I rely on entirely too often. This is when I count on a recipe of command line incantations living on in the history buffer of my Unix shell (generally Bash). What sequence of git commands allowed me to do XYZ ? Let’s check the shell history– I sure hope it’s still in there.
Conclusion
I guess what I’m trying to say here is that I really like Evernote. If you have similar troubles with retaining state, try it out. I hear there are many other services similar to it with slightly varying feature sets (people rave about Microsoft OneNote). So there are plenty of options and something out there is surely a fit.Evernote has a free tier and a premium tier. For my meager note-taking needs, I don’t come anywhere close to the free tier’s limit but I decided to pay for a premium subscription simply because I feel like I derive so much value from the service.
One downside, however, is that I seem to be doing a lot less blogging since I got on Evernote earlier this year (though it is where I author most of these posts nowadays ; I especially like that I have a notebook labeled “Posted” whose incrementing count reminds me that I am getting some stuff out there). I originally started this blog as a sort of technical journal in order to organize notes and projects in a central location. It’s strange to think that if Evernote existed in 2005, I might never have had a reason to start this blog.
-
ffmpeg use on iOS
2 juillet 2015, par Chuck Mc DuranI understand that to use FFmpeg in an iOS app, you use the ./configure and make to generate the .a files, that you will add to the project.
My question is, once the .a files show up in the project navigator and in the Link Binary With Libraries section, how do you actually use them in your classes ?, I see there is no "framework" to use in an #import statement, so I don’t know how to access the classes methods and properties.