Video in visual c++

how do i play video

Page 1 of 1

13 Replies - 22786 Views - Last Post: 28 January 2006 - 11:07 AM Rate Topic: -----

#1 c++ video  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 26-January 06

Video in visual c++

Posted 26 January 2006 - 05:29 AM

hey everyone. im not great at c++ programming only started recently.
im looking to just have an application play a video file. been working in visual c++ 6. have tryed and read a load of tutorials but am clueless its really driving me mad. can anyone give me a hand or even a point in the right direction. would be great thanks. :D

Is This A Good Question/Topic? 0
  • +

Replies To: Video in visual c++

#2 Amadeus  Icon User is offline

  • g+ + -o drink whiskey.cpp
  • member icon

Reputation: 248
  • View blog
  • Posts: 13,506
  • Joined: 12-July 02

Re: Video in visual c++

Posted 26 January 2006 - 07:11 AM

Are you looking to have your application play a video in the application itself (i.e will you be responsible for handling the video input)? Or do you simply want your application to launch an appropriate video player to display the content?
Was This Post Helpful? 0
  • +
  • -

#3 Voodoo Doll  Icon User is offline

  • D.I.C Head
  • member icon

Reputation: 12
  • View blog
  • Posts: 108
  • Joined: 24-January 06

Re: Video in visual c++

Posted 26 January 2006 - 07:57 AM

I'm not well versed in such things, but because I want to be helpful, I asked a friend. He said that it gets complicated if you want to be a do-it-yourselfer and recommended MCI as a part of the Win32 multimedia library.

But I say, why bother? It's much easier to defer to an existing program to do the dirty work for you so you can enjoy the results. :)
#include <iostream>
#include <string>
#include <cstdlib>

int main(int argc, char *argv[])
{
  if (argc > 1) {
    std::cout << "Playing the file: " << argv[1] << '\n';
    std::string command = "\"C:/Program Files/Windows Media Player/wmplayer.exe\" ";
    std::system((command + argv[1]).c_str());
  }
  else
    std::cerr << "usage: musicplayer \"media file\"\n";
}


Was This Post Helpful? 0
  • +
  • -

#4 Amadeus  Icon User is offline

  • g+ + -o drink whiskey.cpp
  • member icon

Reputation: 248
  • View blog
  • Posts: 13,506
  • Joined: 12-July 02

Re: Video in visual c++

Posted 26 January 2006 - 08:02 AM

I'd suggest that as a preferred course of action as well, but it does infer that the application designer is aware of what multi media players are available (and where) on the client machine (error checking in example provided noted). In such a case, there should be a check of available software. Of course, the designer could package a multi media player with the application, but only if it were freely distributed (or written by the designer, which would defeat the purpose of using an existing one in the first place!) :)
Was This Post Helpful? 0
  • +
  • -

#5 Voodoo Doll  Icon User is offline

  • D.I.C Head
  • member icon

Reputation: 12
  • View blog
  • Posts: 108
  • Joined: 24-January 06

Re: Video in visual c++

Posted 26 January 2006 - 08:38 AM

Quote

but it does infer that the application designer is aware of what multi media players are available (and where) on the client machine

Windows Media Player is built into the system and can't be removed, so the only real issue would be whether or not it's stored in the same directory path for various versions of Windows. I'm also reasonably sure that there's a default environment variable that lets you use the 'wmplayer' command unadorned for that kind of situation. But both of those statements are toeing the realm of 'I dunno for sure, but it makes sense', so take it with a grain of salt. :)
Was This Post Helpful? 0
  • +
  • -

#6 Amadeus  Icon User is offline

  • g+ + -o drink whiskey.cpp
  • member icon

Reputation: 248
  • View blog
  • Posts: 13,506
  • Joined: 12-July 02

Re: Video in visual c++

Posted 26 January 2006 - 08:56 AM

You are correct, on both counts , but that further implies that the windows OS is the only one the designer is concerned about. I realize that the use of VS makes it probable that the designer is concerned about Windows only, but I did not want to make an assumption.
Was This Post Helpful? 0
  • +
  • -

#7 Voodoo Doll  Icon User is offline

  • D.I.C Head
  • member icon

Reputation: 12
  • View blog
  • Posts: 108
  • Joined: 24-January 06

Re: Video in visual c++

Posted 26 January 2006 - 10:24 AM

Quote

I realize that the use of VS makes it probable that the designer is concerned about Windows only, but I did not want to make an assumption.

I know about portable graphics libraries like SDL and Qt, but are there portable sound and video libraries? I'm not sure, since I don't really have much experience in that direction. :) Portability is nice when you can get it, but when it comes down to system and hardware dependent functions like playing sound and video, I'm told that it's usually easier to just write multiple versions using system libraries and stuff. Especially if you want the stability and performance benefits of the built-in API's.

As I understand it, and feel free to correct me if I'm wrong because I don't do this stuff much, in X-Windows you use the X interface, and in Microsoft Windows you use Win32 or .NET, and the two are just too different to make attempts at portability worth the effort. If you use a portable library like Qt or a portable platform like Java, you suffer performance hits because of the extra layer(s) of abstraction.

I kind of lost my point through all of that. :D I think in this case it's a safe assumption that the program will be strictly Windows based or have multiple incarnations for the systems that it's ported to.
Was This Post Helpful? 0
  • +
  • -

#8 Amadeus  Icon User is offline

  • g+ + -o drink whiskey.cpp
  • member icon

