hornetseye-ffmpeg 0.6.0 → 0.7.0

Sign up to get free protection for your applications and to get access to all the features.
data/Rakefile CHANGED
@@ -7,7 +7,7 @@ require 'rake/loaders/makefile'
7
7
  require 'rbconfig'
8
8
 
9
9
  PKG_NAME = 'hornetseye-ffmpeg'
10
- PKG_VERSION = '0.6.0'
10
+ PKG_VERSION = '0.7.0'
11
11
  CFG = RbConfig::CONFIG
12
12
  CXX = ENV[ 'CXX' ] || 'g++'
13
13
  RB_FILES = FileList[ 'lib/**/*.rb' ]
data/ext/avoutput.cc CHANGED
@@ -31,8 +31,9 @@ using namespace std;
31
31
  VALUE AVOutput::cRubyClass = Qnil;
32
32
 
33
33
  AVOutput::AVOutput( const string &mrl, int videoBitRate, int width, int height,
34
- int timeBaseNum, int timeBaseDen, int audioBitRate,
35
- int sampleRate, int channels ) throw (Error):
34
+ int timeBaseNum, int timeBaseDen, enum CodecID videoCodec,
35
+ int audioBitRate, int sampleRate, int channels,
36
+ enum CodecID audioCodec ) throw (Error):
36
37
  m_mrl( mrl ), m_oc( NULL ), m_video_st( NULL ), m_audio_st( NULL),
37
38
  m_video_codec_open( false ), m_audio_codec_open( false ), m_video_buf( NULL ),
38
39
  m_audio_buf( NULL ), m_file_open( false ), m_header_written( false ),
