苦苦挣扎xmlstarlet缺少元素

时间:2017-09-25 15:40:42

标签: xml xmlstarlet

我尽力使用下面的命令找出xmlstarlet的错误。不过,我无法让它毫无错误地运行。

命令:

xmlstarlet edit \
   --update "//job/input/file_input/uri" \
   --value 's3://my_source' \
   --update "//job/output_group/file_group_settings/destination/uri" \
   --value 's3://my_destination' \
   --append "//job/input/file_input/uri" \
   --type elem --name "audio" --value "track_01" template.xml > new_file.xml

这是我的模板XML。

<?xml version="1.0" encoding="UTF-8"?>
<job href="/jobs/35932" version="2.10.0.44452">
  <input>
    <deblock_enable>Auto</deblock_enable>
    <deblock_strength>0</deblock_strength>
    <no_psi>false</no_psi>
    <order>1</order>
    <timecode_source>zerobased</timecode_source>
    <file_input>
      <certificate_file nil="true"/>
      <password>xxx</password>
      <uri>s3_source</uri>
      <username>xxx</username>
    </file_input>
    <name>input_1</name>
    <video_selector>
      <color_space>follow</color_space>
      <order>1</order>
      <program_id nil="true"/>
      <name>input_1_video_selector_0</name>
    </video_selector>
    <audio_selector>
      <default_selection>true</default_selection>
      <infer_external_filename>false</infer_external_filename>
      <order>1</order>
      <program_selection>1</program_selection>
      <selector_type>track</selector_type>
      <track>1, 2</track>
      <unwrap_smpte337>true</unwrap_smpte337>
      <name>input_1_audio_selector_0</name>
    </audio_selector>
  </input>
  <timecode_config>
    <require_initial_timecode>false</require_initial_timecode>
    <source>zerobased</source>
    <sync_threshold nil="true"/>
  </timecode_config>
  <ad_trigger>scte35_splice_insert</ad_trigger>
  <ad_avail_offset>0</ad_avail_offset>
  <priority>100</priority>
  <user_data></user_data>
  <avsync_enable>true</avsync_enable>
  <avsync_pad_trim_audio>true</avsync_pad_trim_audio>
  <stream_assembly>
    <name>stream_assembly_0</name>
    <video_description>
      <afd_signaling>None</afd_signaling>
      <anti_alias>true</anti_alias>
      <drop_frame_timecode>true</drop_frame_timecode>
      <fixed_afd nil="true"/>
      <force_cpu_encode>false</force_cpu_encode>
      <height>1080</height>
      <insert_color_metadata>false</insert_color_metadata>
      <respond_to_afd>None</respond_to_afd>
      <sharpness>50</sharpness>
      <stretch_to_output>false</stretch_to_output>
      <timecode_passthrough>false</timecode_passthrough>
      <vbi_passthrough>false</vbi_passthrough>
      <width>1920</width>
      <h264_settings>
        <adaptive_quantization>medium</adaptive_quantization>
        <bitrate>14000000</bitrate>
        <buf_fill_pct nil="true"/>
        <buf_size nil="true"/>
        <cabac>true</cabac>
        <flicker_reduction>off</flicker_reduction>
        <force_field_pictures>false</force_field_pictures>
        <framerate_denominator nil="true"/>
        <framerate_follow_source>true</framerate_follow_source>
        <framerate_numerator nil="true"/>
        <gop_b_reference>false</gop_b_reference>
        <gop_closed_cadence>1</gop_closed_cadence>
        <gop_markers>false</gop_markers>
        <gop_num_b_frames>2</gop_num_b_frames>
        <gop_size>50.0</gop_size>
        <gop_size_units>frames</gop_size_units>
        <interpolate_frc>false</interpolate_frc>
        <look_ahead_rate_control>medium</look_ahead_rate_control>
        <max_bitrate nil="true"/>
        <max_qp nil="true"/>
        <min_buf_occ nil="true"/>
        <min_i_interval>0</min_i_interval>
        <min_qp nil="true"/>
        <num_ref_frames>1</num_ref_frames>
        <par_denominator nil="true"/>
        <par_follow_source>true</par_follow_source>
        <par_numerator nil="true"/>
        <passes>1</passes>
        <qp nil="true"/>
        <repeat_pps>false</repeat_pps>
        <rp2027_syntax>false</rp2027_syntax>
        <scd>true</scd>
        <sei_timecode>false</sei_timecode>
        <slices>1</slices>
        <slow_pal>false</slow_pal>
        <softness nil="true"/>
        <svq>0</svq>
        <telecine>None</telecine>
        <level>4.1</level>
        <profile>High</profile>
        <rate_control_mode>CBR</rate_control_mode>
        <gop_mode>fixed</gop_mode>
        <interlace_mode>progressive</interlace_mode>
      </h264_settings>
      <selected_gpu nil="true"/>
      <codec>h.264</codec>
    </video_description>
    <audio_description>
      <audio_type>0</audio_type>
      <follow_input_audio_type>false</follow_input_audio_type>
      <follow_input_language_code>false</follow_input_language_code>
      <language_code>eng</language_code>
      <order>1</order>
      <stream_name nil="true"/>
      <timecode_passthrough>false</timecode_passthrough>
      <aac_settings>
        <ad_broadcaster_mix>false</ad_broadcaster_mix>
        <bitrate>192000</bitrate>
        <coding_mode>2_0</coding_mode>
        <latm_loas>false</latm_loas>
        <mpeg2>false</mpeg2>
        <sample_rate>48000</sample_rate>
        <profile>LC</profile>
        <rate_control_mode>CBR</rate_control_mode>
      </aac_settings>
      <codec>aac</codec>
      <audio_source_name>Audio Selector 1</audio_source_name>
    </audio_description>
  </stream_assembly>
  <output_group>
    <custom_name>file_group_4</custom_name>
    <name nil="true"/>
    <order>1</order>
    <file_group_settings>
      <rollover_interval nil="true"/>
      <destination>
        <password>xxx</password>
        <username>xxx</username>
        <uri>s3_destination</uri>
      </destination>
    </file_group_settings>
    <type>file_group_settings</type>
    <output>
      <description nil="true"/>
      <extension>mov</extension>
      <log_edit_points>false</log_edit_points>
      <name_modifier></name_modifier>
      <order>1</order>
      <mov_settings>
        <growing_reference>false</growing_reference>
        <include_clap>false</include_clap>
        <include_cslg>true</include_cslg>
        <omneon_padding>true</omneon_padding>
        <reference>self_contained</reference>
        <write_xdcam>false</write_xdcam>
      </mov_settings>
      <stream_assembly_name>stream_assembly_0</stream_assembly_name>
      <container>mov</container>
    </output>
  </output_group>
