diff -ruN transcode-1.0.0/export/export_ffmpeg.c transcode-1.0.0-dirac/export/export_ffmpeg.c --- transcode-1.0.0/export/export_ffmpeg.c 2005-07-12 07:58:04.000000000 +0100 +++ transcode-1.0.0-dirac/export/export_ffmpeg.c 2005-08-18 16:09:42.000000000 +0100 @@ -136,6 +136,7 @@ {"ffv1", "FFV1", "FF Video Codec 1 (an experimental lossless codec)", 0}, {"asv1", "ASV1", "ASUS V1 codec", 0}, {"asv2", "ASV2", "ASUS V2 codec", 0}, + {"dirac", "drac", "Dirac codec", 0}, {NULL, NULL, NULL, 0} }; @@ -179,8 +180,9 @@ static struct ffmpeg_codec *codec; static int is_mpegvideo = 0; static int is_huffyuv = 0; +static int raw_output = 0; static int is_mjpeg = 0; -static FILE *mpeg1fd = NULL; +static FILE *rawfd = NULL; static int interlacing_active = 0; static int interlacing_top_first = 0; @@ -375,6 +377,7 @@ return TC_EXPORT_ERROR; } + raw_output=0; if (!strcmp(user_codec_string, "mpeg1")) real_codec = strdup("mpeg1video"); else @@ -384,7 +387,13 @@ if (!strcmp(user_codec_string, "dv")) real_codec = strdup("dvvideo"); else - real_codec = strdup(user_codec_string); + if(!strcmp(user_codec_string, "dirac-raw")) + { + raw_output=1; + real_codec = strdup("dirac"); + video_ext = strdup(".drc"); + } + else real_codec = strdup(user_codec_string); if (!strcmp(user_codec_string, "huffyuv")) is_huffyuv = 1; @@ -439,11 +448,15 @@ } else pseudo_codec = pc_none; - if (!strcmp(real_codec, "mpeg1video")) + if (!strcmp(real_codec, "mpeg1video")) { + raw_output = 1; is_mpegvideo = 1; + } - if (!strcmp(real_codec, "mpeg2video")) + if (!strcmp(real_codec, "mpeg2video")) { + raw_output = 1; is_mpegvideo = 2; + } codec = find_ffmpeg_codec(real_codec); @@ -1482,7 +1495,7 @@ // open output file /* Open file */ - if ( (param->flag == TC_VIDEO && !is_mpegvideo) || (param->flag == TC_AUDIO && !vob->out_flag)) { + if ( (param->flag == TC_VIDEO && !raw_output) || (param->flag == TC_AUDIO && !vob->out_flag)) { if (vob->avifile_out==NULL) { vob->avifile_out = AVI_open_output_file(vob->video_out_file); @@ -1504,9 +1517,9 @@ char * buf = 0; const char * ext; // video - if (is_mpegvideo) { + if (raw_output) { - if(probe_export_attributes & TC_PROBE_NO_EXPORT_VEXT) + if(!is_mpegvideo || probe_export_attributes & TC_PROBE_NO_EXPORT_VEXT) ext = video_ext; else ext = is_mpegvideo == 1 ? ".m1v" : ".m2v"; @@ -1516,12 +1529,12 @@ return(TC_EXPORT_ERROR); } snprintf(buf, strlen(vob->video_out_file) + 1 + strlen(ext), "%s%s", vob->video_out_file, ext); - mpeg1fd = fopen(buf, "wb"); + rawfd = fopen(buf, "wb"); - if (!mpeg1fd) + if (!rawfd) { ff_warning("Can not open file \"%s\" using /dev/null\n", buf); - mpeg1fd = fopen("/dev/null", "wb"); + rawfd = fopen("/dev/null", "wb"); } free (buf); @@ -1653,7 +1666,7 @@ //0.6.2: switch outfile on "r/R" and -J pv //0.6.2: enforce auto-split at 2G (or user value) for normal AVI files - if (!is_mpegvideo) { + if (!raw_output) { if((uint32_t)(AVI_bytes_written(avifile)+out_size+16+8)>>20 >= tc_avi_limit) tc_outstream_rotate_request(); if (lavc_venc_context->coded_frame->key_frame) tc_outstream_rotate(); @@ -1665,7 +1678,7 @@ return TC_EXPORT_ERROR; } } else { // mpegvideo - if ( (out_size >0) && (fwrite (tmp_buffer, out_size, 1, mpeg1fd) <= 0) ) { + if ( (out_size >0) && (fwrite (tmp_buffer, out_size, 1, rawfd) <= 0) ) { fprintf(stderr, "[%s] encoder error write failed size (%d)\n", MOD_NAME, out_size); //return TC_EXPORT_ERROR; } @@ -1785,9 +1798,28 @@ MOD_close { - + int out_size; vob_t *vob = tc_get_vob(); + if (param->flag == TC_AUDIO) { + /* get delayed data */ + for(;;) + { + out_size = avcodec_encode_video(lavc_venc_context, + (unsigned char *) tmp_buffer, size, + NULL); + if(out_size < 1) + break; + + if(raw_output) + fwrite (tmp_buffer, out_size, 1,rawfd); + else + AVI_write_frame(vob->avifile_out, tmp_buffer, out_size, 0); + + } + + } + if (param->flag == TC_AUDIO) return audio_close(); @@ -1797,10 +1829,10 @@ return 0; } - if (is_mpegvideo) { - if (mpeg1fd) { - fclose (mpeg1fd); - mpeg1fd = NULL; + if (raw_output) { + if (rawfd) { + fclose (rawfd); + rawfd = NULL; return 0; } }