X-Git-Url: http://git.cinelerra-gg.org/git/?a=blobdiff_plain;f=cinelerra-5.0%2Fcinelerra%2Fformattools.C;h=f90958e017c0ebfdbbde5f2c0116afce898eb7d9;hb=f9d0d999e813ae19965e07ae2f7da690b4e6fe45;hp=0cf493facf096f4e1bfdfbbc1f45e13bd6e74c9b;hpb=8ca6d1b8ee0a3e687c57f76e793d1b1688a426f2;p=goodguy%2Fhistory.git diff --git a/cinelerra-5.0/cinelerra/formattools.C b/cinelerra-5.0/cinelerra/formattools.C index 0cf493fa..f90958e0 100644 --- a/cinelerra-5.0/cinelerra/formattools.C +++ b/cinelerra-5.0/cinelerra/formattools.C @@ -27,10 +27,11 @@ #include "filesystem.h" #include "formattools.h" #include "language.h" +#include "libdv.h" +#include "libmjpeg.h" #include "maxchannels.h" #include "mwindow.h" #include "preferences.h" -#include "quicktime.h" #include "theme.h" #include "videodevice.inc" #include @@ -201,12 +202,17 @@ void FormatTools::create_objects(int &init_x, window->add_subwindow(format_title = new BC_Title(x, y, _("File Format:"))); x += 90; - window->add_subwindow(format_text = new BC_TextBox(x, y, 200, 1, + window->add_subwindow(format_text = new BC_TextBox(x, y, 180, 1, File::formattostr(asset->format))); x += format_text->get_w(); //printf("FormatTools::create_objects %d %p\n", __LINE__, window); window->add_subwindow(format_button = new FormatFormat(x, y, this)); format_button->create_objects(); + x += format_button->get_w() + 5; + window->add_subwindow(ffmpeg_type = new FFMpegType(x, y, 50, 1, asset->fformat)); + x += ffmpeg_type->get_w(); + window->add_subwindow(format_ffmpeg = new FormatFFMPEG(x, y, this)); + format_ffmpeg->create_objects(); x = init_x; y += format_button->get_h() + 10; @@ -287,6 +293,7 @@ void FormatTools::update_driver(int driver) { this->video_driver = driver; + locked_compressor = 0; switch(driver) { case CAPTURE_DVB: @@ -299,56 +306,44 @@ void FormatTools::update_driver(int driver) format_text->update(_("MPEG stream")); asset->format = FILE_MPEG; } - locked_compressor = 0; audio_switch->update(1); video_switch->update(1); break; case CAPTURE_IEC61883: case CAPTURE_FIREWIRE: + case CAPTURE_LML: case CAPTURE_BUZ: case VIDEO4LINUX2JPEG: case CAPTURE_JPEG_WEBCAM: - if(asset->format != FILE_AVI && - asset->format != FILE_MOV) - { - format_text->update(MOV_NAME); - asset->format = FILE_MOV; - } - else - format_text->update(File::formattostr(asset->format)); - - switch(driver) - { - case CAPTURE_IEC61883: - case CAPTURE_FIREWIRE: - locked_compressor = (char*)QUICKTIME_DVSD; - strcpy(asset->vcodec, QUICKTIME_DVSD); - break; - - case CAPTURE_BUZ: - case VIDEO4LINUX2JPEG: - locked_compressor = (char*)QUICKTIME_MJPA; - strcpy(asset->vcodec, QUICKTIME_MJPA); - break; + asset->format = FILE_FFMPEG; + format_text->update(File::formattostr(asset->format)); - case CAPTURE_JPEG_WEBCAM: - locked_compressor = (char*)QUICKTIME_JPEG; - strcpy(asset->vcodec, QUICKTIME_JPEG); - break; + switch(driver) { + case CAPTURE_IEC61883: + case CAPTURE_FIREWIRE: + locked_compressor = (char*)CODEC_TAG_DVSD; + break; + + case CAPTURE_BUZ: + case CAPTURE_LML: + case VIDEO4LINUX2JPEG: + locked_compressor = (char*)CODEC_TAG_MJPEG; + break; + + case CAPTURE_JPEG_WEBCAM: + locked_compressor = (char*)CODEC_TAG_JPEG; + break; } + if( locked_compressor ) + strcpy(asset->vcodec, locked_compressor); audio_switch->update(asset->audio_data); video_switch->update(asset->video_data); break; - - - - default: format_text->update(File::formattostr(asset->format)); - locked_compressor = 0; audio_switch->update(asset->audio_data); video_switch->update(asset->video_data); break; @@ -359,7 +354,6 @@ void FormatTools::update_driver(int driver) void FormatTools::update_format() { if( do_audio && prompt_audio && audio_switch ) { - asset->audio_data = File::supports_audio(asset->format); audio_switch->update(asset->audio_data); if( !asset->audio_data ) audio_switch->disable(); @@ -367,13 +361,20 @@ void FormatTools::update_format() audio_switch->enable(); } if( do_video && prompt_video && video_switch ) { - asset->video_data = File::supports_video(asset->format); video_switch->update(asset->video_data); if( !asset->video_data ) video_switch->disable(); else video_switch->enable(); } + if( asset->format == FILE_FFMPEG ) { + ffmpeg_type->show(); + format_ffmpeg->show(); + } + else { + ffmpeg_type->hide(); + format_ffmpeg->hide(); + } } int FormatTools::handle_event() @@ -444,7 +445,8 @@ void FormatTools::update_extension() if(need_extension) { char *ptr1 = ptr; - extension_ptr = extensions.get(0); + extension_ptr = asset->format != FILE_FFMPEG ? + extensions.get(0) : asset->fformat; while(*extension_ptr != 0 && *extension_ptr != '/') *ptr1++ = *extension_ptr++; *ptr1 = 0; @@ -809,13 +811,16 @@ FormatFormat::~FormatFormat() int FormatFormat::handle_event() { - if(get_selection(0, 0) >= 0) - { + BC_ListBoxItem *selection = get_selection(0, 0); + if( selection ) { int new_format = File::strtoformat(format->plugindb, get_selection(0, 0)->get_text()); // if(new_format != format->asset->format) { - format->asset->format = new_format; - format->format_text->update(get_selection(0, 0)->get_text()); + Asset *asset = format->asset; + asset->format = new_format; + asset->audio_data = File::supports_audio(asset->format); + asset->video_data = File::supports_video(asset->format); + format->format_text->update(selection->get_text()); format->update_extension(); format->close_format_windows(); format->update_format(); @@ -825,6 +830,59 @@ int FormatFormat::handle_event() } +FormatFFMPEG::FormatFFMPEG(int x, int y, FormatTools *format) + : FFMPEGPopup(format->plugindb, x, y) +{ + this->format = format; +} + +FormatFFMPEG::~FormatFFMPEG() +{ +} + +int FormatFFMPEG::load_defaults(const char *path, const char *type, + char *codec, char *codec_options, int len) +{ + char default_file[BCTEXTLEN]; + FFMPEG::set_option_path(default_file, "%s/%s.dfl", path, type); + FILE *fp = fopen(default_file,"r"); + if( !fp ) return 1; + fgets(codec, BCSTRLEN, fp); + char *cp = codec; + while( *cp && *cp!='\n' ) ++cp; + *cp = 0; + while( len > 0 && fgets(codec_options, len, fp) ) { + int n = strlen(codec_options); + codec_options += n; len -= n; + } + fclose(fp); + FFMPEG::set_option_path(default_file, "%s/%s", path, codec); + return FFMPEG::load_options(default_file, codec_options, len); +} + +int FormatFFMPEG::handle_event() +{ + BC_ListBoxItem *selection = get_selection(0, 0); + if( selection ) { + char *text = get_selection(0, 0)->get_text(); + format->ffmpeg_type->update(text); + Asset *asset = format->asset; + strcpy(asset->fformat, text); + strcpy(asset->ff_audio_options, ""); + strcpy(asset->ff_video_options, ""); + asset->audio_data = !load_defaults("audio", text, asset->acodec, + asset->ff_audio_options, sizeof(asset->ff_audio_options)); + asset->video_data = !load_defaults("video", text, asset->vcodec, + asset->ff_video_options, sizeof(asset->ff_video_options)); + format->update_extension(); + format->close_format_windows(); + format->update_format(); + } + return 1; +} + + + FormatChannels::FormatChannels(int x, int y, FormatTools *format) : BC_TextBox(x, y, 100, 1, format->asset->channels)