</job>

以下是 xmlstarlet

生成的结果
<?xml version="1.0" encoding="UTF-8"?>
<job href="/jobs/35932" version="2.10.0.44452">
  <input>
    <deblock_enable>Auto</deblock_enable>
    <deblock_strength>0</deblock_strength>
    <no_psi>false</no_psi>
    <order>1</order>
    <timecode_source>zerobased</timecode_source>
    <file_input>
      <certificate_file nil="true"/>
      <password>xxx</password>
      <uri>s3://my_source</uri>
      <audio>track_01</audio>
      <username>xxx</username>
    </file_input>
    <name>input_1</name>
    <video_selector>
      <color_space>follow</color_space>
      <order>1</order>
      <program_id nil="true"/>
      <name>input_1_video_selector_0</name>
    </video_selector>
    <audio_selector>
      <default_selection>true</default_selection>
      <infer_external_filename>false</infer_external_filename>
      <order>1</order>
      <program_selection>1</program_selection>
      <selector_type>track</selector_type>
      <track>1, 2</track>
      <unwrap_smpte337>true</unwrap_smpte337>
      <name>input_1_audio_selector_0</name>
    </audio_selector>
  </input>
  <timecode_config>
    <require_initial_timecode>false</require_initial_timecode>
    <source>zerobased</source>
    <sync_threshold nil="true"/>
  </timecode_config>
  <ad_trigger>scte35_splice_insert</ad_trigger>
  <ad_avail_offset>0</ad_avail_offset>
  <priority>100</priority>
  <user_data/>
  <avsync_enable>true</avsync_enable>
  <avsync_pad_trim_audio>true</avsync_pad_trim_audio>
  <stream_assembly>
    <name>stream_assembly_0</name>
    <video_description>
      <afd_signaling>None</afd_signaling>
      <anti_alias>true</anti_alias>
      <drop_frame_timecode>true</drop_frame_timecode>
      <fixed_afd nil="true"/>
      <force_cpu_encode>false</force_cpu_encode>
      <height>1080</height>
      <insert_color_metadata>false</insert_color_metadata>
      <respond_to_afd>None</respond_to_afd>
      <sharpness>50</sharpness>
      <stretch_to_output>false</stretch_to_output>
      <timecode_passthrough>false</timecode_passthrough>
      <vbi_passthrough>false</vbi_passthrough>
      <width>1920</width>
      <h264_settings>
        <adaptive_quantization>medium</adaptive_quantization>
        <bitrate>14000000</bitrate>
        <buf_fill_pct nil="true"/>
        <buf_size nil="true"/>
        <cabac>true</cabac>
        <flicker_reduction>off</flicker_reduction>
        <force_field_pictures>false</force_field_pictures>
        <framerate_denominator nil="true"/>
        <framerate_follow_source>true</framerate_follow_source>
        <framerate_numerator nil="true"/>
        <gop_b_reference>false</gop_b_reference>
        <gop_closed_cadence>1</gop_closed_cadence>
        <gop_markers>false</gop_markers>
        <gop_num_b_frames>2</gop_num_b_frames>
        <gop_size>50.0</gop_size>
        <gop_size_units>frames</gop_size_units>
        <interpolate_frc>false</interpolate_frc>
        <look_ahead_rate_control>medium</look_ahead_rate_control>
        <max_bitrate nil="true"/>
        <max_qp nil="true"/>
        <min_buf_occ nil="true"/>
        <min_i_interval>0</min_i_interval>
        <min_qp nil="true"/>
        <num_ref_frames>1</num_ref_frames>
        <par_denominator nil="true"/>
        <par_follow_source>true</par_follow_source>
        <par_numerator nil="true"/>
        <passes>1</passes>
        <qp nil="true"/>
        <repeat_pps>false</repeat_pps>
        <rp2027_syntax>false</rp2027_syntax>
        <scd>true</scd>
        <sei_timecode>false</sei_timecode>
        <slices>1</slices>
        <slow_pal>false</slow_pal>
        <softness nil="true"/>
        <svq>0</svq>
        <telecine>None</telecine>
        <level>4.1</level>
        <profile>High</profile>
        <rate_control_mode>CBR</rate_control_mode>
        <gop_mode>fixed</gop_mode>
        <interlace_mode>progressive</interlace_mode>
      </h264_settings>
      <selected_gpu nil="true"/>
      <codec>h.264</codec>
    </video_description>
    <audio_description>
      <audio_type>0</audio_type>
      <follow_input_audio_type>false</follow_input_audio_type>
      <follow_input_language_code>false</follow_input_language_code>
      <language_code>eng</language_code>
      <order>1</order>
      <stream_name nil="true"/>
      <timecode_passthrough>false</timecode_passthrough>
      <aac_settings>
        <ad_broadcaster_mix>false</ad_broadcaster_mix>
        <bitrate>192000</bitrate>
        <coding_mode>2_0</coding_mode>
        <latm_loas>false</latm_loas>
        <mpeg2>false</mpeg2>
        <sample_rate>48000</sample_rate>
        <profile>LC</profile>
        <rate_control_mode>CBR</rate_control_mode>
      </aac_settings>
      <codec>aac</codec>
      <audio_source_name>Audio Selector 1</audio_source_name>
    </audio_description>
  </stream_assembly>
  <output_group>
    <custom_name>file_group_4</custom_name>
    <name nil="true"/>
    <order>1</order>
    <file_group_settings>
      <rollover_interval nil="true"/>
      <destination>
        <password>xxx</password>
        <username>xxx</username>
        <uri>s3://my_destination</uri>
      </destination>
    </file_group_settings>
    <type>file_group_settings</type>
    <output>
      <description nil="true"/>
      <extension>mov</extension>
      <log_edit_points>false</log_edit_points>
      <name_modifier/>
      <order>1</order>
      <mov_settings>
        <growing_reference>false</growing_reference>
        <include_clap>false</include_clap>
        <include_cslg>true</include_cslg>
        <omneon_padding>true</omneon_padding>
        <reference>self_contained</reference>
        <write_xdcam>false</write_xdcam>
      </mov_settings>
      <stream_assembly_name>stream_assembly_0</stream_assembly_name>
      <container>mov</container>
    </output>
  </output_group>
</job>

我使用diffchecker.com比较两个xmls。

<user_data><name_modifier>的开放元素缺失。

任何帮助都非常有价值。

非常感谢

0 个答案:

没有答案