Reputation: 248
  • View blog
  • Posts: 13,506
  • Joined: 12-July 02

Re: Video in visual c++

Posted 26 January 2006 - 10:34 AM

To be honest, my own experience with programming for video is limited, so I can't speak to portable libraries with any certainty...not really my area of expertise. It is easier overall to write multiple versions of software than try to achive true portability, but I always espouse true portability as a laudable goal...I'm not sure that we'll see it in my working lifetime, but I strive towards it with everything I write (of course, I'm mostly repsonsible for web applications and network applications, so it's a little easier without components like video).

I certainly agree that it is likely safe to assume a windows specific application...I just wanted to bring visibility to possible solutions with a wider scope, even if they are not feasible solutions from an implementation viewpoint at this time.

Wouldn't be as much fun without presenting an option to complicate an application! :)
Was This Post Helpful? 0
  • +
  • -

#9 1lacca  Icon User is offline

  • code.rascal
  • member icon

Reputation: 44
  • View blog
  • Posts: 3,822
  • Joined: 11-August 05

Re: Video in visual c++

Posted 26 January 2006 - 03:14 PM

Voodoo Doll, on 26 Jan, 2006 - 09:35 AM, said:

Windows Media Player is built into the system and can't be removed, so the only real issue would be whether or not it's stored in the same directory path for various versions of Windows.

Well, it is removable - and a lot more things, too that doesn't look-like that at first glance- , the EU has just ordered MS to release a crippled Windows version, that lacks the WMP. And it is available. And the fun part: you can download WMP onto it, it costs the same as the "full" version and surprise: not much have been sold yet. Although I can imagine Stalinistic sysadmins rubbing their hands with envy for the next OS purchase...

Portable video APIs: Flash is available for most platforms, but I'm not sure if it has a c++ api, however it should as browsers communicate with it somehow.
And doing the whole thing crossplatform: take a look at some opensource media players like VLC, however I'm not sure how they do it :(

Looking at the first post, I think the use of Visual C++ 6 however implies that it is a Windows project, but I won't give up so easily, here is a tutorial
by NEHE: playing back AVI files with OpenGL. VC++6, and Linux source are available - among others.
Was This Post Helpful? 0
  • +
  • -

#10 Voodoo Doll  Icon User is offline

  • D.I.C Head
  • member icon

Reputation: 12
  • View blog
  • Posts: 108
  • Joined: 24-January 06

Re: Video in visual c++

Posted 26 January 2006 - 03:56 PM

Thanks 1lacca, that's good to know. By the way, how can Media Player be removed? I know you can Add/Remove Components deep in the Control Panel, but I was led to believe that it only removes links so that it's unusable by users rather than banishing it from the system entirely.

Quote

And doing the whole thing crossplatform: take a look at some opensource media players like VLC, however I'm not sure how they do it

It can be done, but the result is usually slower unless you make the code longer by conditionally compiling platform specific pieces or have separate builds for each platform. To do it without preprocessor tricks or separate builds, you end up adding at least one level of abstraction to hide away the system stuff that needs to be done. That's what Java does, it's a system overlay that does its own system-like things so you don't have to. :)
Was This Post Helpful? 0
  • +
  • -

#11 1lacca  Icon User is offline

  • code.rascal
  • member icon

Reputation: 44
  • View blog
  • Posts: 3,822
  • Joined: 11-August 05

Re: Video in visual c++

Posted 26 January 2006 - 05:20 PM

I think XPlite removes not just links, as the footprint of your installation is reduced during operation, altough one can never know. There are other hacks: you can even make a Windows XP without Explorer and active desktop that still runs fine everything, and becomes even faster and more reliable - although some apps, like Norton bloatware things and others that rely on Explorer won't function anymore - your choice. These are not too hard to come across, just search on google, I've tried some myself but never took the time to bookmark them - however I do stop services I don't need, like themes and things like that...

On the cross-platform things you are completely right both about the idea of how to make an application cross-platform, and about the performance issues. In my post I was thinking about the actual techincal implementation that VLC uses - generating a rendering surface, and getting the audio/video codec to work, etc - but got a little sloppy...
Was This Post Helpful? 0
  • +
  • -

#12 c++ video  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 26-January 06

Re: Video in visual c++

Posted 27 January 2006 - 05:59 AM

hey again everyone. thanks for the interset. what im looking to do is really design and control the video. at the min all im really looking to get is for a small application in which i can load a video play stop etc. if i can get that to work would be a big start. have played around with some downloads that are nice tho im kinda hoping to make my own version. if i can get that to work i hope to add a process button that will run image processing algorithims on the video.
Was This Post Helpful? 0
  • +
  • -

#13 1lacca  Icon User is offline

  • code.rascal
  • member icon

Reputation: 44
  • View blog
  • Posts: 3,822
  • Joined: 11-August 05

Re: Video in visual c++

Posted 27 January 2006 - 06:06 AM

And what platform/OS are you targeting?
Was This Post Helpful? 0
  • +
  • -

#14 1lacca  Icon User is offline

  • code.rascal
  • member icon

Reputation: 44
  • View blog
  • Posts: 3,822
  • Joined: 11-August 05

Re: Video in visual c++

Posted 28 January 2006 - 11:07 AM

Just read back the comments, and found an open question: a portable sound library is OpenAL, its name might suggest it is for games, but just like OpenGL it has many professional uses in other fields, too. I am sure there are more, just check google or sourceforge.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1