Permalink
Browse files

Allow to have only audio or only video and change the muxer. Does not…

… work for now..
  • Loading branch information...
1 parent ef0eebb commit a26c1fe3951fbc167f231e28dbff28d9144b2193 @toots toots committed Nov 22, 2012
Showing with 48 additions and 21 deletions.
  1. +11 −8 src/encoder/encoder.ml
  2. +13 −5 src/encoder/gstreamer_encoder.ml
  3. +24 −8 src/lang/lang_encoders.ml
View
@@ -425,19 +425,20 @@ end
module GStreamer =
struct
type t = {
- channels : int;
- audio_pipeline : string option;
- video_pipeline : string option
+ channels : int;
+ audio : string option;
+ video : string option;
+ muxer : string option
}
let audio_channels m =
- if m.audio_pipeline = None then
+ if m.audio = None then
0
else
m.channels
let video_channels m =
- if m.video_pipeline = None then
+ if m.video = None then
0
else
1
@@ -452,9 +453,11 @@ struct
Printf.sprintf "%%gstreamer(%s)"
(String.concat ","
(pipeline
- (pipeline [Printf.sprintf "channels=%d" m.channels]
- "audio_pipeline" m.audio_pipeline)
- "video_pipeline" m.video_pipeline))
+ (pipeline
+ (pipeline [Printf.sprintf "channels=%d" m.channels]
+ "audio" m.audio)
+ "video" m.video)
+ "muxer" m.muxer))
end
module Theora =
@@ -55,24 +55,32 @@ let encoder id ext =
in
let gst =
+ let muxer = if ext.muxer <> None then "! muxer." else "" in
let audio_pipeline =
Stdlib.maybe (fun pipeline ->
- Printf.sprintf "%s ! queue ! %s ! %s ! muxer."
+ Printf.sprintf "%s ! queue ! %s ! %s %s"
(GU.Pipeline.audio_src ~channels ~block:true "audio_src")
(GU.Pipeline.convert_audio ())
- pipeline) ext.audio_pipeline
+ pipeline
+ muxer) ext.audio
in
let video_pipeline =
Stdlib.maybe (fun pipeline ->
- Printf.sprintf "%s ! queue ! %s ! %s ! muxer."
+ Printf.sprintf "%s ! queue ! %s ! %s %s"
(GU.Pipeline.video_src ~block:true "video_src")
(GU.Pipeline.convert_video ())
- pipeline) ext.video_pipeline
+ pipeline
+ muxer) ext.video
+ in
+ let muxer_pipeline = match ext.muxer with
+ | Some muxer -> Printf.sprintf "%s name=muxer" muxer
+ | None -> ""
in
let pipeline =
- Printf.sprintf "%s %s mpegtsmux name=muxer ! appsink name=sink sync=false emit-signals=true"
+ Printf.sprintf "%s %s %s ! appsink name=sink sync=false emit-signals=true"
(Stdlib.some_or "" audio_pipeline)
(Stdlib.some_or "" video_pipeline)
+ muxer_pipeline
in
let bin = Gstreamer.Pipeline.parse_launch pipeline in
let audio_src =
View
@@ -800,8 +800,9 @@ let mk_gstreamer params =
let defaults =
{ Encoder.GStreamer.
channels = 2;
- audio_pipeline = Some "lamemp3enc";
- video_pipeline = Some "x264enc"
+ audio = Some "lamemp3enc";
+ video = Some "x264enc";
+ muxer = Some "mpegtsmux"
}
in
let gstreamer =
@@ -814,12 +815,27 @@ let mk_gstreamer params =
function
| ("channels",{ term = Int i }) ->
{ f with Encoder.GStreamer.channels = i }
- | ("audio_pipeline",{ term = String s }) ->
- { f with Encoder.GStreamer.audio_pipeline = perhaps s }
- | ("video_pipeline",{ term = String s }) ->
- { f with Encoder.GStreamer.video_pipeline = perhaps s }
+ | ("audio",{ term = String s }) ->
+ { f with Encoder.GStreamer.audio = perhaps s }
+ | ("video",{ term = String s }) ->
+ { f with Encoder.GStreamer.video = perhaps s }
+ | ("muxer",{ term = String s }) ->
+ { f with Encoder.GStreamer.muxer = perhaps s }
| (_,t) -> raise (generic_error t))
defaults params
in
- mk (Encoder (Encoder.GStreamer gstreamer))
-
+ let ret = mk (Encoder (Encoder.GStreamer gstreamer)) in
+ if gstreamer.Encoder.GStreamer.audio <> None &&
+ gstreamer.Encoder.GStreamer.channels = 0
+ then
+ raise
+ (Error (ret, "Must have at least one audio channel when \
+ passing an audio pipeline!"));
+ if gstreamer.Encoder.GStreamer.video <> None &&
+ gstreamer.Encoder.GStreamer.audio <> None &&
+ gstreamer.Encoder.GStreamer.muxer = None
+ then
+ raise
+ (Error (ret, "Must have a muxer when passing an audio and \
+ a video pipeline!"));
+ ret

0 comments on commit a26c1fe

Please sign in to comment.