[gnome-subtitles] Enable subtitling of audio files (Fixes #584795)
- From: Pedro Daniel da Rocha Melo e Castro <pcastro src gnome org>
- To: svn-commits-list gnome org
- Subject: [gnome-subtitles] Enable subtitling of audio files (Fixes #584795)
- Date: Sun, 12 Jul 2009 21:35:14 +0000 (UTC)
commit 10c483e9b6a6b3a33e5387fbc5d3610250de5674
Author: Pedro Castro <mail pedrocastro org>
Date: Sun Jul 12 22:35:03 2009 +0100
Enable subtitling of audio files (Fixes #584795)
Set default frame rate and aspect ratio for audio files.
src/External/GStreamerPlaybin/Engine.cs | 13 ++++++++++---
src/External/GStreamerPlaybin/main.c | 2 ++
src/GnomeSubtitles/Ui/VideoPreview/Player.cs | 26 ++++++++++++++++++++------
src/GnomeSubtitles/Ui/VideoPreview/Video.cs | 2 +-
src/SubLib/Core/Domain/SubtitleConstants.cs | 5 +++--
5 files changed, 36 insertions(+), 12 deletions(-)
---
diff --git a/src/External/GStreamerPlaybin/Engine.cs b/src/External/GStreamerPlaybin/Engine.cs
index 296ed03..f034a3b 100644
--- a/src/External/GStreamerPlaybin/Engine.cs
+++ b/src/External/GStreamerPlaybin/Engine.cs
@@ -532,7 +532,8 @@ namespace GStreamer
{
int width;
int height;
- float frame_rate;
+ float aspect_ratio;
+ float frame_rate;
bool has_audio;
bool has_video;
@@ -544,8 +545,14 @@ namespace GStreamer
public int Width { get{ return width; } }
public int Height { get{ return height; } }
- public float AspectRatio { get { return (float)width/height; } }
- public float FrameRate { get{ return frame_rate; } }
+ public float AspectRatio {
+ get { return aspect_ratio; }
+ set { aspect_ratio = value; }
+ }
+ public float FrameRate {
+ get{ return frame_rate; }
+ set {this.frame_rate = value;}
+ }
public bool HasAudio { get{ return has_audio; } }
public bool HasVideo { get{ return has_video; } }
diff --git a/src/External/GStreamerPlaybin/main.c b/src/External/GStreamerPlaybin/main.c
index d598eac..bb9e136 100644
--- a/src/External/GStreamerPlaybin/main.c
+++ b/src/External/GStreamerPlaybin/main.c
@@ -45,6 +45,7 @@ typedef void (* tagCallback) (gstTag *tag);
struct gstVideoInfo {
gint width;
gint height;
+ gfloat aspect_ratio;
gfloat frame_rate;
gboolean has_audio;
gboolean has_video;
@@ -483,6 +484,7 @@ gboolean gst_binding_load_video_info (gstPlay *play) {
if ((caps_width != -1) && (caps_height != -1) && (caps_frame_rate != -1)) {
play->video_info->width = caps_width;
play->video_info->height = caps_height;
+ play->video_info->aspect_ratio = ((float)caps_width)/((float)caps_height);
play->video_info->frame_rate = caps_frame_rate;
return TRUE;
}
diff --git a/src/GnomeSubtitles/Ui/VideoPreview/Player.cs b/src/GnomeSubtitles/Ui/VideoPreview/Player.cs
index fb2116c..9a406ef 100644
--- a/src/GnomeSubtitles/Ui/VideoPreview/Player.cs
+++ b/src/GnomeSubtitles/Ui/VideoPreview/Player.cs
@@ -20,6 +20,7 @@
using GnomeSubtitles.Ui.VideoPreview.Exceptions;
using GStreamer;
using Gtk;
+using SubLib.Core.Domain;
using System;
namespace GnomeSubtitles.Ui.VideoPreview {
@@ -35,6 +36,10 @@ public class Player {
private PlayerPositionWatcher position = null;
private bool hasFoundDuration = false;
private Uri videoUri = null;
+ private VideoInfo videoInfo = null;
+
+ /* Constants */
+ public const float DefaultAspectRatio = 1.67f;
public Player (AspectFrame aspectFrame) {
this.frame = aspectFrame;
@@ -85,23 +90,23 @@ public class Player {
}
public bool HasVideoInfo {
- get { return playbin.VideoInfo != null; }
+ get { return videoInfo != null; }
}
public float AspectRatio {
- get { return playbin.VideoInfo.AspectRatio; }
+ get { return videoInfo.AspectRatio; }
}
public float FrameRate {
- get { return playbin.VideoInfo.FrameRate; }
+ get { return videoInfo.FrameRate; }
}
public bool HasAudio {
- get { return playbin.VideoInfo.HasAudio; }
+ get { return videoInfo.HasAudio; }
}
public bool HasVideo {
- get { return playbin.VideoInfo.HasVideo; }
+ get { return videoInfo.HasVideo; }
}
public Uri VideoUri {
@@ -124,6 +129,7 @@ public class Player {
videoUri = null;
hasFoundDuration = false;
+ videoInfo = null;
}
public void Play () {
@@ -204,7 +210,15 @@ public class Player {
private void OnPlaybinFoundVideoInfo (VideoInfoEventArgs args) {
Console.Error.WriteLine("Got video info: " + args.VideoInfo.ToString());
- frame.Ratio = args.VideoInfo.AspectRatio;
+ this.videoInfo = args.VideoInfo;
+
+ /* Set defaults if there is no video */
+ if (!videoInfo.HasVideo) {
+ videoInfo.FrameRate = SubtitleConstants.DefaultFrameRate;
+ videoInfo.AspectRatio = DefaultAspectRatio;
+ }
+
+ frame.Ratio = videoInfo.AspectRatio;
if (FoundVideoInfo != null)
FoundVideoInfo(args);
diff --git a/src/GnomeSubtitles/Ui/VideoPreview/Video.cs b/src/GnomeSubtitles/Ui/VideoPreview/Video.cs
index 4b63c21..0f085ca 100644
--- a/src/GnomeSubtitles/Ui/VideoPreview/Video.cs
+++ b/src/GnomeSubtitles/Ui/VideoPreview/Video.cs
@@ -118,7 +118,7 @@ public class Video {
/* Update the frame */
frame.Child.Hide();
frame.Child.Show();
- frame.Ratio = 1.67f;
+ frame.Ratio = Player.DefaultAspectRatio;
SilentDisablePlayPauseButton();
SetControlsSensitivity(false);
diff --git a/src/SubLib/Core/Domain/SubtitleConstants.cs b/src/SubLib/Core/Domain/SubtitleConstants.cs
index 922ac0d..09f349d 100644
--- a/src/SubLib/Core/Domain/SubtitleConstants.cs
+++ b/src/SubLib/Core/Domain/SubtitleConstants.cs
@@ -1,6 +1,6 @@
/*
* This file is part of SubLib.
- * Copyright (C) 2006-2008 Pedro Castro
+ * Copyright (C) 2006-2009 Pedro Castro
*
* SubLib is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -89,7 +89,8 @@ public class SubtitleConstants {
/// <summary>The maximum number of sentences that should be allowed per subtitle.</summary>
/// <remarks>The value of this property is 2.</remarks>
public const int MaxSentencesPerSubtitle = 2;
-
+
+ public const float DefaultFrameRate = 25;
}
}
\ No newline at end of file
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]