-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathREADME
168 lines (147 loc) · 5.81 KB
/
README
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
Building FFMPEG on Linux for Windows using MinGW
------------------------------------------------
On an ubuntu 64 bit machine (make sure it is natty so that all dependencies are present)
#!/bin/bash
sudo apt-get install subversion yasm bison flex libgmp3-dev libmpfr-dev libmpc-dev \
texinfo gcc-4.5-source binutils-source
mkdir src
cd src
tar xvJf /usr/src/binutils/binutils-2.20.51.tar.xz
mv binutils* binutils
tar xvJf /usr/src/gcc-4.5/gcc-4.5.1.tar.xz
mv gcc* gcc
svn co https://mingw-w64.svn.sourceforge.net/svnroot/mingw-w64/trunk mingw
svn co svn://svn.ffmpeg.org/ffmpeg/trunk ffmpeg
cd ..
mkdir build
cd build
mkdir binutils
mkdir gcc
mkdir mingw-headers
mkdir mingw-crt
mkdir ffmpeg
cd binutils
../../src/binutils/configure --target=x86_64-w64-mingw32 --disable-multilib
make
sudo make install
cd ../mingw-headers
../../src/mingw/mingw-w64-headers/configure --host=x86_64-w64-mingw32
make
sudo make install
sudo ln -s /usr/local/x86_64-w64-mingw32 /usr/local/mingw
sudo mkdir -p /usr/local/x86_64-w64-mingw32/lib
sudo ln -s /usr/local/x86_64-w64-mingw32/lib /usr/local/x86_64-w64-mingw32/lib64
cd ../gcc
../../src/gcc/configure --target=x86_64-w64-mingw32 --disable-multilib
make all-gcc
sudo make install-gcc
cd ../mingw-crt
../../src/mingw/mingw-w64-crt/configure --host=x86_64-w64-mingw32
make
sudo make install
cd ../gcc
make
sudo make install
cd ../ffmpeg
../../src/ffmpeg/configure --disable-dxva2 --cross-prefix=x86_64-w64-mingw32- \
--extra-cflags='-Dstrtod=__strtod' --arch=x86_64 --target-os=mingw32
make
Copying Over and building a Metro project out of FFMPEG 64 bit build.
--------------------------------------------------------------------
1. In the Win8 Developer preview, build a new Metro component dll WinApp and project named FFMpeg in directory <Base>\source. Make sure in Configuration manager that the target platform is x64.
2. Copy over the ffmpeg source (src/ffmpeg) from the linux machine as ffmpeg_src into <Base>\source\WinApp\FFMpeg
3. Copy over the ffmpeg build (build/ffmpeg) directory from the linux machine as ffmpeg_build into <Base>\source\WinApp\FFMpeg
3.5. Copy over the following libraries from the linux build into the project
build/gcc/gcc/libgcc.a -> <Base>\source\WinApp\FFMpeg\ffmpeg_build
build/mingw-crt/lib64/libmingw32.a -> <Base>\source\WinApp\FFMpeg\ffmpeg_build
build/mingw-crt/lib64/libmingwex.a -> <Base>\source\WinApp\FFMpeg\ffmpeg_build
build/mingw-crt/lib64/libwsock32.a -> <Base>\source\WinApp\FFMpeg\ffmpeg_build
4. Add the following into FFMpeg project's linker input directories (Properties -> Conf Properties -> VC++ directories -> Library Directories:
C:\Users\pankajk81\source\WinApp\FFMpeg\ffmpeg_build\libavcore;
C:\Users\pankajk81\source\WinApp\FFMpeg\ffmpeg_build\libavdevice;
C:\Users\pankajk81\source\WinApp\FFMpeg\ffmpeg_build\libavcodec;
C:\Users\pankajk81\source\WinApp\FFMpeg\ffmpeg_build\libavfilter;
C:\Users\pankajk81\source\WinApp\FFMpeg\ffmpeg_build\libswscale;
C:\Users\pankajk81\source\WinApp\FFMpeg\ffmpeg_build\libpostproc;
C:\Users\pankajk81\source\WinApp\FFMpeg\ffmpeg_build\libavutil;
C:\Users\pankajk81\source\WinApp\FFMpeg\ffmpeg_build\libavformat;
C:\Users\pankajk81\source\WinApp\FFMpeg\ffmpeg_build\;$(LibraryPath)
5. Add the following to the FFMpeg project's include directories (Properties -> Configuration Properties->VC++ directories -> Include Directories:
C:\Users\pankajk81\source\WinApp\FFMpeg\ffmpeg_build;
C:\Users\pankajk81\source\WinApp\FFMpeg\ffmpeg_src;
C:\Users\pankajk81\source\WinApp\FFMpeg\ffmpeg_src\libavutil;
C:\Users\pankajk81\source\WinApp\FFMpeg\ffmpeg_src\libavcore;
C:\Users\pankajk81\source\WinApp\FFMpeg\ffmpeg_src\libavformat;
C:\Users\pankajk81\source\WinApp\FFMpeg\ffmpeg_src\libavcodec;$(IncludePath)
6.
Include the following libraries in the FFMPeg project (Properties->Configuration Properties->Linker->Input->Additional Deps) :
libavcore.a
libavcodec.a
libavformat.a
libavdevice.a
libgcc.a
libwsock32.a
libavfilter.a
libavutil.a
libswscale.a
libmingwex.a
7. Replace the contents of WinRTComponent.h with the following code that accesses ffmpeg routines.
<code>
#pragma once
using namespace Windows::Foundation;
#ifndef __STDC_CONSTANT_MACROS
# define __STDC_CONSTANT_MACROS
#endif
extern "C" {
#include <avcodec.h>
#include <avformat.h>
}
namespace FFMpeg
{
// Activatable class.
public ref class LangSample sealed
{
public:
LangSample()
{
av_register_all();
AVFormatContext *pFormatCtx;
//open video file
if (av_open_input_file(&pFormatCtx, "C:\\test\\centaur_1.mpeg", NULL, 0, NULL) != 0)
return ;
// Retrieve stream information
if(av_find_stream_info(pFormatCtx)<0)
return ; // Couldn't find stream information
}
int testMePlease()
{
return 0;
}
};
}
// WinRTComponent.h
</code>
7. Remove all function definitions from WinRTComponent.cpp
Replace the content with the following:
<code>
// WinRTComponent.cpp
#include "pch.h"
#include "WinRTComponent.h"
using namespace FFMpeg;
extern "C" int mingw_app_type = 0;
extern "C" void __mingw_raise_matherr (int typ, const char *name, double a1, double a2,
double rslt)
{
}
typedef int HMODULE;
extern "C" HMODULE __mingw_get_msvcrt_handle(void)
{
return 0;
}
This introduces these three symbols that are defined in libmingw32.a but including libmingw32.a leads to other symbol errors. These two functions never seem to be called though.
Make a new CS App project
-------------------------
1. Make a new CS app project called WinApp (inside the WinApp folder and in the WinApp Solution)
2. Make sure that the configuration manager compiles it in x64 and set it as the startup project
3. Add a reference to C:\Users\pankajk81\source\WinApp\Debug\FFMpeg\FFMpeg.winmd
4. In App.xaml.cs , add a "using FFMpeg" declaration and call the "LangSample ls = new LangSample()" in the App() constructor.