Skip to content

Commit c998bac

Browse files
committed
added filter example
1 parent d4e9715 commit c998bac

File tree

5 files changed

+36
-26
lines changed

5 files changed

+36
-26
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
/source/ffmpeg-cpp/encode_audio/obj
1919
/source/ffmpeg-cpp/encode_video/obj
2020
/source/ffmpeg-cpp/decode_video/obj
21-
/source/ffmpeg-cpp/filter_video/obj
21+
/source/ffmpeg-cpp/filtering_video/obj
2222
/include
2323

2424
/source/ffmpeg-cpp/remuxing/obj

source/ffmpeg-cpp/encode_video/encode_video.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ int main()
1414
// Create a muxer that will output the video as MKV.
1515
Muxer* muxer = new Muxer("output.mpg");
1616

17-
// Create a MP3 codec that will encode the raw data.
17+
// Create a MPEG2 codec that will encode the raw data.
1818
VideoCodec* codec = new VideoCodec("mpeg2video");
1919

2020
// Set the global quality of the video encoding. This maps to the command line

source/ffmpeg-cpp/filtering_video/filtering_video.cpp

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -14,43 +14,42 @@ int main()
1414
// Create a muxer that will output the video as MKV.
1515
Muxer* muxer = new Muxer("filtered_video.mp4");
1616

17-
// Create a MP3 codec that will encode the raw data.
17+
// Create a MPEG2 codec that will encode the raw data.
1818
VideoCodec* codec = new VideoCodec(AV_CODEC_ID_MPEG2VIDEO);
19-
codec->SetOption("preset", "default");
20-
//VideoCodec* codec = new H264NVEncCodec();
19+
20+
// Set the global quality of the video encoding. This maps to the command line
21+
// parameter -qscale and must be within range [0,31].
22+
codec->SetQualityScale(0);
2123

2224
// Create an encoder that will encode the raw audio data as MP3.
2325
// Tie it to the muxer so it will be written to the file.
2426
VideoEncoder* encoder = new VideoEncoder(codec, muxer);
2527

26-
// Load the raw video file so we can process it.
27-
// FFmpeg is very good at deducing the file format, even from raw video files,
28-
// but if we have something weird, we can specify the properties of the format
29-
// in the constructor as commented out below.
30-
RawVideoFileSource* videoFile = new RawVideoFileSource("samples/carphone_qcif.y4m", encoder);
28+
// Create a video filter and do some funny stuff with the video data.
29+
VideoFilter* filter = new VideoFilter("scale=640:150,transpose=cclock,vignette", encoder);
30+
31+
// Load a video from a container and send it to the filter first.
32+
Demuxer* demuxer = new Demuxer("samples/big_buck_bunny.mp4");
33+
demuxer->DecodeBestVideoStream(filter);
3134

3235
// Prepare the output pipeline. This will push a small amount of frames to the file sink until it IsPrimed returns true.
33-
videoFile->PreparePipeline();
36+
demuxer->PreparePipeline();
3437

3538
// Push all the remaining frames through.
36-
while (!videoFile->IsDone())
39+
while (!demuxer->IsDone())
3740
{
38-
videoFile->Step();
41+
demuxer->Step();
3942
}
4043

4144
// Save everything to disk by closing the muxer.
4245
muxer->Close();
4346
}
44-
catch (const char* bla)
45-
{
46-
47-
}
48-
/*catch (FFmpegException e)
47+
catch (FFmpegException e)
4948
{
5049
cerr << "Exception caught!" << endl;
5150
cerr << e.what() << endl;
5251
throw e;
53-
}*/
52+
}
5453

5554
cout << "Encoding complete!" << endl;
5655
cout << "Press any key to continue..." << endl;
Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,19 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3-
<PropertyGroup />
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>
419
</Project>

source/ffmpeg-cpp/remuxing/remuxing.cpp

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -56,16 +56,12 @@ int main()
5656
// Save everything to disk by closing the muxer.
5757
muxer->Close();
5858
}
59-
catch (const char* bla)
60-
{
61-
62-
}
63-
/*catch (FFmpegException e)
59+
catch (FFmpegException e)
6460
{
6561
cerr << "Exception caught!" << endl;
6662
cerr << e.what() << endl;
6763
throw e;
68-
}*/
64+
}
6965

7066
cout << "Encoding complete!" << endl;
7167
cout << "Press any key to continue..." << endl;

0 commit comments

Comments
 (0)