@@ -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;
0 commit comments