Skip to content

Commit 6389f60

Browse files
committed
added remuxing example
1 parent 11fe395 commit 6389f60

File tree

5 files changed

+315
-0
lines changed

5 files changed

+315
-0
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,4 @@
2121
/source/ffmpeg-cpp/filter_video/obj
2222
/include
2323

24+
/source/ffmpeg-cpp/remuxing/obj
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
2+
#include <iostream>
3+
4+
#include "ffmpegcpp.h"
5+
6+
using namespace std;
7+
using namespace ffmpegcpp;
8+
9+
10+
int main()
11+
{
12+
// This example will take a raw audio file and encode it into as MP3.
13+
try
14+
{
15+
// Create a muxer that will output the video as MKV.
16+
Muxer* muxer = new Muxer("output.mkv");
17+
18+
// Create a codec that will encode video as VP9
19+
VP9Codec* videoCodec = new VP9Codec();
20+
21+
// Configure the codec to not do compression, to use multiple CPU's and to go as fast as possible.
22+
videoCodec->SetLossless(true);
23+
videoCodec->SetCpuUsed(5);
24+
videoCodec->SetDeadline("realtime");
25+
26+
// Create a codec that will encode audio as AAC
27+
AudioCodec* audioCodec = new AudioCodec(AV_CODEC_ID_AAC);
28+
29+
// Create encoders for both
30+
VideoEncoder* videoEncoder = new VideoEncoder(videoCodec, muxer);
31+
AudioEncoder* audioEncoder = new AudioEncoder(audioCodec, muxer);
32+
33+
// Load both audio and video from a container
34+
Demuxer* videoContainer = new Demuxer("samples/big_buck_bunny.mp4");
35+
Demuxer* audioContainer = new Demuxer("samples/DesiJourney.wav");
36+
37+
// Tie the best stream from each container to the output
38+
videoContainer->DecodeBestVideoStream(videoEncoder);
39+
audioContainer->DecodeBestAudioStream(audioEncoder);
40+
41+
42+
videoContainer->PreparePipeline();
43+
audioContainer->PreparePipeline();
44+
45+
/*while (!videoContainer->IsDone())
46+
{
47+
videoContainer->Step();
48+
}*/
49+
50+
// Pump the audio and video fully through.
51+
// To avoid big buffers, we interleave these calls so that the container
52+
// can be written to disk efficiently.
53+
while (!videoContainer->IsDone() || !audioContainer->IsDone())
54+
{
55+
if (!videoContainer->IsDone()) videoContainer->Step();
56+
if (!audioContainer->IsDone()) audioContainer->Step();
57+
}
58+
59+
// Save everything to disk by closing the muxer.
60+
muxer->Close();
61+
}
62+
catch (const char* bla)
63+
{
64+
65+
}
66+
/*catch (FFmpegException e)
67+
{
68+
cerr << "Exception caught!" << endl;
69+
cerr << e.what() << endl;
70+
throw e;
71+
}*/
72+
73+
cout << "Encoding complete!" << endl;
74+
cout << "Press any key to continue..." << endl;
75+
76+
getchar();
77+
}
Lines changed: 200 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,200 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<ItemGroup Label="ProjectConfigurations">
4+
<ProjectConfiguration Include="Debug|Win32">
5+
<Configuration>Debug</Configuration>
6+
<Platform>Win32</Platform>
7+
</ProjectConfiguration>
8+
<ProjectConfiguration Include="Release|Win32">
9+
<Configuration>Release</Configuration>
10+
<Platform>Win32</Platform>
11+
</ProjectConfiguration>
12+
<ProjectConfiguration Include="Debug|x64">
13+
<Configuration>Debug</Configuration>
14+
<Platform>x64</Platform>
15+
</ProjectConfiguration>
16+
<ProjectConfiguration Include="Release|x64">
17+
<Configuration>Release</Configuration>
18+
<Platform>x64</Platform>
19+
</ProjectConfiguration>
20+
</ItemGroup>
21+
<PropertyGroup Label="Globals">
22+
<VCProjectVersion>15.0</VCProjectVersion>
23+
<ProjectGuid>{B337D322-355B-4348-A2A8-270471BE2C95}</ProjectGuid>
24+
<Keyword>Win32Proj</Keyword>
25+
<RootNamespace>decodeaudio</RootNamespace>
26+
<WindowsTargetPlatformVersion>10.0.17763.0</WindowsTargetPlatformVersion>
27+
</PropertyGroup>
28+
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
29+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
30+
<ConfigurationType>Application</ConfigurationType>
31+
<UseDebugLibraries>true</UseDebugLibraries>
32+
<PlatformToolset>v141</PlatformToolset>
33+
<CharacterSet>Unicode</CharacterSet>
34+
</PropertyGroup>
35+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
36+
<ConfigurationType>Application</ConfigurationType>
37+
<UseDebugLibraries>false</UseDebugLibraries>
38+
<PlatformToolset>v141</PlatformToolset>
39+
<WholeProgramOptimization>true</WholeProgramOptimization>
40+
<CharacterSet>Unicode</CharacterSet>
41+
</PropertyGroup>
42+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
43+
<ConfigurationType>Application</ConfigurationType>
44+
<UseDebugLibraries>true</UseDebugLibraries>
45+
<PlatformToolset>v141</PlatformToolset>
46+
<CharacterSet>Unicode</CharacterSet>
47+
</PropertyGroup>
48+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
49+
<ConfigurationType>Application</ConfigurationType>
50+
<UseDebugLibraries>false</UseDebugLibraries>
51+
<PlatformToolset>v141</PlatformToolset>
52+
<WholeProgramOptimization>true</WholeProgramOptimization>
53+
<CharacterSet>Unicode</CharacterSet>
54+
</PropertyGroup>
55+
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
56+
<ImportGroup Label="ExtensionSettings">
57+
</ImportGroup>
58+
<ImportGroup Label="Shared">
59+
</ImportGroup>
60+
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
61+
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
62+
<Import Project="..\FFmpegLibraryLocationProperty.props" />
63+
</ImportGroup>
64+
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
65+
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
66+
<Import Project="..\FFmpegLibraryLocationProperty.props" />
67+
</ImportGroup>
68+
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
69+
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
70+
<Import Project="..\FFmpegLibraryLocationProperty.props" />
71+
</ImportGroup>
72+
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
73+
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
74+
<Import Project="..\FFmpegLibraryLocationProperty.props" />
75+
</ImportGroup>
76+
<PropertyGroup Label="UserMacros" />
77+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
78+
<LinkIncremental>true</LinkIncremental>
79+
<OutDir>$(ProjectDir)..\..\..\bin\$(Platform)\$(Configuration)\</OutDir>
80+
<IntDir>obj\$(Platform)\$(Configuration)\</IntDir>
81+
</PropertyGroup>
82+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
83+
<LinkIncremental>true</LinkIncremental>
84+
<OutDir>$(ProjectDir)..\..\..\bin\$(Platform)\$(Configuration)\</OutDir>
85+
<IntDir>obj\$(Platform)\$(Configuration)\</IntDir>
86+
</PropertyGroup>
87+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
88+
<LinkIncremental>false</LinkIncremental>
89+
<OutDir>$(ProjectDir)..\..\..\bin\$(Platform)\$(Configuration)\</OutDir>
90+
<IntDir>obj\$(Platform)\$(Configuration)\</IntDir>
91+
</PropertyGroup>
92+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
93+
<LinkIncremental>false</LinkIncremental>
94+
<OutDir>$(ProjectDir)..\..\..\bin\$(Platform)\$(Configuration)\</OutDir>
95+
<IntDir>obj\$(Platform)\$(Configuration)\</IntDir>
96+
</PropertyGroup>
97+
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
98+
<ClCompile>
99+
<PrecompiledHeader>NotUsing</PrecompiledHeader>
100+
<WarningLevel>Level3</WarningLevel>
101+
<Optimization>Disabled</Optimization>
102+
<SDLCheck>false</SDLCheck>
103+
<PreprocessorDefinitions>_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
104+
<ConformanceMode>true</ConformanceMode>
105+
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
106+
<AdditionalIncludeDirectories>$(FFmpegLibraryDir)include;..\ffmpeg-cpp;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
107+
</ClCompile>
108+
<Link>
109+
<SubSystem>Console</SubSystem>
110+
<GenerateDebugInformation>true</GenerateDebugInformation>
111+
<AdditionalDependencies>%(AdditionalDependencies)</AdditionalDependencies>
112+
</Link>
113+
<PostBuildEvent>
114+
<Command>xcopy $(SamplesDir) $(OutDir)samples /s /y /i
115+
xcopy $(FFmpegLibraryDir)bin $(OutDir) /s /y /i</Command>
116+
</PostBuildEvent>
117+
</ItemDefinitionGroup>
118+
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
119+
<ClCompile>
120+
<PrecompiledHeader>NotUsing</PrecompiledHeader>
121+
<WarningLevel>Level3</WarningLevel>
122+
<Optimization>Disabled</Optimization>
123+
<SDLCheck>true</SDLCheck>
124+
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
125+
<ConformanceMode>true</ConformanceMode>
126+
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
127+
<AdditionalIncludeDirectories>$(FFmpegLibraryDir)include;..\ffmpeg-cpp;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
128+
</ClCompile>
129+
<Link>
130+
<SubSystem>Console</SubSystem>
131+
<GenerateDebugInformation>true</GenerateDebugInformation>
132+
<AdditionalDependencies>%(AdditionalDependencies)</AdditionalDependencies>
133+
</Link>
134+
<PostBuildEvent>
135+
<Command>xcopy $(SamplesDir) $(OutDir)samples /s /y /i
136+
xcopy $(FFmpegLibraryDir)bin $(OutDir) /s /y /i</Command>
137+
</PostBuildEvent>
138+
</ItemDefinitionGroup>
139+
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
140+
<ClCompile>
141+
<PrecompiledHeader>NotUsing</PrecompiledHeader>
142+
<WarningLevel>Level3</WarningLevel>
143+
<Optimization>MaxSpeed</Optimization>
144+
<FunctionLevelLinking>true</FunctionLevelLinking>
145+
<IntrinsicFunctions>true</IntrinsicFunctions>
146+
<SDLCheck>true</SDLCheck>
147+
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
148+
<ConformanceMode>true</ConformanceMode>
149+
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
150+
<AdditionalIncludeDirectories>$(FFmpegLibraryDir)include;..\ffmpeg-cpp;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
151+
</ClCompile>
152+
<Link>
153+
<SubSystem>Console</SubSystem>
154+
<EnableCOMDATFolding>true</EnableCOMDATFolding>
155+
<OptimizeReferences>true</OptimizeReferences>
156+
<GenerateDebugInformation>true</GenerateDebugInformation>
157+
<AdditionalDependencies>%(AdditionalDependencies)</AdditionalDependencies>
158+
</Link>
159+
<PostBuildEvent>
160+
<Command>xcopy $(SamplesDir) $(OutDir)samples /s /y /i
161+
xcopy $(FFmpegLibraryDir)bin $(OutDir) /s /y /i</Command>
162+
</PostBuildEvent>
163+
</ItemDefinitionGroup>
164+
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
165+
<ClCompile>
166+
<PrecompiledHeader>NotUsing</PrecompiledHeader>
167+
<WarningLevel>Level3</WarningLevel>
168+
<Optimization>MaxSpeed</Optimization>
169+
<FunctionLevelLinking>true</FunctionLevelLinking>
170+
<IntrinsicFunctions>true</IntrinsicFunctions>
171+
<SDLCheck>true</SDLCheck>
172+
<PreprocessorDefinitions>NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
173+
<ConformanceMode>true</ConformanceMode>
174+
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
175+
<AdditionalIncludeDirectories>$(FFmpegLibraryDir)include;..\ffmpeg-cpp;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
176+
</ClCompile>
177+
<Link>
178+
<SubSystem>Console</SubSystem>
179+
<EnableCOMDATFolding>true</EnableCOMDATFolding>
180+
<OptimizeReferences>true</OptimizeReferences>
181+
<GenerateDebugInformation>true</GenerateDebugInformation>
182+
<AdditionalDependencies>%(AdditionalDependencies)</AdditionalDependencies>
183+
</Link>
184+
<PostBuildEvent>
185+
<Command>xcopy $(SamplesDir) $(OutDir)samples /s /y /i
186+
xcopy $(FFmpegLibraryDir)bin $(OutDir) /s /y /i</Command>
187+
</PostBuildEvent>
188+
</ItemDefinitionGroup>
189+
<ItemGroup>
190+
<ProjectReference Include="..\ffmpeg-cpp\ffmpeg-cpp.vcxproj">
191+
<Project>{babfd64d-9bf1-4328-b977-24bf81800620}</Project>
192+
</ProjectReference>
193+
</ItemGroup>
194+
<ItemGroup>
195+
<ClCompile Include="remuxing.cpp" />
196+
</ItemGroup>
197+
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
198+
<ImportGroup Label="ExtensionTargets">
199+
</ImportGroup>
200+
</Project>
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<ItemGroup>
4+
<Filter Include="Source Files">
5+
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
6+
<Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
7+
</Filter>
8+
<Filter Include="Resource Files">
9+
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
10+
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
11+
</Filter>
12+
</ItemGroup>
13+
<ItemGroup>
14+
<ClCompile Include="remuxing.cpp">
15+
<Filter>Source Files</Filter>
16+
</ClCompile>
17+
</ItemGroup>
18+
</Project>
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
4+
<LocalDebuggerWorkingDirectory>$(OutDir)</LocalDebuggerWorkingDirectory>
5+
<DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor>
6+
</PropertyGroup>
7+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
8+
<LocalDebuggerWorkingDirectory>$(OutDir)</LocalDebuggerWorkingDirectory>
9+
<DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor>
10+
</PropertyGroup>
11+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
12+
<LocalDebuggerWorkingDirectory>$(OutDir)</LocalDebuggerWorkingDirectory>
13+
<DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor>
14+
</PropertyGroup>
15+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
16+
<LocalDebuggerWorkingDirectory>$(OutDir)</LocalDebuggerWorkingDirectory>
17+
<DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor>
18+
</PropertyGroup>
19+
</Project>

0 commit comments

Comments
 (0)