How do I encode and split longer videos into segments?

 

 
1. Add source via AddMediaBenchmark API call.
 
XML should reflect the following:
 
<?xml version="1.0"?>
<query>
  <userid>xxx</userid>
  <userkey>yyy</userkey>
  <action>AddMediaBenchmark</action>
  <source>http://domain.com/source/file/url</source>
</query>
 
2. Store Media ID returned by API for next 2 steps.
 
3. Get media duration by using GetMediaInfo call.
 
	<?xml version="1.0"?>
<query>
  <userid>xxx</userid>
  <userkey>yyy</userkey>
  <action>GetMediaInfo</action>
  <mediaid>3402153</mediaid>
</query>
 
API will return the following XML:
 
<?xml version="1.0" ?> 
<response>
<bitrate>518k</bitrate> 
<duration>723.09</duration> 
<audio_bitrate>256K</audio_bitrate> 
<audio_duration>1253</audio_duration> 
<video_duration>1253</video_duration> 
<video_codec>mpeg2video</video_codec> 
<frame_rate>29.97</frame_rate> 
<size>320x240</size> 
<video_bitrate>104857k</video_bitrate> 
<pixel_aspect_ratio>1:1</pixel_aspect_ratio> 
<display_aspect_ratio>4:3</display_aspect_ratio> 
<audio_codec>mp2</audio_codec> 
<audio_sample_rate>44100</audio_sample_rate> 
<audio_channels>2</audio_channels> 
<format>mpeg-ps</format> 
<format_profile>Main@Main</format_profile> 
<scan_type>Progressive</scan_type> 
</response>
 
Pay attention only the <video_duration>1253</video_duration> tag. 
Based on the video duration they should calculate how many segments they will have for given segment lenght. For this particular example and their segment lenght = 600s here will be 3 segments 600+600+53 seconds.
 
4. Update media and add formats based on calculated number of segments. 
 
<?xml version="1.0"?>
<query>
  <userid>xxx</userid>
  <userkey>yyy</userkey>
  <action>UpdateMedia</action>
  <mediaid>3402153</mediaid>
<format>
      <output>mp4</output>
      <start>0</start>
      <duration>600</duration>
</format>
<format>
      <output>mp4</output>
      <start>600</start>
      <duration>600</duration>
</format>
<format>
      <output>mp4</output>
      <start>1200</start>
      <duration>53</duration>
</format>
</query>
Important! You should add all formats by one UpdateMedia call.
 

 

1 Star2 Stars3 Stars4 Stars5 Stars (2 votes, average: 4.00 out of 5)
Loading ... Loading ...

edchelp