Videodaten ausgeben, parameter ändern ?!
-
hallo,
ich brauche unbedingt mal ein paar tipps. ich will videodaten (avi oder mpg oder so) mit einem simplen c/c++ programm abspielen. wenn möglich will ich auch parameter ändern für filter etc. keine ahnung wie ich da ran gehen soll. tutorials find ich leider auch nicht im netz. windows/linux ist egal. vielleicht kann mir jemand helfen? welche bibliotheken unterstützen den das?vielen dank schon mal,
greetz
-
Hab da ein paar uralte Sourcen dazu gefunden...
mplayerwnd.h
#ifndef MPLAYERWND_H_INCLUDED #define MPLAYERWND_H_INCLUDED #if _MSC_VER > 1000 #pragma once #endif // _MSC_VER > 1000 #include <mmsystem.h> // Definitionen enum { MPW_PLAY = 10, MPW_HOME, MPW_END, MPW_STEP, MPW_RSTEP, MPW_RPLAY, } ///////////////////////////////////////////////////////////////////////////// // CMediaPlayerWnd window class CMediaPlayerWnd : public CWnd { // Construction public: CMediaPlayerWnd(); // Overrides // ClassWizard generated virtual function overrides //{{AFX_VIRTUAL(CMediaPlayerWndo) public: virtual void OnFinalRelease(); //}}AFX_VIRTUAL // Implementation public: void CenterMediaPlayerWnd(HWND); void Open(HWND hWnd, LPCTSTR szFilter); void Open(LPSTR sVPath, HWND hWnd); void Close(HWND); void Play(HWND, int); void Seek(HWND, int); void Step(HWND, int); virtual ~CMediaPlayerWnd(); protected: MCIERROR GetLastError() const; MCIDEVICEID m_wDeviceID, m_mciDeviceID; HWND m_hwnd; BOOL m_bPlaying, m_bOpened; private: MCIERROR m_dwLastError; BOOL m_bReportErrors; // Generated message map functions protected: //{{AFX_MSG(CMediaPlayerWnd) // NOTE - the ClassWizard will add and remove member functions here. //}}AFX_MSG DECLARE_MESSAGE_MAP() // Generated OLE dispatch map functions //{{AFX_DISPATCH(CMediaPlayerWnd) // NOTE - the ClassWizard will add and remove member functions here. //}}AFX_DISPATCH DECLARE_DISPATCH_MAP() afx_msg LONG OnMciNotify(HWND hWnd,UINT message,WPARAM wParam,LPARAM lParam); DECLARE_INTERFACE_MAP() }; ///////////////////////////////////////////////////////////////////////////// //{{AFX_INSERT_LOCATION}} // Microsoft Visual C++ will insert additional declarations immediately before the previous line. #endif // !defined(MPLAYERWND_H_INCLUDED)
mplayerwnd.cpp
// Fensterklasse zum Abspielen von Mediadateien // winmm.lib muss mitkompiliert werden... // #ifdef _DEBUG #define new DEBUG_NEW #undef THIS_FILE static char THIS_FILE[] = __FILE__; #endif #include "stdafx.h" #include "mplayerwnd.h" #include <digitalv.h> ////////////////////////////////////////////////////////////////////////// // CMediaPlayerWnd CMediaPlayerWnd::CMediaPlayerWnd() { m_mciDeviceID = 0; m_bPlaying = FALSE; m_bOpened = FALSE; EnableAutomation(); } CMediaPlayerWnd::~CMediaPlayerWnd() { } void CMediaPlayerWnd::OnFinalRelease() { CWnd::OnFinalRelease(); } LONG CMediaPlayerWnd::OnMciNotify(HWND hWnd,UINT message,WPARAM wParam,LPARAM lParam) { m_bPlaying = FALSE; mciSendCommand(m_mciDeviceID, MCI_SEEK, MCI_SEEK_TO_START, (DWORD)(LPVOID)NULL); Close(hWnd); return 0L; } BEGIN_MESSAGE_MAP(CMediaPlayerWnd, CWnd) //{{AFX_MSG_MAP(CMediaPlayerWnd) // NOTE - the ClassWizard will add and remove mapping macros here. ON_MESSAGE(MM_MCINOTIFY, OnMciNotify) //}}AFX_MSG_MAP END_MESSAGE_MAP() BEGIN_DISPATCH_MAP(CMediaPlayerWnd, CWnd) //{{AFX_DISPATCH_MAP(CMediaPlayerWnd) // NOTE - the ClassWizard will add and remove mapping macros here. //}}AFX_DISPATCH_MAP END_DISPATCH_MAP() // {F3E179A1-476B-11D4-A880-00E029302FE0} static const IID IID_IVideo = {0xf3e179a1, 0x476b, 0x11d4, { 0xa8, 0x80, 0x0, 0xe0, 0x29, 0x30, 0x2f, 0xe0 }}; BEGIN_INTERFACE_MAP(CMediaPlayerWnd, CWnd) INTERFACE_PART(CMediaPlayerWnd, IID_IVideo, Dispatch) END_INTERFACE_MAP() ////////////////////////////////////////////////////////////////////////// // CenterMediaPlayerWnd - Zentriert das Video in seinem Fenster void CMediaPlayerWnd::CenterMediaPlayerWnd(HWND hWnd) { RECT rcMovie; RECT rcClient, rcMovieBounds; MCI_DGV_RECT_PARMS mciRect; // Wenn noch keins geöffnet ist rausgehen if(!m_bOpened) return; // Rechteck des Parents holen ::GetClientRect(hWnd, &rcClient); // Originalgröße holen mciSendCommand(m_mciDeviceID, MCI_WHERE, (DWORD)(MCI_DGV_WHERE_SOURCE), (DWORD)(LPMCI_DGV_RECT_PARMS)&mciRect); // Kopieren CopyRect(&rcMovieBounds, &mciRect.rc); rcMovie.left = (rcClient.right/2) - (rcMovieBounds.right / 2); rcMovie.top = (rcClient.bottom/2) - (rcMovieBounds.bottom / 2); rcMovie.right = rcMovie.left + rcMovieBounds.right; rcMovie.bottom = rcMovie.top + rcMovieBounds.bottom; // Neu positionieren ::MoveWindow(m_hwnd, rcClient.left, rcClient.top, rcClient.right, rcClient.bottom, TRUE); } ////////////////////////////////////////////////////////////////////////// // Open - Mediadatei mit Datei-Öffnen Dialog öffnen void CMediaPlayerWnd::Open(HWND hWnd, LPCTSTR szFilter) { CFileDialog dlg(1, 0, 0, OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT, szFilter); // Dateinamen holen if(dlg.DoModal() == IDOK) Open(dlg.m_ofn.lpstrFile, hWnd); } ////////////////////////////////////////////////////////////////////////// // Open - Mediadatei mit angegebenem Pfad öffnen void CMediaPlayerWnd::Open(LPSTR sVPath, HWND hWnd) { MCI_DGV_OPEN_PARMS mciOpen; MCI_DGV_WINDOW_PARMS mciWindow; MCI_DGV_STATUS_PARMS mciStatus; // Altes schließen if(m_bOpened) Close(hWnd); // MCI-Parameter einstellen mciOpen.wDeviceID = 0; mciOpen.lpstrDeviceType = NULL; mciOpen.lpstrElementName = sVPath; mciOpen.lpstrAlias = NULL; mciOpen.dwStyle = WS_CHILD; mciOpen.hWndParent = hWnd; // Versuchen die Datei zu öffnen if(mciSendCommand(0, MCI_OPEN, (DWORD)(MCI_OPEN_ELEMENT|MCI_DGV_OPEN_PARENT| MCI_DGV_OPEN_WS|MCI_OVLY_WINDOW_ENABLE_STRETCH ), (DWORD)(LPMCI_DGV_OPEN_PARMS)&mciOpen) == 0) { // Abspielen m_mciDeviceID = mciOpen.wDeviceID; m_bOpened = TRUE; // Wiedergabefenster zeigen mciWindow.hWnd = NULL; mciWindow.nCmdShow = SW_SHOW; mciWindow.lpstrText = (LPSTR)NULL; mciSendCommand(m_mciDeviceID, MCI_WINDOW, MCI_DGV_WINDOW_STATE| MCI_OVLY_WINDOW_ENABLE_STRETCH, (DWORD)(LPMCI_DGV_WINDOW_PARMS)&mciWindow); // Fenster-Handle holen mciStatus.dwItem = MCI_DGV_STATUS_HWND; mciSendCommand(m_mciDeviceID, MCI_STATUS, MCI_STATUS_ITEM, (DWORD)(LPMCI_STATUS_PARMS)&mciStatus); m_hwnd = (HWND)mciStatus.dwReturn; // Zentrieren CenterMediaPlayerWnd(hWnd); } else m_bOpened = FALSE; // Nicht geöffnet // Neuzeichnen und aktualisieren ::InvalidateRect(hWnd, NULL, FALSE); ::UpdateWindow(hWnd); } ////////////////////////////////////////////////////////////////////////// // Close - Mediadatei schließen void CMediaPlayerWnd::Close(HWND hWnd) { MCI_GENERIC_PARMS mciGeneric; mciSendCommand(m_mciDeviceID, MCI_CLOSE, 0L, (DWORD)(LPMCI_GENERIC_PARMS)&mciGeneric); m_bPlaying = FALSE; m_bOpened = FALSE; // Komplett neuzeichnen ::InvalidateRect(hWnd, NULL, TRUE); ::UpdateWindow(hWnd); } ////////////////////////////////////////////////////////////////////////// // Play - Abspielen/Pause-Funktion void CMediaPlayerWnd::Play(HWND hWnd,int nDirection) { m_bPlaying = !m_bPlaying; if(!nDirection) m_bPlaying = FALSE; if(m_bPlaying) { DWORD dwFlags; MCI_DGV_PLAY_PARMS mciPlay; // Initialisieren mciPlay.dwFrom = mciPlay.dwTo = 0; dwFlags = MCI_NOTIFY; if(nDirection == MPW_RPLAY) dwFlags |= MCI_DGV_PLAY_REVERSE; // Abspielen mciSendCommand(m_mciDeviceID, MCI_PLAY, dwFlags, (DWORD)(LPMCI_DGV_PLAY_PARMS)&mciPlay); } else { MCI_DGV_PAUSE_PARMS mciPause; // Pausieren mciSendCommand(m_mciDeviceID,MCI_PAUSE,0L, (DWORD)(LPMCI_DGV_PAUSE_PARMS)&mciPause); } } ////////////////////////////////////////////////////////////////////////// // Seek - Springt an den Anfang oder an das Ende der Mediadatei void CMediaPlayerWnd::Seek(HWND hWnd, int nAction) { // Anhalten if(m_bPlaying) Play(hWnd, 0); if(nAction == MPW_HOME) // An den Anfang gehen mciSendCommand(m_mciDeviceID, MCI_SEEK, MCI_SEEK_TO_START, (DWORD)(LPVOID)NULL); else if (nAction == MPW_END) // Ans Ende gehen mciSendCommand(m_mciDeviceID, MCI_SEEK, MCI_SEEK_TO_END, (DWORD)(LPVOID)NULL); } ////////////////////////////////////////////////////////////////////////// // Step - Einen Schritt in die gewünschte Richtung machen void CMediaPlayerWnd::Step(HWND hWnd, int nDirection) { MCI_DGV_STEP_PARMS mciStep; // Anhalten if(m_bPlaying) Play(hWnd, 0); mciStep.dwFrames = 1L; if(nDirection == MPW_STEP) // Nach vorne mciSendCommand(m_mciDeviceID, MCI_STEP, MCI_DGV_STEP_FRAMES,(DWORD)(LPMCI_DGV_STEP_PARMS)&mciStep); else // Nach hinten mciSendCommand(m_mciDeviceID, MCI_STEP, MCI_DGV_STEP_FRAMES|MCI_DGV_STEP_REVERSE, (DWORD)(LPMCI_DGV_STEP_PARMS)&mciStep); }
Den Style finde ich nicht so gut. Ich würde mir was neues daraus bauen...
-
Es gibt dazu ein nehe tut (nehe.gamedev.net)! Musste mal suchen
-
Ich habe mal davon gehört, dass eine eine mpeg-ZusatzLib für SDL gibt.
Sonst wäre vielleicht libmpeg3 (für Win und Lin) + OpenGL ein Blick wert.[ Dieser Beitrag wurde am 03.06.2003 um 15:07 Uhr von Kane editiert. ]
-
danke schonmal für die vielen antworten. wenn es nach mir ginge würde ich das ja auch mit cg und opengl machen. ich soll ja filter bauen.
aber die wollen reine softwarefilter haben. nuja..
http://us.dl.sourceforge.net/sourceforge/amiga/smpeg-0.4.4.lhadie hier passt wohl ganz gut. das ist übrigens die sdl-mpeg-zusatz-dings. werd mich da mal durchfitzeln. ansonsten wäre es mit noch sehr hilfreich, wenn jemand eine kleines prog mit source hat, wo ein video durchgeschliffen wird, bei dem man vielleicht im sourcecode einfache rgb-werte verändern kann. da könnte ich wohl viel von lernen. oder einfach ein tutorial, bei dem so ein vorgang gut beschrieben wird. achso, die projektgruppe hat sich auf linux geeinigt.
naja, danke schonmal
[ Dieser Beitrag wurde am 03.06.2003 um 18:12 Uhr von Strahlemann1 editiert. ]