|
Hmm, maybe GDI+[^], it comes with Windows. If you don't like that either then depending on your needs i would google for some 3rd party library like jpeglib.
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> Computers are evil, EVIL i tell you!! <
|
|
|
|
|
Hi all,
I am working on transcoding using ffmeg.Im having the mpeg4 video and alaw audio which should be converted to the desired video and audio format.Im reading the frame by frame conversion from my media stream using av_read_frame(...)
int main(int argc, char **argv)
{
const char *filename;
AVOutputFormat *fmt;
AVFormatContext *oc;
AVFormatContext *ic;
AVCodecContext *pCodecCtx;
AVCodec *pCodec;
AVStream *audio_st, *video_st;
int i,frame,video_stream;
av_register_all();
filename = "test.mp4";
if(av_open_input_file(&ic, filename, NULL, 0, NULL)!=0)
return -1;
if(av_find_stream_info(ic)<0)
return -1;
video_stream=-1;
for(i=0; i<10; i++)
if(ic->streams[i]->codec->codec_type==CODEC_TYPE_VIDEO)
{
video_stream=i;
break;
}
if(video_stream==-1)
return -1;
pCodecCtx=ic->streams[video_stream]->codec;
pCodec=avcodec_find_decoder(pCodecCtx->codec_id);
if(pCodec==NULL) return -1;
if(avcodec_open(pCodecCtx, pCodec)<0) return -1;
AVPacket pkt;
AVFrame videoFrame;
fmt = guess_format(NULL, filename, NULL);
if (!fmt) {
printf("Could not deduce output format from file extension: using MPEG.\n");
fmt = guess_format("mpeg", NULL, NULL);
}
if (!fmt) {
fprintf(stderr, "Could not find suitable output format\n");
exit(1);
}
oc = av_alloc_format_context();
if (!oc) {
fprintf(stderr, "Memory error\n");
exit(1);
}
oc->oformat = fmt;
_snprintf(oc->filename, sizeof(oc->filename), "%s", filename);
AVStream* stream = av_new_stream(oc, 0);
AVCodecContext* videoEncoderContext = stream->codec;
setupVideoEncode(videoEncoderContext);
stream->sample_aspect_ratio = av_d2q(1, 255);
stream->pts_wrap_bits = 33;
stream->codec->thread_count = 0;
if (av_set_parameters(oc, 0) < 0) {
return 0;
}
AVCodec* codec = avcodec_find_encoder(videoEncoderContext->codec_id);
if (!codec)
{
return 0;
}
if (avcodec_open(videoEncoderContext, codec) < 0)
{
return 0;
}
av_write_header(oc);
const char *ofilename = "testresult.mp4";
if (!(fmt->flags & AVFMT_NOFILE)) {
if (url_fopen(&oc->pb, ofilename, URL_WRONLY) < 0) {
fprintf(stderr, "Could not open '%s'\n", filename);
exit(1);
}
}
int audioFrameFinished = 0;
int videoFrameFinished = 0;
const int outbuf_size = 640000;
uint8_t outbuf[outbuf_size];
int64_t lastpts = 0;
while(av_read_frame( ic, &pkt ) == 0)
{
if (video_stream == pkt.stream_index)
{
avcodec_get_frame_defaults(&videoFrame);
avcodec_decode_video(pCodecCtx, &videoFrame,&videoFrameFinished,pkt.data, pkt.size);
videoFrame.pts = pkt.dts;
if (videoFrameFinished)
{
int out_size = avcodec_encode_video(videoEncoderContext,outbuf, outbuf_size, &videoFrame); if (out_size > 0)
{
AVPacket outpkt;
av_init_packet(&outpkt);
outpkt.data = outbuf;
outpkt.size = out_size;
outpkt.stream_index = 0;
outpkt.dts = outpkt.pts = videoEncoderContext->coded_frame->pts;
outpkt.flags |=(videoEncoderContext->coded_frame->key_frame) ? PKT_FLAG_KEY : 0;
if (av_write_frame (oc, &outpkt) < 0)
{
return 0;
}
}
}
}
av_free_packet( &pkt );
}
av_write_trailer(oc);
avcodec_close(videoEncoderContext);
av_free(videoEncoderContext);
for(i = 0; i < oc->nb_streams; i++) {
av_freep(&oc->streams[i]);
}
if (!(fmt->flags & AVFMT_NOFILE)) {
url_fclose(oc->pb);
}
av_free(oc);
return 0;
} )
In the above code,the bold statements failed always..(avcodec_open() after avcodec_find_encoder() and avcodec_encode_video(...))
Do any one help me?
Thanx..
|
|
|
|
|
Try calling
avcodec_init();
avcodec_register_all();
near av_register_all();
|
|
|
|
|
hi
I have solved that by assigning correct parameters...(In setupVideoEncode(videoEncoderContext)).
But now im getting crash in av_write_frame(..)inside that loop.
pls help me..
|
|
|
|
|
Hi all,
i m working on Rapi function,so i m using Rapi and Ceutil dll,
but here CFileDialog display strange behaviour,
when i open CFileDialog its crash when Mobile device center not installed,or Rapi.dll and Ceutil.dll place in application exe folder.
please help me how can i resolve this.
thanks in advance.
|
|
|
|
|
To rule out MFC, try using GetOpenFileName() or GetSaveFileName() instead.
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Man who follows car will be exhausted." - Confucius
|
|
|
|
|
Hi. It can be total removed menu toolbar from an MDI project ? I do this thing in an SDI project , but in MDI failed ...
|
|
|
|
|
You can hide a menubar by this:
m_wndMenuBar.ShowWindow(SW_HIDE);
|
|
|
|
|
m_wndMenuBar is not member data of CMainFrame ....
|
|
|
|
|
I work only in VC6 , that's why m_wndMenuBar is not data member of CMainFrame ...
|
|
|
|
|
How do i know that my process is running as an administrator ??
Thanks in advance...
Yes U Can ...If U Can ,Dream it , U can do it ...ICAN
|
|
|
|
|
|
How can CreateProcess() be used to tell if a process is being run as administrator?
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Man who follows car will be exhausted." - Confucius
|
|
|
|
|
Hey Everyone. My problem is it seems that when I create a .cpp file for a .hpp, when dealing with inheritance, I get the same error which is :
5>c:\users\rob\school work\information technology\computer programming with c++\projects\inherit_1\inherit_5\geogroup.hpp(20) : error C2146: syntax error : missing ';' before identifier 'GeoGroup'
5>c:\users\rob\school work\information technology\computer programming with c++\projects\inherit_1\inherit_5\geogroup.hpp(20) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
5>c:\users\rob\school work\information technology\computer programming with c++\projects\inherit_1\inherit_5\geogroup.hpp(20) : error C2470: 'GeoGroup' : looks like a function definition, but there is no parameter list; skipping apparent body
5>c:\users\rob\school work\information technology\computer programming with c++\projects\inherit_1\inherit_5\geogroup.hpp(20) : error C2059: syntax error : 'public'
5>c:\users\rob\school work\information technology\computer programming with c++\projects\inherit_1\inherit_5\geogroup.cpp(14) : error C2653: 'GeoGroup' : is not a class or namespace name
5>c:\users\rob\school work\information technology\computer programming with c++\projects\inherit_1\inherit_5\geogroup.cpp(15) : error C2270: 'draw' : modifiers not allowed on nonmember functions
5>c:\users\rob\school work\information technology\computer programming with c++\projects\inherit_1\inherit_5\geogroup.cpp(16) : error C2065: 'elems' : undeclared identifier
5>c:\users\rob\school work\information technology\computer programming with c++\projects\inherit_1\inherit_5\geogroup.cpp(16) : error C2228: left of '.size' must have class/struct/union
5> type is ''unknown-type''
5>c:\users\rob\school work\information technology\computer programming with c++\projects\inherit_1\inherit_5\geogroup.cpp(18) : error C2065: 'elems' : undeclared identifier
5>c:\users\rob\school work\information technology\computer programming with c++\projects\inherit_1\inherit_5\geogroup.cpp(18) : error C2227: left of '->move' must point to class/struct/union/generic type
5>c:\users\rob\school work\information technology\computer programming with c++\projects\inherit_1\inherit_5\geogroup.cpp(18) : error C2065: 'refpoint' : undeclared identifier
5>c:\users\rob\school work\information technology\computer programming with c++\projects\inherit_1\inherit_5\geogroup.cpp(19) : error C2065: 'elems' : undeclared identifier
5>c:\users\rob\school work\information technology\computer programming with c++\projects\inherit_1\inherit_5\geogroup.cpp(19) : error C2227: left of '->draw' must point to class/struct/union/generic type
5>c:\users\rob\school work\information technology\computer programming with c++\projects\inherit_1\inherit_5\geogroup.cpp(20) : error C2065: 'elems' : undeclared identifier
5>c:\users\rob\school work\information technology\computer programming with c++\projects\inherit_1\inherit_5\geogroup.cpp(20) : error C2227: left of '->move' must point to class/struct/union/generic type
5>c:\users\rob\school work\information technology\computer programming with c++\projects\inherit_1\inherit_5\geogroup.cpp(20) : error C2065: 'refpoint' : undeclared identifier
5>c:\users\rob\school work\information technology\computer programming with c++\projects\inherit_1\inherit_5\geogroup.cpp(27) : error C2653: 'GeoGroup' : is not a class or namespace name
5>c:\users\rob\school work\information technology\computer programming with c++\projects\inherit_1\inherit_5\geogroup.cpp(32) : error C2065: 'elems' : undeclared identifier
5>c:\users\rob\school work\information technology\computer programming with c++\projects\inherit_1\inherit_5\geogroup.cpp(32) : error C2228: left of '.begin' must have class/struct/union
5> type is ''unknown-type''
5>c:\users\rob\school work\information technology\computer programming with c++\projects\inherit_1\inherit_5\geogroup.cpp(32) : error C2065: 'elems' : undeclared identifier
5>c:\users\rob\school work\information technology\computer programming with c++\projects\inherit_1\inherit_5\geogroup.cpp(32) : error C2228: left of '.end' must have class/struct/union
5> type is ''unknown-type''
5>c:\users\rob\school work\information technology\computer programming with c++\projects\inherit_1\inherit_5\geogroup.cpp(33) : error C2065: 'elems' : undeclared identifier
5>c:\users\rob\school work\information technology\computer programming with c++\projects\inherit_1\inherit_5\geogroup.cpp(33) : error C2228: left of '.end' must have class/struct/union
5> type is ''unknown-type''
5>c:\users\rob\school work\information technology\computer programming with c++\projects\inherit_1\inherit_5\geogroup.cpp(35) : error C2065: 'elems' : undeclared identifier
5>c:\users\rob\school work\information technology\computer programming with c++\projects\inherit_1\inherit_5\geogroup.cpp(35) : error C2228: left of '.erase' must have class/struct/union
5> type is ''unknown-type''
here is an example of what I am trying to get complied:
the header file
#ifndef GEOGROUP_HPP
#define GEOGROUP_HPP
#include "geo.hpp"
#include <vector>
namespace Geo
{
Class GeoGroup : public GeoObj
{
protected:
std::vector<GeoObj*> elems;
public:
GeoGroup(const Coord& p = Coord(0,0)) : GeoObj(p)
{
}
virtual void draw() const;
virtual void add(GeoObj&);
virtual bool remove(GeoObj&);
virtual ~GeoGroup()
{
}
};
}
#endif //GEOGROUP_HPP
and the dotC file:
#include "geogroup.hpp"
#include <algorithm>
namespace Geo
{
void GeoGroup::draw() const
{
for (unsigned i = 0 ; i < elems.size(); ++i)
{
elems[i]->move(refpoint);
elems[i]->draw();
elems[i]->move(-refpoint);
}
}
bool GeoGroup::remove(GeoObj& obj)
{
std::vector<GeoObj*>::iterator pos;
pos = std::find(elems.begin(), elems.end(), &obj);
if (pos != elems.end())
{
elems.erase(pos);
return true;
}
else
{
return false;
}
}
}
This seems to me to be a linking problem, and also I realized that I might have something to do with having multiple .hpp and multiple .cpp implementation files.
Anyone have an idea on what I am doing wrong?
Thanks,
RobNO.
|
|
|
|
|
The keyword class should have a lower-case 'c'.
|
|
|
|
|
Thank you very much
RobNO
|
|
|
|
|
RobNO wrote: This seems to me to be a linking problem
when the first error message says "missing ;" it is a compiler error, not a linking problem.
Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]
I only read formatted code with indentation, so please use PRE tags for code snippets.
I'm not participating in frackin' Q&A, so if you want my opinion, ask away in a real forum (or on my profile page).
|
|
|
|
|
An often ocurring syntax error: a class declaration should end with a semicolumn.
class C {
} void f(){
}
|
|
|
|
|
I have an HMENU that shows a typical context menu.
What I want to do is make a large context menu like win98 start menu.
Any particular method?
|
|
|
|
|
Check out this[^] article, it might be usefull.
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> Sometimes you just have to hate coding to do it well. <
|
|
|
|
|
I don't work with MFC. Is there a way to do it in C within the native API?
|
|
|
|
|
Well, since MFC is just a wrapper around the API, i'd say yes, in my oppinion what you need is an owner drawn menu, i think this[^] should help.
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> Computers are evil, EVIL i tell you!! <
|
|
|
|
|
|
Hi,
In Internet Explorer, when I click on a link and go back to the previous site I am exactly at the same position of the document where I left. Even the link I clicked is still marked by a thin border.
I have an application where I keep track on the history on my own. Now I need exactly the same behaviour.
I think i need to save the "state" (scrollposition and "marked" link) in my history array and restore it afterwards when I load the old site again.
Does anybody know how to achieve this?
If this is hopeless it would also be enough to just save to current (scroll-)position. However, the loaded documents are complex with different divs which have overflow:auto, overflow:hidden etc. So I can't just get_body, query IHTMLTextContainer and afterwards get_scrollTop etc. because those would be the scroll stuff from the document itself...
Thank you for any hints!
|
|
|
|
|
I want to create a dll which can create custom controls like custom dialog and custom button etc..
Can anybody tell me how to do that..
Please help me regarding this..
Thanks
|
|
|
|