diff -ruN transcode-0.6.14/export/export_ffmpeg.c transcode-0.6.14-dirac/export/export_ffmpeg.c --- transcode-0.6.14/export/export_ffmpeg.c 2004-11-14 04:17:54.000000000 +0000 +++ transcode-0.6.14-dirac/export/export_ffmpeg.c 2005-05-25 11:48:46.752814314 +0100 @@ -1,3 +1,4 @@ + /* * export_ffmpeg.c * based heavily on mplayers ve_lavc.c @@ -127,6 +128,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}}; typedef enum // do not edit without changing *_name and *_rate @@ -168,8 +170,9 @@ static int frames = 0; static struct ffmpeg_codec *codec; static int is_mpegvideo = 0; +static int raw_output=0; static int is_huffyuv = 0; -static FILE *mpeg1fd = NULL; +static FILE *rawfd = NULL; static int interlacing_active = 0; static int interlacing_top_first = 0; @@ -369,6 +372,8 @@ return TC_EXPORT_ERROR; } + + raw_output=0; if(!strcmp(user_codec_string, "mpeg1")) real_codec = strdup("mpeg1video"); else @@ -378,7 +383,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; @@ -428,10 +439,16 @@ pseudo_codec = pc_none; if(!strcmp(real_codec, "mpeg1video")) + { + raw_output=1; is_mpegvideo = 1; - + } + if(!strcmp(real_codec, "mpeg2video")) + { + raw_output=1; is_mpegvideo = 2; + } codec = find_ffmpeg_codec(real_codec); @@ -1387,7 +1404,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); @@ -1409,21 +1426,21 @@ 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"; buf = malloc(strlen (vob->video_out_file)+1+strlen(ext)); sprintf(buf, "%s%s", vob->video_out_file, ext); - mpeg1fd = fopen(buf, "wb"); - - if (!mpeg1fd) + rawfd = fopen(buf, "wb"); + fprintf(stderr, "%s \n", ext); + 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); @@ -1548,22 +1565,22 @@ if (verbose & TC_STATS) { fprintf(stderr, "[%s] encoder: size of encoded (%d)\n", MOD_NAME, out_size); } - + fprintf(stderr, "[%s] size (%d)\n", MOD_NAME, out_size); //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(); - + if (AVI_write_frame(avifile, tmp_buffer, out_size, - lavc_venc_context->coded_frame->key_frame? 1 : 0) < 0) { + lavc_venc_context->coded_frame->key_frame? 1 : 1) < 0) { AVI_print_error("avi video write error"); 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; } @@ -1684,8 +1701,32 @@ MOD_close { +int out_size; + vob_t *vob = tc_get_vob(); + if (param->flag == TC_VIDEO) { + + + /* 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(); @@ -1695,10 +1736,10 @@ return 0; } - if (is_mpegvideo) { - if (mpeg1fd) { - fclose (mpeg1fd); - mpeg1fd = NULL; + if (raw_output) { + if (rawfd) { + fclose (rawfd); + rawfd = NULL; return 0; } }