@@ -57,7 +58,7 @@ AVOutput::AVOutput( const string &mrl, int videoBitRate, int width, int height,
57
58
  m_video_st = av_new_stream( m_oc, 0 );
58
59
  ERRORMACRO( m_video_st != NULL, Error, , "Could not allocate video stream" );
59
60
  AVCodecContext *c = m_video_st->codec;
60
- c->codec_id = format->video_codec;
61
+ c->codec_id = videoCodec != CODEC_ID_NONE ? videoCodec : format->video_codec;
61
62
  c->codec_type = CODEC_TYPE_VIDEO;
62
63
  c->bit_rate = videoBitRate;
63
64
  c->width = width;
@@ -72,7 +73,7 @@ AVOutput::AVOutput( const string &mrl, int videoBitRate, int width, int height,
72
73
  m_audio_st = av_new_stream( m_oc, 0 );
73
74
  ERRORMACRO( m_audio_st != NULL, Error, , "Could not allocate audio stream" );
74
75
  AVCodecContext *c = m_audio_st->codec;
75
- c->codec_id = format->audio_codec;
76
+ c->codec_id = audioCodec != CODEC_ID_NONE ? audioCodec : format->audio_codec;
76
77
  c->codec_type = CODEC_TYPE_AUDIO;
77
78
  c->bit_rate = audioBitRate;
78
79
  c->sample_rate = sampleRate;
@@ -84,7 +85,7 @@ AVOutput::AVOutput( const string &mrl, int videoBitRate, int width, int height,
84
85
  ERRORMACRO( codec != NULL, Error, , "Could not find video codec "
85
86
  << c->codec_id );
86
87
  ERRORMACRO( avcodec_open( c, codec ) >= 0, Error, ,
87
- "Error opening video codec " << c->codec_id << ": "
88
+ "Error opening video codec \"" << codec->name << "\": "
88
89
  << strerror( errno ) );
89
90
  m_video_codec_open = true;
90
91
  if ( !( m_oc->oformat->flags & AVFMT_RAWPICTURE ) ) {
@@ -98,7 +99,7 @@ AVOutput::AVOutput( const string &mrl, int videoBitRate, int width, int height,
98
99
  ERRORMACRO( codec != NULL, Error, , "Could not find audio codec "
99
100
  << c->codec_id );
100
101
  ERRORMACRO( avcodec_open( c, codec ) >= 0, Error, ,
101
- "Error opening audio codec " << c->codec_id << ": "
102
+ "Error opening audio codec \"" << codec->name << "\": "
102
103
  << strerror( errno ) );
103
104
  m_audio_codec_open = true;
104
105
  m_audio_buf = (char *)av_malloc( AUDIO_BUF_SIZE );
@@ -208,12 +209,19 @@ void AVOutput::writeVideo( FramePtr frame ) throw (Error)
208
209
  } else {
209
210
  AVCodecContext *c = m_video_st->codec;
210
211
  AVFrame picture;
212
+ int
213
+ width = c->width,
214
+ height = c->height,
215
+ width2 = ( width + 1 ) / 2,
216
+ height2 = ( height + 1 ) / 2,
217
+ widtha = ( width + 7 ) & ~0x7,
218
+ width2a = ( width2 + 7 ) & ~0x7;
211
219
  picture.data[0] = (uint8_t *)frame->data();
212
- picture.data[1] = (uint8_t *)frame->data() + c->width * c->height * 5 / 4;
213
- picture.data[2] = (uint8_t *)frame->data() + c->width * c->height;
214
- picture.linesize[0] = c->width;
215
- picture.linesize[1] = c->width / 2;
216
- picture.linesize[2] = c->width / 2;
220
+ picture.data[2] = (uint8_t *)frame->data() + widtha * height;
221
+ picture.data[1] = (uint8_t *)picture.data[2] + width2a * height2;
222
+ picture.linesize[0] = widtha;
223
+ picture.linesize[1] = width2a;
224
+ picture.linesize[2] = width2a;
217
225
  sws_scale( m_swsContext, picture.data, picture.linesize, 0,
218
226
  c->height, m_frame->data, m_frame->linesize );
219
227
  int packetSize = avcodec_encode_video( c, (uint8_t *)m_video_buf,
@@ -288,7 +296,477 @@ VALUE AVOutput::registerRubyClass( VALUE rbModule )
288
296
  {
289
297
  cRubyClass = rb_define_class_under( rbModule, "AVOutput", rb_cObject );
290
298
  rb_define_singleton_method( cRubyClass, "new",
291
- RUBY_METHOD_FUNC( wrapNew ), 9 );
299
+ RUBY_METHOD_FUNC( wrapNew ), 11 );
300
+ rb_define_const( cRubyClass, "CODEC_ID_NONE",
301
+ INT2FIX( CODEC_ID_NONE ) );
302
+ rb_define_const( cRubyClass, "CODEC_ID_MPEG1VIDEO",
303
+ INT2FIX( CODEC_ID_MPEG1VIDEO ) );
304
+ rb_define_const( cRubyClass, "CODEC_ID_MPEG2VIDEO",
305
+ INT2FIX( CODEC_ID_MPEG2VIDEO ) );
306
+ rb_define_const( cRubyClass, "CODEC_ID_MPEG2VIDEO_XVMC",
307
+ INT2FIX( CODEC_ID_MPEG2VIDEO_XVMC ) );
308
+ rb_define_const( cRubyClass, "CODEC_ID_H261",
309
+ INT2FIX( CODEC_ID_H261 ) );
310
+ rb_define_const( cRubyClass, "CODEC_ID_H263",
311
+ INT2FIX( CODEC_ID_H263 ) );
312
+ rb_define_const( cRubyClass, "CODEC_ID_RV10",
313
+ INT2FIX( CODEC_ID_RV10 ) );
314
+ rb_define_const( cRubyClass, "CODEC_ID_RV20",
315
+ INT2FIX( CODEC_ID_RV20 ) );
316
+ rb_define_const( cRubyClass, "CODEC_ID_MJPEG",
317
+ INT2FIX( CODEC_ID_MJPEG ) );
318
+ rb_define_const( cRubyClass, "CODEC_ID_MJPEGB",
319
+ INT2FIX( CODEC_ID_MJPEGB ) );
320
+ rb_define_const( cRubyClass, "CODEC_ID_LJPEG",
321
+ INT2FIX( CODEC_ID_LJPEG ) );
322
+ rb_define_const( cRubyClass, "CODEC_ID_SP5X",
323
+ INT2FIX( CODEC_ID_SP5X ) );
324
+ rb_define_const( cRubyClass, "CODEC_ID_JPEGLS",
325
+ INT2FIX( CODEC_ID_JPEGLS ) );
326
+ rb_define_const( cRubyClass, "CODEC_ID_MPEG4",
327
+ INT2FIX( CODEC_ID_MPEG4 ) );
328
+ rb_define_const( cRubyClass, "CODEC_ID_RAWVIDEO",
329
+ INT2FIX( CODEC_ID_RAWVIDEO ) );
330
+ rb_define_const( cRubyClass, "CODEC_ID_MSMPEG4V1",
331
+ INT2FIX( CODEC_ID_MSMPEG4V1 ) );
332
+ rb_define_const( cRubyClass, "CODEC_ID_MSMPEG4V2",
333
+ INT2FIX( CODEC_ID_MSMPEG4V2 ) );
334
+ rb_define_const( cRubyClass, "CODEC_ID_MSMPEG4V3",
335
+ INT2FIX( CODEC_ID_MSMPEG4V3 ) );
336
+ rb_define_const( cRubyClass, "CODEC_ID_WMV1",
337
+ INT2FIX( CODEC_ID_WMV1 ) );
338
+ rb_define_const( cRubyClass, "CODEC_ID_WMV2",
339
+ INT2FIX( CODEC_ID_WMV2 ) );
340
+ rb_define_const( cRubyClass, "CODEC_ID_H263P",
341
+ INT2FIX( CODEC_ID_H263P ) );
342
+ rb_define_const( cRubyClass, "CODEC_ID_H263I",
343
+ INT2FIX( CODEC_ID_H263I ) );
344
+ rb_define_const( cRubyClass, "CODEC_ID_FLV1",
345
+ INT2FIX( CODEC_ID_FLV1 ) );
346
+ rb_define_const( cRubyClass, "CODEC_ID_SVQ1",
347
+ INT2FIX( CODEC_ID_SVQ1 ) );
348
+ rb_define_const( cRubyClass, "CODEC_ID_SVQ3",
349
+ INT2FIX( CODEC_ID_SVQ3 ) );
350
+ rb_define_const( cRubyClass, "CODEC_ID_DVVIDEO",
351
+ INT2FIX( CODEC_ID_DVVIDEO ) );
352
+ rb_define_const( cRubyClass, "CODEC_ID_HUFFYUV",
353
+ INT2FIX( CODEC_ID_HUFFYUV ) );
354
+ rb_define_const( cRubyClass, "CODEC_ID_CYUV",
355
+ INT2FIX( CODEC_ID_CYUV ) );
356
+ rb_define_const( cRubyClass, "CODEC_ID_H264",
357
+ INT2FIX( CODEC_ID_H264 ) );
358
+ rb_define_const( cRubyClass, "CODEC_ID_INDEO3",
359
+ INT2FIX( CODEC_ID_INDEO3 ) );
360
+ rb_define_const( cRubyClass, "CODEC_ID_VP3",
361
+ INT2FIX( CODEC_ID_VP3 ) );
362
+ rb_define_const( cRubyClass, "CODEC_ID_THEORA",
363
+ INT2FIX( CODEC_ID_THEORA ) );
364
+ rb_define_const( cRubyClass, "CODEC_ID_ASV1",
365
+ INT2FIX( CODEC_ID_ASV1 ) );
366
+ rb_define_const( cRubyClass, "CODEC_ID_ASV2",
367
+ INT2FIX( CODEC_ID_ASV2 ) );
368
+ rb_define_const( cRubyClass, "CODEC_ID_FFV1",
369
+ INT2FIX( CODEC_ID_FFV1 ) );
370
+ rb_define_const( cRubyClass, "CODEC_ID_4XM",
371
+ INT2FIX( CODEC_ID_4XM ) );
372
+ rb_define_const( cRubyClass, "CODEC_ID_VCR1",
373
+ INT2FIX( CODEC_ID_VCR1 ) );
374
+ rb_define_const( cRubyClass, "CODEC_ID_CLJR",
375
+ INT2FIX( CODEC_ID_CLJR ) );
376
+ rb_define_const( cRubyClass, "CODEC_ID_MDEC",
377
+ INT2FIX( CODEC_ID_MDEC ) );
378
+ rb_define_const( cRubyClass, "CODEC_ID_ROQ",
379
+ INT2FIX( CODEC_ID_ROQ ) );
380
+ rb_define_const( cRubyClass, "CODEC_ID_INTERPLAY_VIDEO",
381
+ INT2FIX( CODEC_ID_INTERPLAY_VIDEO ) );
382
+ rb_define_const( cRubyClass, "CODEC_ID_XAN_WC3",
383
+ INT2FIX( CODEC_ID_XAN_WC3 ) );
384
+ rb_define_const( cRubyClass, "CODEC_ID_XAN_WC4",
385
+ INT2FIX( CODEC_ID_XAN_WC4 ) );
386
+ rb_define_const( cRubyClass, "CODEC_ID_RPZA",
387
+ INT2FIX( CODEC_ID_RPZA ) );
388
+ rb_define_const( cRubyClass, "CODEC_ID_CINEPAK",
389
+ INT2FIX( CODEC_ID_CINEPAK ) );
390
+ rb_define_const( cRubyClass, "CODEC_ID_WS_VQA",
391
+ INT2FIX( CODEC_ID_WS_VQA ) );
392
+ rb_define_const( cRubyClass, "CODEC_ID_MSRLE",
393
+ INT2FIX( CODEC_ID_MSRLE ) );
394
+ rb_define_const( cRubyClass, "CODEC_ID_MSVIDEO1",
395
+ INT2FIX( CODEC_ID_MSVIDEO1 ) );
396
+ rb_define_const( cRubyClass, "CODEC_ID_IDCIN",
397
+ INT2FIX( CODEC_ID_IDCIN ) );
398
+ rb_define_const( cRubyClass, "CODEC_ID_8BPS",
399
+ INT2FIX( CODEC_ID_8BPS ) );
400
+ rb_define_const( cRubyClass, "CODEC_ID_SMC",
401
+ INT2FIX( CODEC_ID_SMC ) );
402
+ rb_define_const( cRubyClass, "CODEC_ID_FLIC",
403
+ INT2FIX( CODEC_ID_FLIC ) );
404
+ rb_define_const( cRubyClass, "CODEC_ID_TRUEMOTION1",
405
+ INT2FIX( CODEC_ID_TRUEMOTION1 ) );
406
+ rb_define_const( cRubyClass, "CODEC_ID_VMDVIDEO",
407
+ INT2FIX( CODEC_ID_VMDVIDEO ) );
408
+ rb_define_const( cRubyClass, "CODEC_ID_MSZH",
409
+ INT2FIX( CODEC_ID_MSZH ) );
410
+ rb_define_const( cRubyClass, "CODEC_ID_ZLIB",
411
+ INT2FIX( CODEC_ID_ZLIB ) );
412
+ rb_define_const( cRubyClass, "CODEC_ID_QTRLE",
413
+ INT2FIX( CODEC_ID_QTRLE ) );
414
+ rb_define_const( cRubyClass, "CODEC_ID_SNOW",
415
+ INT2FIX( CODEC_ID_SNOW ) );
416
+ rb_define_const( cRubyClass, "CODEC_ID_TSCC",
417
+ INT2FIX( CODEC_ID_TSCC ) );
418
+ rb_define_const( cRubyClass, "CODEC_ID_ULTI",
419
+ INT2FIX( CODEC_ID_ULTI ) );
420
+ rb_define_const( cRubyClass, "CODEC_ID_QDRAW",
421
+ INT2FIX( CODEC_ID_QDRAW ) );
422
+ rb_define_const( cRubyClass, "CODEC_ID_VIXL",
423
+ INT2FIX( CODEC_ID_VIXL ) );
424
+ rb_define_const( cRubyClass, "CODEC_ID_QPEG",
425
+ INT2FIX( CODEC_ID_QPEG ) );
426
+ rb_define_const( cRubyClass, "CODEC_ID_XVID",
427
+ INT2FIX( CODEC_ID_XVID ) );
428
+ rb_define_const( cRubyClass, "CODEC_ID_PNG",
429
+ INT2FIX( CODEC_ID_PNG ) );
430
+ rb_define_const( cRubyClass, "CODEC_ID_PPM",
431
+ INT2FIX( CODEC_ID_PPM ) );
432
+ rb_define_const( cRubyClass, "CODEC_ID_PBM",
433
+ INT2FIX( CODEC_ID_PBM ) );
434
+ rb_define_const( cRubyClass, "CODEC_ID_PGM",
435
+ INT2FIX( CODEC_ID_PGM ) );
436
+ rb_define_const( cRubyClass, "CODEC_ID_PGMYUV",
437
+ INT2FIX( CODEC_ID_PGMYUV ) );
438
+ rb_define_const( cRubyClass, "CODEC_ID_PAM",
439
+ INT2FIX( CODEC_ID_PAM ) );
440
+ rb_define_const( cRubyClass, "CODEC_ID_FFVHUFF",
441
+ INT2FIX( CODEC_ID_FFVHUFF ) );
442
+ rb_define_const( cRubyClass, "CODEC_ID_RV30",
443
+ INT2FIX( CODEC_ID_RV30 ) );
444
+ rb_define_const( cRubyClass, "CODEC_ID_RV40",
445
+ INT2FIX( CODEC_ID_RV40 ) );
446
+ rb_define_const( cRubyClass, "CODEC_ID_VC1",
447
+ INT2FIX( CODEC_ID_VC1 ) );
448
+ rb_define_const( cRubyClass, "CODEC_ID_WMV3",
449
+ INT2FIX( CODEC_ID_WMV3 ) );
450
+ rb_define_const( cRubyClass, "CODEC_ID_LOCO",
451
+ INT2FIX( CODEC_ID_LOCO ) );
452
+ rb_define_const( cRubyClass, "CODEC_ID_WNV1",
453
+ INT2FIX( CODEC_ID_WNV1 ) );
454
+ rb_define_const( cRubyClass, "CODEC_ID_AASC",
455
+ INT2FIX( CODEC_ID_AASC ) );
456
+ rb_define_const( cRubyClass, "CODEC_ID_INDEO2",
457
+ INT2FIX( CODEC_ID_INDEO2 ) );
458
+ rb_define_const( cRubyClass, "CODEC_ID_FRAPS",
459
+ INT2FIX( CODEC_ID_FRAPS ) );
460
+ rb_define_const( cRubyClass, "CODEC_ID_TRUEMOTION2",
461
+ INT2FIX( CODEC_ID_TRUEMOTION2 ) );
462
+ rb_define_const( cRubyClass, "CODEC_ID_BMP",
463
+ INT2FIX( CODEC_ID_BMP ) );
464
+ rb_define_const( cRubyClass, "CODEC_ID_CSCD",
465
+ INT2FIX( CODEC_ID_CSCD ) );
466
+ rb_define_const( cRubyClass, "CODEC_ID_MMVIDEO",
467
+ INT2FIX( CODEC_ID_MMVIDEO ) );
468
+ rb_define_const( cRubyClass, "CODEC_ID_ZMBV",
469
+ INT2FIX( CODEC_ID_ZMBV ) );
470
+ rb_define_const( cRubyClass, "CODEC_ID_AVS",
471
+ INT2FIX( CODEC_ID_AVS ) );
472
+ rb_define_const( cRubyClass, "CODEC_ID_SMACKVIDEO",
473
+ INT2FIX( CODEC_ID_SMACKVIDEO ) );
474
+ rb_define_const( cRubyClass, "CODEC_ID_NUV",
475
+ INT2FIX( CODEC_ID_NUV ) );
476
+ rb_define_const( cRubyClass, "CODEC_ID_KMVC",
477
+ INT2FIX( CODEC_ID_KMVC ) );
478
+ rb_define_const( cRubyClass, "CODEC_ID_FLASHSV",
479
+ INT2FIX( CODEC_ID_FLASHSV ) );
480
+ rb_define_const( cRubyClass, "CODEC_ID_CAVS",
481
+ INT2FIX( CODEC_ID_CAVS ) );
482
+ rb_define_const( cRubyClass, "CODEC_ID_JPEG2000",
483
+ INT2FIX( CODEC_ID_JPEG2000 ) );
484
+ rb_define_const( cRubyClass, "CODEC_ID_VMNC",
485
+ INT2FIX( CODEC_ID_VMNC ) );
486
+ rb_define_const( cRubyClass, "CODEC_ID_VP5",
487
+ INT2FIX( CODEC_ID_VP5 ) );
488
+ rb_define_const( cRubyClass, "CODEC_ID_VP6",
489
+ INT2FIX( CODEC_ID_VP6 ) );
490
+ rb_define_const( cRubyClass, "CODEC_ID_VP6F",
491
+ INT2FIX( CODEC_ID_VP6F ) );
492
+ rb_define_const( cRubyClass, "CODEC_ID_TARGA",
493
+ INT2FIX( CODEC_ID_TARGA ) );
494
+ rb_define_const( cRubyClass, "CODEC_ID_DSICINVIDEO",
495
+ INT2FIX( CODEC_ID_DSICINVIDEO ) );
496
+ rb_define_const( cRubyClass, "CODEC_ID_TIERTEXSEQVIDEO",
497
+ INT2FIX( CODEC_ID_TIERTEXSEQVIDEO ) );
498
+ rb_define_const( cRubyClass, "CODEC_ID_TIFF",
499
+ INT2FIX( CODEC_ID_TIFF ) );
500
+ rb_define_const( cRubyClass, "CODEC_ID_GIF",
501
+ INT2FIX( CODEC_ID_GIF ) );
502
+ rb_define_const( cRubyClass, "CODEC_ID_FFH264",
503
+ INT2FIX( CODEC_ID_FFH264 ) );
504
+ rb_define_const( cRubyClass, "CODEC_ID_DXA",
505
+ INT2FIX( CODEC_ID_DXA ) );
506
+ rb_define_const( cRubyClass, "CODEC_ID_DNXHD",
507
+ INT2FIX( CODEC_ID_DNXHD ) );
508
+ rb_define_const( cRubyClass, "CODEC_ID_THP",
509
+ INT2FIX( CODEC_ID_THP ) );
510
+ rb_define_const( cRubyClass, "CODEC_ID_SGI",
511
+ INT2FIX( CODEC_ID_SGI ) );
512
+ rb_define_const( cRubyClass, "CODEC_ID_C93",
513
+ INT2FIX( CODEC_ID_C93 ) );
514
+ rb_define_const( cRubyClass, "CODEC_ID_BETHSOFTVID",
515
+ INT2FIX( CODEC_ID_BETHSOFTVID ) );
516
+ rb_define_const( cRubyClass, "CODEC_ID_PTX",
517
+ INT2FIX( CODEC_ID_PTX ) );
518
+ rb_define_const( cRubyClass, "CODEC_ID_TXD",
519
+ INT2FIX( CODEC_ID_TXD ) );
520
+ rb_define_const( cRubyClass, "CODEC_ID_VP6A",
521
+ INT2FIX( CODEC_ID_VP6A ) );
522
+ rb_define_const( cRubyClass, "CODEC_ID_AMV",
523
+ INT2FIX( CODEC_ID_AMV ) );
524
+ rb_define_const( cRubyClass, "CODEC_ID_VB",
525
+ INT2FIX( CODEC_ID_VB ) );
526
+ rb_define_const( cRubyClass, "CODEC_ID_PCX",
527
+ INT2FIX( CODEC_ID_PCX ) );
528
+ rb_define_const( cRubyClass, "CODEC_ID_SUNRAST",
529
+ INT2FIX( CODEC_ID_SUNRAST ) );
530
+ rb_define_const( cRubyClass, "CODEC_ID_INDEO4",
531
+ INT2FIX( CODEC_ID_INDEO4 ) );
532
+ rb_define_const( cRubyClass, "CODEC_ID_INDEO5",
533
+ INT2FIX( CODEC_ID_INDEO5 ) );
534
+ rb_define_const( cRubyClass, "CODEC_ID_MIMIC",
535
+ INT2FIX( CODEC_ID_MIMIC ) );
536
+ rb_define_const( cRubyClass, "CODEC_ID_RL2",
537
+ INT2FIX( CODEC_ID_RL2 ) );
538
+ rb_define_const( cRubyClass, "CODEC_ID_8SVX_EXP",
539
+ INT2FIX( CODEC_ID_8SVX_EXP ) );
540
+ rb_define_const( cRubyClass, "CODEC_ID_8SVX_FIB",
541
+ INT2FIX( CODEC_ID_8SVX_FIB ) );
542
+ rb_define_const( cRubyClass, "CODEC_ID_ESCAPE124",
543
+ INT2FIX( CODEC_ID_ESCAPE124 ) );
544
+ rb_define_const( cRubyClass, "CODEC_ID_DIRAC",
545
+ INT2FIX( CODEC_ID_DIRAC ) );
546
+ rb_define_const( cRubyClass, "CODEC_ID_BFI",
547
+ INT2FIX( CODEC_ID_BFI ) );
548
+ rb_define_const( cRubyClass, "CODEC_ID_CMV",
549
+ INT2FIX( CODEC_ID_CMV ) );
550
+ rb_define_const( cRubyClass, "CODEC_ID_MOTIONPIXELS",
551
+ INT2FIX( CODEC_ID_MOTIONPIXELS ) );
552
+ rb_define_const( cRubyClass, "CODEC_ID_TGV",
553
+ INT2FIX( CODEC_ID_TGV ) );
554
+ rb_define_const( cRubyClass, "CODEC_ID_TGQ",
555
+ INT2FIX( CODEC_ID_TGQ ) );
556
+ rb_define_const( cRubyClass, "CODEC_ID_TQI",
557
+ INT2FIX( CODEC_ID_TQI ) );
558
+ rb_define_const( cRubyClass, "CODEC_ID_PCM_S16LE",
559
+ INT2FIX( CODEC_ID_PCM_S16LE ) );
560
+ rb_define_const( cRubyClass, "CODEC_ID_PCM_S16BE",
561
+ INT2FIX( CODEC_ID_PCM_S16BE ) );
562
+ rb_define_const( cRubyClass, "CODEC_ID_PCM_U16LE",
563
+ INT2FIX( CODEC_ID_PCM_U16LE ) );
564
+ rb_define_const( cRubyClass, "CODEC_ID_PCM_U16BE",
565
+ INT2FIX( CODEC_ID_PCM_U16BE ) );
566
+ rb_define_const( cRubyClass, "CODEC_ID_PCM_S8",
567
+ INT2FIX( CODEC_ID_PCM_S8 ) );
568
+ rb_define_const( cRubyClass, "CODEC_ID_PCM_U8",
569
+ INT2FIX( CODEC_ID_PCM_U8 ) );
570
+ rb_define_const( cRubyClass, "CODEC_ID_PCM_MULAW",
571
+ INT2FIX( CODEC_ID_PCM_MULAW ) );
572
+ rb_define_const( cRubyClass, "CODEC_ID_PCM_ALAW",
573
+ INT2FIX( CODEC_ID_PCM_ALAW ) );
574
+ rb_define_const( cRubyClass, "CODEC_ID_PCM_S32LE",
575
+ INT2FIX( CODEC_ID_PCM_S32LE ) );
576
+ rb_define_const( cRubyClass, "CODEC_ID_PCM_S32BE",
577
+ INT2FIX( CODEC_ID_PCM_S32BE ) );
578
+ rb_define_const( cRubyClass, "CODEC_ID_PCM_U32LE",
579
+ INT2FIX( CODEC_ID_PCM_U32LE ) );
580
+ rb_define_const( cRubyClass, "CODEC_ID_PCM_U32BE",
581
+ INT2FIX( CODEC_ID_PCM_U32BE ) );
582
+ rb_define_const( cRubyClass, "CODEC_ID_PCM_S24LE",
583
+ INT2FIX( CODEC_ID_PCM_S24LE ) );
584
+ rb_define_const( cRubyClass, "CODEC_ID_PCM_S24BE",
585
+ INT2FIX( CODEC_ID_PCM_S24BE ) );
586
+ rb_define_const( cRubyClass, "CODEC_ID_PCM_U24LE",
587
+ INT2FIX( CODEC_ID_PCM_U24LE ) );
588
+ rb_define_const( cRubyClass, "CODEC_ID_PCM_U24BE",
589
+ INT2FIX( CODEC_ID_PCM_U24BE ) );
590
+ rb_define_const( cRubyClass, "CODEC_ID_PCM_S24DAUD",
591
+ INT2FIX( CODEC_ID_PCM_S24DAUD ) );
592
+ rb_define_const( cRubyClass, "CODEC_ID_PCM_ZORK",
593
+ INT2FIX( CODEC_ID_PCM_ZORK ) );
594
+ rb_define_const( cRubyClass, "CODEC_ID_PCM_S16LE_PLANAR",
595
+ INT2FIX( CODEC_ID_PCM_S16LE_PLANAR ) );
596
+ rb_define_const( cRubyClass, "CODEC_ID_PCM_DVD",
597
+ INT2FIX( CODEC_ID_PCM_DVD ) );
598
+ rb_define_const( cRubyClass, "CODEC_ID_PCM_F32BE",
599
+ INT2FIX( CODEC_ID_PCM_F32BE ) );
600
+ rb_define_const( cRubyClass, "CODEC_ID_PCM_F32LE",
601
+ INT2FIX( CODEC_ID_PCM_F32LE ) );
602
+ rb_define_const( cRubyClass, "CODEC_ID_PCM_F64BE",
603
+ INT2FIX( CODEC_ID_PCM_F64BE ) );
604
+ rb_define_const( cRubyClass, "CODEC_ID_PCM_F64LE",
605
+ INT2FIX( CODEC_ID_PCM_F64LE ) );
606
+ rb_define_const( cRubyClass, "CODEC_ID_ADPCM_IMA_QT",
607
+ INT2FIX( CODEC_ID_ADPCM_IMA_QT ) );
608
+ rb_define_const( cRubyClass, "CODEC_ID_ADPCM_IMA_WAV",
609
+ INT2FIX( CODEC_ID_ADPCM_IMA_WAV ) );
610
+ rb_define_const( cRubyClass, "CODEC_ID_ADPCM_IMA_DK3",
611
+ INT2FIX( CODEC_ID_ADPCM_IMA_DK3 ) );
612
+ rb_define_const( cRubyClass, "CODEC_ID_ADPCM_IMA_DK4",
613
+ INT2FIX( CODEC_ID_ADPCM_IMA_DK4 ) );
614
+ rb_define_const( cRubyClass, "CODEC_ID_ADPCM_IMA_WS",
615
+ INT2FIX( CODEC_ID_ADPCM_IMA_WS ) );
616
+ rb_define_const( cRubyClass, "CODEC_ID_ADPCM_IMA_SMJPEG",
617
+ INT2FIX( CODEC_ID_ADPCM_IMA_SMJPEG ) );
618
+ rb_define_const( cRubyClass, "CODEC_ID_ADPCM_MS",
619
+ INT2FIX( CODEC_ID_ADPCM_MS ) );
620
+ rb_define_const( cRubyClass, "CODEC_ID_ADPCM_4XM",
621
+ INT2FIX( CODEC_ID_ADPCM_4XM ) );
622
+ rb_define_const( cRubyClass, "CODEC_ID_ADPCM_XA",
623
+ INT2FIX( CODEC_ID_ADPCM_XA ) );
624
+ rb_define_const( cRubyClass, "CODEC_ID_ADPCM_ADX",
625
+ INT2FIX( CODEC_ID_ADPCM_ADX ) );
626
+ rb_define_const( cRubyClass, "CODEC_ID_ADPCM_EA",
627
+ INT2FIX( CODEC_ID_ADPCM_EA ) );
628
+ rb_define_const( cRubyClass, "CODEC_ID_ADPCM_G726",
629
+ INT2FIX( CODEC_ID_ADPCM_G726 ) );
630
+ rb_define_const( cRubyClass, "CODEC_ID_ADPCM_CT",
631
+ INT2FIX( CODEC_ID_ADPCM_CT ) );
632
+ rb_define_const( cRubyClass, "CODEC_ID_ADPCM_SWF",
633
+ INT2FIX( CODEC_ID_ADPCM_SWF ) );
634
+ rb_define_const( cRubyClass, "CODEC_ID_ADPCM_YAMAHA",
635
+ INT2FIX( CODEC_ID_ADPCM_YAMAHA ) );
636
+ rb_define_const( cRubyClass, "CODEC_ID_ADPCM_SBPRO_4",
637
+ INT2FIX( CODEC_ID_ADPCM_SBPRO_4 ) );
638
+ rb_define_const( cRubyClass, "CODEC_ID_ADPCM_SBPRO_3",
639
+ INT2FIX( CODEC_ID_ADPCM_SBPRO_3 ) );
640
+ rb_define_const( cRubyClass, "CODEC_ID_ADPCM_SBPRO_2",
641
+ INT2FIX( CODEC_ID_ADPCM_SBPRO_2 ) );
642
+ rb_define_const( cRubyClass, "CODEC_ID_ADPCM_THP",
643
+ INT2FIX( CODEC_ID_ADPCM_THP ) );
644
+ rb_define_const( cRubyClass, "CODEC_ID_ADPCM_IMA_AMV",
645
+ INT2FIX( CODEC_ID_ADPCM_IMA_AMV ) );
646
+ rb_define_const( cRubyClass, "CODEC_ID_ADPCM_EA_R1",
647
+ INT2FIX( CODEC_ID_ADPCM_EA_R1 ) );
648
+ rb_define_const( cRubyClass, "CODEC_ID_ADPCM_EA_R3",
649
+ INT2FIX( CODEC_ID_ADPCM_EA_R3 ) );
650
+ rb_define_const( cRubyClass, "CODEC_ID_ADPCM_EA_R2",
651
+ INT2FIX( CODEC_ID_ADPCM_EA_R2 ) );
652
+ rb_define_const( cRubyClass, "CODEC_ID_ADPCM_IMA_EA_SEAD",
653
+ INT2FIX( CODEC_ID_ADPCM_IMA_EA_SEAD ) );
654
+ rb_define_const( cRubyClass, "CODEC_ID_ADPCM_IMA_EA_EACS",
655
+ INT2FIX( CODEC_ID_ADPCM_IMA_EA_EACS ) );
656
+ rb_define_const( cRubyClass, "CODEC_ID_ADPCM_EA_XAS",
657
+ INT2FIX( CODEC_ID_ADPCM_EA_XAS ) );
658
+ rb_define_const( cRubyClass, "CODEC_ID_ADPCM_EA_MAXIS_XA",
659
+ INT2FIX( CODEC_ID_ADPCM_EA_MAXIS_XA ) );
660
+ rb_define_const( cRubyClass, "CODEC_ID_ADPCM_IMA_ISS",
661
+ INT2FIX( CODEC_ID_ADPCM_IMA_ISS ) );
662
+ rb_define_const( cRubyClass, "CODEC_ID_AMR_NB",
663
+ INT2FIX( CODEC_ID_AMR_NB ) );
664
+ rb_define_const( cRubyClass, "CODEC_ID_AMR_WB",
665
+ INT2FIX( CODEC_ID_AMR_WB ) );
666
+ rb_define_const( cRubyClass, "CODEC_ID_RA_144",
667
+ INT2FIX( CODEC_ID_RA_144 ) );
668
+ rb_define_const( cRubyClass, "CODEC_ID_RA_288",
669
+ INT2FIX( CODEC_ID_RA_288 ) );
670
+ rb_define_const( cRubyClass, "CODEC_ID_ROQ_DPCM",
671
+ INT2FIX( CODEC_ID_ROQ_DPCM ) );
672
+ rb_define_const( cRubyClass, "CODEC_ID_INTERPLAY_DPCM",
673
+ INT2FIX( CODEC_ID_INTERPLAY_DPCM ) );
674
+ rb_define_const( cRubyClass, "CODEC_ID_XAN_DPCM",
675
+ INT2FIX( CODEC_ID_XAN_DPCM ) );
676
+ rb_define_const( cRubyClass, "CODEC_ID_SOL_DPCM",
677
+ INT2FIX( CODEC_ID_SOL_DPCM ) );
678
+ rb_define_const( cRubyClass, "CODEC_ID_MP2",
679
+ INT2FIX( CODEC_ID_MP2 ) );
680
+ rb_define_const( cRubyClass, "CODEC_ID_MP3",
681
+ INT2FIX( CODEC_ID_MP3 ) );
682
+ rb_define_const( cRubyClass, "CODEC_ID_AAC",
683
+ INT2FIX( CODEC_ID_AAC ) );
684
+ rb_define_const( cRubyClass, "CODEC_ID_AC3",
685
+ INT2FIX( CODEC_ID_AC3 ) );
686
+ rb_define_const( cRubyClass, "CODEC_ID_DTS",
687
+ INT2FIX( CODEC_ID_DTS ) );
688
+ rb_define_const( cRubyClass, "CODEC_ID_VORBIS",
689
+ INT2FIX( CODEC_ID_VORBIS ) );
690
+ rb_define_const( cRubyClass, "CODEC_ID_DVAUDIO",
691
+ INT2FIX( CODEC_ID_DVAUDIO ) );
692
+ rb_define_const( cRubyClass, "CODEC_ID_WMAV1",
693
+ INT2FIX( CODEC_ID_WMAV1 ) );
694
+ rb_define_const( cRubyClass, "CODEC_ID_WMAV2",
695
+ INT2FIX( CODEC_ID_WMAV2 ) );
696
+ rb_define_const( cRubyClass, "CODEC_ID_MACE3",
697
+ INT2FIX( CODEC_ID_MACE3 ) );
698
+ rb_define_const( cRubyClass, "CODEC_ID_MACE6",
699
+ INT2FIX( CODEC_ID_MACE6 ) );
700
+ rb_define_const( cRubyClass, "CODEC_ID_VMDAUDIO",
701
+ INT2FIX( CODEC_ID_VMDAUDIO ) );
702
+ rb_define_const( cRubyClass, "CODEC_ID_SONIC",
703
+ INT2FIX( CODEC_ID_SONIC ) );
704
+ rb_define_const( cRubyClass, "CODEC_ID_SONIC_LS",
705
+ INT2FIX( CODEC_ID_SONIC_LS ) );
706
+ rb_define_const( cRubyClass, "CODEC_ID_FLAC",
707
+ INT2FIX( CODEC_ID_FLAC ) );
708
+ rb_define_const( cRubyClass, "CODEC_ID_MP3ADU",
709
+ INT2FIX( CODEC_ID_MP3ADU ) );
710
+ rb_define_const( cRubyClass, "CODEC_ID_MP3ON4",
711
+ INT2FIX( CODEC_ID_MP3ON4 ) );
712
+ rb_define_const( cRubyClass, "CODEC_ID_SHORTEN",
713
+ INT2FIX( CODEC_ID_SHORTEN ) );
714
+ rb_define_const( cRubyClass, "CODEC_ID_ALAC",
715
+ INT2FIX( CODEC_ID_ALAC ) );
716
+ rb_define_const( cRubyClass, "CODEC_ID_WESTWOOD_SND1",
717
+ INT2FIX( CODEC_ID_WESTWOOD_SND1 ) );
718
+ rb_define_const( cRubyClass, "CODEC_ID_GSM",
719
+ INT2FIX( CODEC_ID_GSM ) );
720
+ rb_define_const( cRubyClass, "CODEC_ID_QDM2",
721
+ INT2FIX( CODEC_ID_QDM2 ) );
722
+ rb_define_const( cRubyClass, "CODEC_ID_COOK",
723
+ INT2FIX( CODEC_ID_COOK ) );
724
+ rb_define_const( cRubyClass, "CODEC_ID_TRUESPEECH",
725
+ INT2FIX( CODEC_ID_TRUESPEECH ) );
726
+ rb_define_const( cRubyClass, "CODEC_ID_TTA",
727
+ INT2FIX( CODEC_ID_TTA ) );
728
+ rb_define_const( cRubyClass, "CODEC_ID_SMACKAUDIO",
729
+ INT2FIX( CODEC_ID_SMACKAUDIO ) );
730
+ rb_define_const( cRubyClass, "CODEC_ID_QCELP",
731
+ INT2FIX( CODEC_ID_QCELP ) );
732
+ rb_define_const( cRubyClass, "CODEC_ID_WAVPACK",
733
+ INT2FIX( CODEC_ID_WAVPACK ) );
734
+ rb_define_const( cRubyClass, "CODEC_ID_DSICINAUDIO",
735
+ INT2FIX( CODEC_ID_DSICINAUDIO ) );
736
+ rb_define_const( cRubyClass, "CODEC_ID_IMC",
737
+ INT2FIX( CODEC_ID_IMC ) );
738
+ rb_define_const( cRubyClass, "CODEC_ID_MUSEPACK7",
739
+ INT2FIX( CODEC_ID_MUSEPACK7 ) );
740
+ rb_define_const( cRubyClass, "CODEC_ID_MLP",
741
+ INT2FIX( CODEC_ID_MLP ) );
742
+ rb_define_const( cRubyClass, "CODEC_ID_GSM_MS",
743
+ INT2FIX( CODEC_ID_GSM_MS ) );
744
+ rb_define_const( cRubyClass, "CODEC_ID_ATRAC3",
745
+ INT2FIX( CODEC_ID_ATRAC3 ) );
746
+ rb_define_const( cRubyClass, "CODEC_ID_VOXWARE",
747
+ INT2FIX( CODEC_ID_VOXWARE ) );
748
+ rb_define_const( cRubyClass, "CODEC_ID_APE",
749
+ INT2FIX( CODEC_ID_APE ) );
750
+ rb_define_const( cRubyClass, "CODEC_ID_NELLYMOSER",
751
+ INT2FIX( CODEC_ID_NELLYMOSER ) );
752
+ rb_define_const( cRubyClass, "CODEC_ID_MUSEPACK8",
753
+ INT2FIX( CODEC_ID_MUSEPACK8 ) );
754
+ rb_define_const( cRubyClass, "CODEC_ID_SPEEX",
755
+ INT2FIX( CODEC_ID_SPEEX ) );
756
+ rb_define_const( cRubyClass, "CODEC_ID_WMAVOICE",
757
+ INT2FIX( CODEC_ID_WMAVOICE ) );
758
+ rb_define_const( cRubyClass, "CODEC_ID_WMAPRO",
759
+ INT2FIX( CODEC_ID_WMAPRO ) );
760
+ rb_define_const( cRubyClass, "CODEC_ID_WMALOSSLESS",
761
+ INT2FIX( CODEC_ID_WMALOSSLESS ) );
762
+ rb_define_const( cRubyClass, "CODEC_ID_ATRAC3P",
763
+ INT2FIX( CODEC_ID_ATRAC3P ) );
764
+ rb_define_const( cRubyClass, "CODEC_ID_EAC3",
765
+ INT2FIX( CODEC_ID_EAC3 ) );
766
+ rb_define_const( cRubyClass, "CODEC_ID_SIPR",
767
+ INT2FIX( CODEC_ID_SIPR ) );
768
+ rb_define_const( cRubyClass, "CODEC_ID_MP1",
769
+ INT2FIX( CODEC_ID_MP1 ) );
292
770
  rb_define_method( cRubyClass, "close", RUBY_METHOD_FUNC( wrapClose ), 0 );
293
771
  rb_define_method( cRubyClass, "frame_size", RUBY_METHOD_FUNC( wrapFrameSize ), 0 );
294
772
  rb_define_method( cRubyClass, "channels", RUBY_METHOD_FUNC( wrapChannels ), 0 );
@@ -303,7 +781,8 @@ void AVOutput::deleteRubyObject( void *ptr )
303
781
 
304
782
  VALUE AVOutput::wrapNew( VALUE rbClass, VALUE rbMRL, VALUE rbBitRate, VALUE rbWidth,
305
783
  VALUE rbHeight, VALUE rbTimeBaseNum, VALUE rbTimeBaseDen,
306
- VALUE rbAudioBitRate, VALUE rbSampleRate, VALUE rbChannels )
784
+ VALUE rbVideoCodec, VALUE rbAudioBitRate, VALUE rbSampleRate,
785
+ VALUE rbChannels, VALUE rbAudioCodec )
307
786
  {
308
787
  VALUE retVal = Qnil;
309
788
  try {
@@ -311,8 +790,10 @@ VALUE AVOutput::wrapNew( VALUE rbClass, VALUE rbMRL, VALUE rbBitRate, VALUE rbWi
311
790
  AVOutputPtr ptr( new AVOutput( StringValuePtr( rbMRL ), NUM2INT( rbBitRate ),
312
791
  NUM2INT( rbWidth ), NUM2INT( rbHeight ),
313
792
  NUM2INT( rbTimeBaseNum ), NUM2INT( rbTimeBaseDen ),
793
+ (enum CodecID)NUM2INT( rbVideoCodec ),
314
794
  NUM2INT( rbAudioBitRate ), NUM2INT( rbSampleRate ),
315
- NUM2INT( rbChannels ) ) );
795
+ NUM2INT( rbChannels ),
796
+ (enum CodecID)NUM2INT( rbAudioCodec ) ) );
316
797
  retVal = Data_Wrap_Struct( rbClass, 0, deleteRubyObject,
317
798
  new AVOutputPtr( ptr ) );
318
799
  } catch ( exception &e ) {
data/ext/avoutput.hh CHANGED
@@ -41,9 +41,10 @@ extern "C" {
41
41
  class AVOutput
42
42
  {
43
43
  public:
44
- AVOutput( const std::string &mrl, int videoBitRate,
45
- int width, int height, int timeBaseNum, int timeBaseDen,
46
- int audioBitRate, int sampleRate, int channels ) throw (Error);
44
+ AVOutput( const std::string &mrl, int videoBitRate, int width, int height,
45
+ int timeBaseNum, int timeBaseDen, enum CodecID videoCodec,
46
+ int audioBitRate, int sampleRate, int channels,
47
+ enum CodecID audioCodec ) throw (Error);
47
48
  virtual ~AVOutput(void);
48
49
  void close(void);
49
50
  int frameSize(void) throw (Error);
@@ -55,7 +56,8 @@ public:
55
56
  static void deleteRubyObject( void *ptr );
56
57
  static VALUE wrapNew( VALUE rbClass, VALUE rbMRL, VALUE rbBitRate, VALUE rbWidth,
57
58
  VALUE rbHeight, VALUE rbTimeBaseNum, VALUE rbTimeBaseDen,
58
- VALUE rbAudioBitRate, VALUE rbSampleRate, VALUE rbChannels );
59
+ VALUE rbVideoCodec, VALUE rbAudioBitRate, VALUE rbSampleRate,
60
+ VALUE rbChannels, VALUE rbAudioCodec );
59
61
  static VALUE wrapClose( VALUE rbSelf );
60
62
  static VALUE wrapFrameSize( VALUE rbSelf );
61
63
  static VALUE wrapChannels( VALUE rbSelf );
@@ -23,16 +23,19 @@ module Hornetseye
23
23
 
24
24
  alias_method :orig_new, :new
25
25
 
26
- def new( mrl, video_bit_rate, width, height, frame_rate, have_audio = false,
27
- audio_bit_rate = 64000, sample_rate = 44100, channels = 2 )
26
+ def new( mrl, video_bit_rate, width, height, frame_rate, video_codec = nil,
27
+ have_audio = false, audio_bit_rate = 64000, sample_rate = 44100,
28
+ channels = 2, audio_codec = nil )
28
29
  if frame_rate.is_a? Float
29
30
  frame_rate = Rational( 90000, ( 90000 / frame_rate ).to_i )
30
31
  end
31
32
  orig_new mrl, video_bit_rate, width, height,
32
33
  frame_rate.denominator, frame_rate.numerator,
34
+ video_codec || CODEC_ID_NONE,
33
35
  have_audio ? audio_bit_rate : 0,
34
36
  have_audio ? sample_rate : 0,
35
- have_audio ? channels : 0
37
+ have_audio ? channels : 0,
38
+ audio_codec || CODEC_ID_NONE
36
39
  end
37
40
 
38
41
  end
metadata CHANGED
@@ -4,9 +4,9 @@ version: !ruby/object:Gem::Version
4
4
  prerelease: false
5
5
  segments:
6
6
  - 0
7
- - 6
7
+ - 7
8
8
  - 0
9
- version: 0.6.0
9
+ version: 0.7.0
10
10
  platform: ruby
11
11
  authors:
12
12
  - Jan Wedekind