[FFmpeg-cvslog] examples/decoding_encoding.c: test mpeg1 and h264

Michael Niedermayer git at videolan.org
Mon Oct 17 20:59:34 CEST 2011


ffmpeg | branch: master | Michael Niedermayer <michaelni at gmx.at> | Mon Oct 17 20:36:03 2011 +0200| [107460c1e9b6a0c348b35f105cc89ef2ac5edc79] | committer: Michael Niedermayer

examples/decoding_encoding.c: test mpeg1 and h264

Signed-off-by: Michael Niedermayer <michaelni at gmx.at>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=107460c1e9b6a0c348b35f105cc89ef2ac5edc79
---

 doc/examples/decoding_encoding.c |   12 +++++++-----
 1 files changed, 7 insertions(+), 5 deletions(-)

diff --git a/doc/examples/decoding_encoding.c b/doc/examples/decoding_encoding.c
index debf591..ee0cb58 100644
--- a/doc/examples/decoding_encoding.c
+++ b/doc/examples/decoding_encoding.c
@@ -194,7 +194,7 @@ static void audio_decode_example(const char *outfilename, const char *filename)
 /*
  * Video encoding example
  */
-static void video_encode_example(const char *filename)
+static void video_encode_example(const char *filename, int codec_id)
 {
     AVCodec *codec;
     AVCodecContext *c= NULL;
@@ -206,7 +206,7 @@ static void video_encode_example(const char *filename)
     printf("Video encoding\n");
 
     /* find the mpeg1 video encoder */
-    codec = avcodec_find_encoder(CODEC_ID_H264);
+    codec = avcodec_find_encoder(codec_id);
     if (!codec) {
         fprintf(stderr, "codec not found\n");
         exit(1);
@@ -226,7 +226,8 @@ static void video_encode_example(const char *filename)
     c->max_b_frames=1;
     c->pix_fmt = PIX_FMT_YUV420P;
 
-    av_opt_set(c->priv_data, "preset", "slow", 0);
+    if(codec_id == CODEC_ID_H264)
+        av_opt_set(c->priv_data, "preset", "slow", 0);
 
     /* open it */
     if (avcodec_open(c, codec) < 0) {
@@ -449,8 +450,9 @@ int main(int argc, char **argv)
         audio_encode_example("/tmp/test.mp2");
         audio_decode_example("/tmp/test.sw", "/tmp/test.mp2");
 
-        video_encode_example("/tmp/test.h264");
-        filename = "/tmp/test.h264";
+        video_encode_example("/tmp/test.h264", CODEC_ID_H264);
+        video_encode_example("/tmp/test.mpg", CODEC_ID_MPEG1VIDEO);
+        filename = "/tmp/test.mpg";
     } else {
         filename = argv[1];
     }



More information about the ffmpeg-cvslog mailing list