forked from mia/Aegisub
Add "Open Subtitles From Video" menu option. Closes #253.
Originally committed to SVN as r4306.
This commit is contained in:
parent
ea100e9bff
commit
a573b0897b
7 changed files with 65 additions and 21 deletions
|
@ -357,6 +357,7 @@ void FrameMain::InitMenu() {
|
||||||
AppendBitmapMenuItem(fileMenu,Menu_File_New_Subtitles, MakeHotkeyText(_("&New Subtitles"), _T("New Subtitles")), _("New subtitles"),GETIMAGE(new_toolbutton_16));
|
AppendBitmapMenuItem(fileMenu,Menu_File_New_Subtitles, MakeHotkeyText(_("&New Subtitles"), _T("New Subtitles")), _("New subtitles"),GETIMAGE(new_toolbutton_16));
|
||||||
AppendBitmapMenuItem(fileMenu,Menu_File_Open_Subtitles, MakeHotkeyText(_("&Open Subtitles..."), _T("Open Subtitles")), _("Opens a subtitles file"),GETIMAGE(open_toolbutton_16));
|
AppendBitmapMenuItem(fileMenu,Menu_File_Open_Subtitles, MakeHotkeyText(_("&Open Subtitles..."), _T("Open Subtitles")), _("Opens a subtitles file"),GETIMAGE(open_toolbutton_16));
|
||||||
AppendBitmapMenuItem(fileMenu,Menu_File_Open_Subtitles_Charset, _("&Open Subtitles with Charset..."), _("Opens a subtitles file with a specific charset"),GETIMAGE(open_with_toolbutton_16));
|
AppendBitmapMenuItem(fileMenu,Menu_File_Open_Subtitles_Charset, _("&Open Subtitles with Charset..."), _("Opens a subtitles file with a specific charset"),GETIMAGE(open_with_toolbutton_16));
|
||||||
|
fileMenu->Append(Menu_File_Open_Subtitles_From_Video, _("Open Subtitles from &Video"), _("Opens the subtitles from the current video file"));
|
||||||
AppendBitmapMenuItem(fileMenu,Menu_File_Save_Subtitles, MakeHotkeyText(_("&Save Subtitles"), _T("Save Subtitles")), _("Saves subtitles"),GETIMAGE(save_toolbutton_16));
|
AppendBitmapMenuItem(fileMenu,Menu_File_Save_Subtitles, MakeHotkeyText(_("&Save Subtitles"), _T("Save Subtitles")), _("Saves subtitles"),GETIMAGE(save_toolbutton_16));
|
||||||
AppendBitmapMenuItem(fileMenu,Menu_File_Save_Subtitles_As, _("Save Subtitles as..."), _("Saves subtitles with another name"), GETIMAGE(save_as_toolbutton_16));
|
AppendBitmapMenuItem(fileMenu,Menu_File_Save_Subtitles_As, _("Save Subtitles as..."), _("Saves subtitles with another name"), GETIMAGE(save_as_toolbutton_16));
|
||||||
AppendBitmapMenuItem(fileMenu,Menu_File_Export_Subtitles, _("Export Subtitles..."), _("Saves a copy of subtitles with processing applied to it."), GETIMAGE(export_menu_16));
|
AppendBitmapMenuItem(fileMenu,Menu_File_Export_Subtitles, _("Export Subtitles..."), _("Saves a copy of subtitles with processing applied to it."), GETIMAGE(export_menu_16));
|
||||||
|
|
|
@ -214,6 +214,7 @@ private:
|
||||||
void OnNewSubtitles (wxCommandEvent &event);
|
void OnNewSubtitles (wxCommandEvent &event);
|
||||||
void OnOpenSubtitles (wxCommandEvent &event);
|
void OnOpenSubtitles (wxCommandEvent &event);
|
||||||
void OnOpenSubtitlesCharset (wxCommandEvent &event);
|
void OnOpenSubtitlesCharset (wxCommandEvent &event);
|
||||||
|
void OnOpenSubtitlesVideo (wxCommandEvent &event);
|
||||||
void OnSaveSubtitles (wxCommandEvent &event);
|
void OnSaveSubtitles (wxCommandEvent &event);
|
||||||
void OnSaveSubtitlesAs (wxCommandEvent &event);
|
void OnSaveSubtitlesAs (wxCommandEvent &event);
|
||||||
void OnSaveSubtitlesCharset (wxCommandEvent &event);
|
void OnSaveSubtitlesCharset (wxCommandEvent &event);
|
||||||
|
@ -412,6 +413,7 @@ enum {
|
||||||
|
|
||||||
/// DOCME
|
/// DOCME
|
||||||
Menu_File_Open_Subtitles_Charset,
|
Menu_File_Open_Subtitles_Charset,
|
||||||
|
Menu_File_Open_Subtitles_From_Video,
|
||||||
|
|
||||||
/// DOCME
|
/// DOCME
|
||||||
Menu_File_New_Subtitles,
|
Menu_File_New_Subtitles,
|
||||||
|
|
|
@ -124,6 +124,7 @@ BEGIN_EVENT_TABLE(FrameMain, wxFrame)
|
||||||
EVT_MENU(Menu_File_Close_Video, FrameMain::OnCloseVideo)
|
EVT_MENU(Menu_File_Close_Video, FrameMain::OnCloseVideo)
|
||||||
EVT_MENU(Menu_File_Open_Subtitles, FrameMain::OnOpenSubtitles)
|
EVT_MENU(Menu_File_Open_Subtitles, FrameMain::OnOpenSubtitles)
|
||||||
EVT_MENU(Menu_File_Open_Subtitles_Charset, FrameMain::OnOpenSubtitlesCharset)
|
EVT_MENU(Menu_File_Open_Subtitles_Charset, FrameMain::OnOpenSubtitlesCharset)
|
||||||
|
EVT_MENU(Menu_File_Open_Subtitles_From_Video, FrameMain::OnOpenSubtitlesVideo)
|
||||||
EVT_MENU(Menu_File_New_Subtitles, FrameMain::OnNewSubtitles)
|
EVT_MENU(Menu_File_New_Subtitles, FrameMain::OnNewSubtitles)
|
||||||
EVT_MENU(Menu_File_Save_Subtitles, FrameMain::OnSaveSubtitles)
|
EVT_MENU(Menu_File_Save_Subtitles, FrameMain::OnSaveSubtitles)
|
||||||
EVT_MENU(Menu_File_Save_Subtitles_As, FrameMain::OnSaveSubtitlesAs)
|
EVT_MENU(Menu_File_Save_Subtitles_As, FrameMain::OnSaveSubtitlesAs)
|
||||||
|
@ -296,6 +297,8 @@ void FrameMain::OnMenuOpen (wxMenuEvent &event) {
|
||||||
if (curMenu == fileMenu) {
|
if (curMenu == fileMenu) {
|
||||||
// Rebuild recent
|
// Rebuild recent
|
||||||
RebuildRecentList(_T("Recent sub"),RecentSubs,Menu_File_Recent);
|
RebuildRecentList(_T("Recent sub"),RecentSubs,Menu_File_Recent);
|
||||||
|
|
||||||
|
MenuBar->Enable(Menu_File_Open_Subtitles_From_Video,VideoContext::Get()->HasSubtitles());
|
||||||
}
|
}
|
||||||
|
|
||||||
// View menu
|
// View menu
|
||||||
|
@ -811,6 +814,11 @@ void FrameMain::OnOpenSubtitlesCharset(wxCommandEvent& WXUNUSED(event)) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// @brief Open subtitles from the currently open video file
|
||||||
|
void FrameMain::OnOpenSubtitlesVideo(wxCommandEvent&) {
|
||||||
|
LoadSubtitles(VideoContext::Get()->videoName);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/// @brief Save subtitles as
|
/// @brief Save subtitles as
|
||||||
|
|
|
@ -508,9 +508,31 @@ void MatroskaWrapper::GetSubtitles(AssFile *target) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool MatroskaWrapper::HasSubtitles(wxString const& filename) {
|
||||||
|
char err[2048];
|
||||||
|
MkvStdIO input(filename);
|
||||||
|
if (!input.fp) return false;
|
||||||
|
|
||||||
|
MatroskaFile* file = mkv_Open(&input, err, sizeof(err));
|
||||||
|
if (!file) return false;
|
||||||
|
|
||||||
|
// Find tracks
|
||||||
|
int tracks = mkv_GetNumTracks(file);
|
||||||
|
for (int track = 0; track < tracks; track++) {
|
||||||
|
TrackInfo *trackInfo = mkv_GetTrackInfo(file, track);
|
||||||
|
|
||||||
|
if (trackInfo->Type == 0x11) {
|
||||||
|
wxString CodecID = wxString(trackInfo->CodecID, *wxConvCurrent);
|
||||||
|
if (CodecID == _T("S_TEXT/SSA") || CodecID == _T("S_TEXT/ASS") || CodecID == _T("S_TEXT/UTF8")) {
|
||||||
|
mkv_Close(file);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
mkv_Close(file);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
////////////////////////////// LOTS OF HAALI C CODE DOWN HERE ///////////////////////////////////////
|
////////////////////////////// LOTS OF HAALI C CODE DOWN HERE ///////////////////////////////////////
|
||||||
|
|
||||||
|
|
|
@ -174,6 +174,7 @@ public:
|
||||||
unsigned int GetFrameCount() { return timecodes.size(); }
|
unsigned int GetFrameCount() { return timecodes.size(); }
|
||||||
wxArrayInt GetKeyFrames();
|
wxArrayInt GetKeyFrames();
|
||||||
void GetSubtitles(AssFile *target);
|
void GetSubtitles(AssFile *target);
|
||||||
|
static bool HasSubtitles(wxString const& filename);
|
||||||
|
|
||||||
|
|
||||||
/// DOCME
|
/// DOCME
|
||||||
|
|
|
@ -62,6 +62,7 @@
|
||||||
#include "ass_style.h"
|
#include "ass_style.h"
|
||||||
#include "ass_time.h"
|
#include "ass_time.h"
|
||||||
#include "audio_display.h"
|
#include "audio_display.h"
|
||||||
|
#include "mkv_wrap.h"
|
||||||
#include "options.h"
|
#include "options.h"
|
||||||
#include "standard_paths.h"
|
#include "standard_paths.h"
|
||||||
#include "subs_edit_box.h"
|
#include "subs_edit_box.h"
|
||||||
|
@ -95,27 +96,26 @@ VideoContext *VideoContext::instance = NULL;
|
||||||
|
|
||||||
/// @brief Constructor
|
/// @brief Constructor
|
||||||
///
|
///
|
||||||
VideoContext::VideoContext() {
|
VideoContext::VideoContext()
|
||||||
// Set GL context
|
: glContext(NULL)
|
||||||
glContext = NULL;
|
, ownGlContext(false)
|
||||||
ownGlContext = false;
|
, audio(NULL)
|
||||||
|
, provider(NULL)
|
||||||
// Set options
|
, subsProvider(NULL)
|
||||||
audio = NULL;
|
, curLine(NULL)
|
||||||
provider = NULL;
|
, loaded(false)
|
||||||
subsProvider = NULL;
|
, keyFramesLoaded(false)
|
||||||
curLine = NULL;
|
, overKeyFramesLoaded(false)
|
||||||
loaded = false;
|
, frame_n(0)
|
||||||
keyFramesLoaded = false;
|
, length(0)
|
||||||
overKeyFramesLoaded = false;
|
, fps(0)
|
||||||
frame_n = 0;
|
, arType(0)
|
||||||
length = 0;
|
, arValue(1.)
|
||||||
fps = 0;
|
, isPlaying(false)
|
||||||
arType = 0;
|
, nextFrame(-1)
|
||||||
arValue = 1.0;
|
, keepAudioSync(true)
|
||||||
isPlaying = false;
|
, hasSubtitles(false)
|
||||||
nextFrame = -1;
|
{
|
||||||
keepAudioSync = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// @brief Destructor
|
/// @brief Destructor
|
||||||
|
@ -274,6 +274,11 @@ void VideoContext::SetVideo(const wxString &filename) {
|
||||||
wxString warning = provider->GetWarning().c_str();
|
wxString warning = provider->GetWarning().c_str();
|
||||||
if (!warning.IsEmpty()) wxMessageBox(warning,_T("Warning"),wxICON_WARNING | wxOK);
|
if (!warning.IsEmpty()) wxMessageBox(warning,_T("Warning"),wxICON_WARNING | wxOK);
|
||||||
|
|
||||||
|
hasSubtitles = false;
|
||||||
|
if (filename.Right(4).Lower() == L".mkv") {
|
||||||
|
hasSubtitles = MatroskaWrapper::HasSubtitles(filename);
|
||||||
|
}
|
||||||
|
|
||||||
UpdateDisplays(true);
|
UpdateDisplays(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -174,6 +174,8 @@ private:
|
||||||
/// DOCME
|
/// DOCME
|
||||||
int arType;
|
int arType;
|
||||||
|
|
||||||
|
bool hasSubtitles;
|
||||||
|
|
||||||
void OnPlayTimer(wxTimerEvent &event);
|
void OnPlayTimer(wxTimerEvent &event);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
@ -215,6 +217,9 @@ public:
|
||||||
/// @return
|
/// @return
|
||||||
bool IsPlaying() { return isPlaying; }
|
bool IsPlaying() { return isPlaying; }
|
||||||
|
|
||||||
|
/// @brief Does the video file loaded have muxed subtitles that we can load?
|
||||||
|
bool HasSubtitles() {return hasSubtitles; }
|
||||||
|
|
||||||
/// @brief DOCME
|
/// @brief DOCME
|
||||||
/// @param sync
|
/// @param sync
|
||||||
/// @return
|
/// @return
|
||||||
|
|
Loading…
Reference in a new issue