g_object_class_install_property (gobject_class, PROP_MULTIPASS_CACHE_FILE,
g_param_spec_string ("multipass-cache-file", "Multipass Cache File",
- "Multipass cache file",
+ "Multipass cache file. "
+ "If stream caps reinited, multiple files will be created: "
+ "file, file.1, file.2, ... and so on.",
DEFAULT_MULTIPASS_CACHE_FILE,
(GParamFlags) (G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)));
gst_vp9_enc->cfg.kf_mode = DEFAULT_KF_MODE;
gst_vp9_enc->cfg.kf_max_dist = DEFAULT_KF_MAX_DIST;
gst_vp9_enc->cfg.g_pass = DEFAULT_MULTIPASS_MODE;
- gst_vp9_enc->multipass_cache_file = g_strdup (DEFAULT_MULTIPASS_CACHE_FILE);
+ gst_vp9_enc->multipass_cache_prefix = g_strdup (DEFAULT_MULTIPASS_CACHE_FILE);
+ gst_vp9_enc->multipass_cache_file = NULL;
+ gst_vp9_enc->multipass_cache_idx = 0;
gst_vp9_enc->cfg.ts_number_layers = DEFAULT_TS_NUMBER_LAYERS;
gst_vp9_enc->n_ts_target_bitrate = 0;
gst_vp9_enc->n_ts_rate_decimator = 0;
g_return_if_fail (GST_IS_VP9_ENC (object));
gst_vp9_enc = GST_VP9_ENC (object);
+ g_free (gst_vp9_enc->multipass_cache_prefix);
g_free (gst_vp9_enc->multipass_cache_file);
- gst_vp9_enc->multipass_cache_file = NULL;
+ gst_vp9_enc->multipass_cache_idx = 0;
if (gst_vp9_enc->input_state)
gst_video_codec_state_unref (gst_vp9_enc->input_state);
global = TRUE;
break;
case PROP_MULTIPASS_CACHE_FILE:
- if (gst_vp9_enc->multipass_cache_file)
- g_free (gst_vp9_enc->multipass_cache_file);
- gst_vp9_enc->multipass_cache_file = g_value_dup_string (value);
+ if (gst_vp9_enc->multipass_cache_prefix)
+ g_free (gst_vp9_enc->multipass_cache_prefix);
+ gst_vp9_enc->multipass_cache_prefix = g_value_dup_string (value);
break;
case PROP_TS_NUMBER_LAYERS:
gst_vp9_enc->cfg.ts_number_layers = g_value_get_int (value);
g_value_set_enum (value, gst_vp9_enc->cfg.g_pass);
break;
case PROP_MULTIPASS_CACHE_FILE:
- g_value_set_string (value, gst_vp9_enc->multipass_cache_file);
+ g_value_set_string (value, gst_vp9_enc->multipass_cache_prefix);
break;
case PROP_TS_NUMBER_LAYERS:
g_value_set_int (value, gst_vp9_enc->cfg.ts_number_layers);
g_mutex_lock (&encoder->encoder_lock);
vpx_codec_destroy (&encoder->encoder);
encoder->inited = FALSE;
+ encoder->multipass_cache_idx++;
} else {
g_mutex_lock (&encoder->encoder_lock);
}
encoder->cfg.g_timebase.den = 90000;
}
- if (encoder->cfg.g_pass == VPX_RC_FIRST_PASS) {
- if (encoder->first_pass_cache_content == NULL) {
- encoder->first_pass_cache_content = g_byte_array_sized_new (4096);
- }
- } else if (encoder->cfg.g_pass == VPX_RC_LAST_PASS) {
- GError *err = NULL;
-
- if (!encoder->multipass_cache_file) {
+ if (encoder->cfg.g_pass == VPX_RC_FIRST_PASS ||
+ encoder->cfg.g_pass == VPX_RC_LAST_PASS) {
+ if (!encoder->multipass_cache_prefix) {
GST_ELEMENT_ERROR (encoder, RESOURCE, OPEN_READ,
("No multipass cache file provided"), (NULL));
g_mutex_unlock (&encoder->encoder_lock);
return FALSE;
}
+ g_free (encoder->multipass_cache_file);
+
+ if (encoder->multipass_cache_idx > 0)
+ encoder->multipass_cache_file = g_strdup_printf ("%s.%u",
+ encoder->multipass_cache_prefix, encoder->multipass_cache_idx);
+ else
+ encoder->multipass_cache_file =
+ g_strdup (encoder->multipass_cache_prefix);
+ }
+
+ if (encoder->cfg.g_pass == VPX_RC_FIRST_PASS) {
+ if (encoder->first_pass_cache_content != NULL)
+ g_byte_array_free (encoder->first_pass_cache_content, TRUE);
+
+ encoder->first_pass_cache_content = g_byte_array_sized_new (4096);
+
+ } else if (encoder->cfg.g_pass == VPX_RC_LAST_PASS) {
+ GError *err = NULL;
+
if (encoder->cfg.rc_twopass_stats_in.buf != NULL) {
g_free (encoder->cfg.rc_twopass_stats_in.buf);
encoder->cfg.rc_twopass_stats_in.buf = NULL;