pitivi / gst-editing-services

MIRROR of the GStreamer Editing Services repository for pull requests. The official git repository is at http://cgit.freedesktop.org/gstreamer/gst-editing-services/
Other
1 stars 1 forks source link

Timeline does not start when trying to encode with a audio/x-aac codec #40

Closed lubosz closed 11 years ago

lubosz commented 11 years ago

MKV h264 audio/x-vorbis works, but not with audio/x-aac

#!/usr/bin/python
from gi.repository import GES, Gst, Gtk, GstPbutils, GObject

import signal

outputFile = 'file:///home/bmonkey/workspace/ges/export/aacTest'

def handle_sigint(sig, frame):
    Gtk.main_quit()

def busMessageCb(bus, message):
    if message.type == Gst.MessageType.EOS:
        print("eos")
        Gtk.main_quit()
    elif message.type == Gst.MessageType.ERROR:
        print (message.parse_error())

def duration_querier(pipeline):
    print(pipeline.query_position(Gst.Format.TIME)[1] / Gst.SECOND)
    return True

def encoderProfile(container, video, audio):
  container_profile = GstPbutils.EncodingContainerProfile.new(
    "aac",
    "AAC Encoding Profile",
    Gst.Caps.new_empty_simple(container),
    None)

  video_profile = GstPbutils.EncodingVideoProfile.new(
    Gst.Caps.new_empty_simple(video),
    None,
    Gst.Caps.new_empty_simple("video/x-raw"),
    0)
  container_profile.add_profile(video_profile)

  audio_profile = GstPbutils.EncodingAudioProfile.new(
    Gst.Caps.new_empty_simple(audio),
    None,
    Gst.Caps.new_empty_simple("audio/x-raw"),
    0)
  container_profile.add_profile(audio_profile)

  return container_profile

if __name__ =="__main__":
  Gst.init(None)
  GES.init()

  timeline = GES.Timeline.new_audio_video()
  layer = GES.Layer()
  timeline.add_layer(layer)
  asset = GES.Asset.request(GES.TestClip, None)

  layer.add_asset(asset, 0 * Gst.SECOND, 0, 10 * Gst.SECOND, GES.TrackType.UNKNOWN)

  timeline.commit()

  pipeline = GES.TimelinePipeline()
  pipeline.add_timeline(timeline)

  # does not start, no error
  format = ["video/x-matroska", "video/x-h264", "audio/x-aac", "mkv"]

  # Works
  #format = ["video/x-matroska", "video/x-h264", "audio/x-vorbis", "mkv"]

  container_profile = encoderProfile(format[0], format[1], format[2])

  pipeline.set_render_settings(outputFile + "." + format[3], container_profile)
  pipeline.set_mode(GES.PipelineFlags.RENDER)
  pipeline.set_state(Gst.State.PLAYING)

  bus = pipeline.get_bus()
  bus.add_signal_watch()
  bus.connect("message", busMessageCb)
  GObject.timeout_add(300, duration_querier, pipeline)

  signal.signal(signal.SIGINT, handle_sigint)
  Gtk.main()
MathieuDuponchelle commented 11 years ago

https://github.com/pitivi/gst-editing-services/issues/41

lubosz commented 11 years ago

The caps for aac auto need to be created with:

Gst.Caps.from_string("audio/mpeg,mpegversion=4,stream-format=raw")

Then it works.