Skip to content
This repository was archived by the owner on Mar 25, 2019. It is now read-only.

Commit 38b6090

Browse files
committed
Update README with segmenting job description
1 parent c2cafa0 commit 38b6090

1 file changed

Lines changed: 56 additions & 2 deletions

File tree

README.markdown

Lines changed: 56 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,9 @@ Parameters (HTTP POST data, should be valid JSON object):
134134
"size": "160x90",
135135
"format": "png"
136136
},
137+
"segments_options" : {
138+
"segment_time": 10
139+
},
137140
"callback_urls": ["http://example.com/notifications"]
138141
}
139142

@@ -143,6 +146,9 @@ Responses:
143146
* `400 Bad Request` - Invalid request (format)
144147
* `503 Service Unavailable` - Transcoder not accepting jobs at the moment (all encoding slots are in use)
145148

149+
150+
Required options are `source_file`, `destination_file` and `encoder_options`. Input and output files must be *absolute* paths.
151+
146152
The `callback_urls` array is optional and is a list (array) of HTTP endpoints that should be notified once encoding finishes (due to the job being complete or some error condition). The notification will sent using HTTP PUT to the specified endpoints with the job status. It will also include a custom HTTP header "X-Codem-Notify-Timestamp" that contains the timestamp (in milliseconds) at which the notification was generated and sent. It is best to observe this header to determine the order in which notifications are received at the other end due to network lag or other circumstances that may cause notifications to be received out of order.
147153

148154
The `thumbnail_options` object is optional and contains a set of thumbnails that should be encoded after the transcoding is complete. Thumbnails are captured from the source file for maximum quality. The options for thumbnails include:
@@ -159,7 +165,23 @@ The `thumbnail_options` object is optional and contains a set of thumbnails that
159165

160166
If you specify thumbnails but an error occurs during generation, your job will be marked as failed. If you don't specify a valid `seconds` or `percentages` option thumbnail generation will be skipped but the job can still be completed successfully.
161167

162-
All other options are required (`source_file`, `destination_file` and `encoder_options`). Input and output files must be *absolute* paths.
168+
The `segments_options` object is optional and contains segment time (duration) in seconds.
169+
Segmented videos are used in [HLS](https://en.wikipedia.org/wiki/HTTP_Live_Streaming).
170+
These options applied to encoded video, thus `encoder_options` are required.
171+
Moreover `encoder_options` should prepare video for segmenting, because bitstream
172+
filter [h264_mp4toannexb](https://www.ffmpeg.org/ffmpeg-bitstream-filters.html#h264_005fmp4toannexb) will be applied to the video.
173+
174+
The segmenting command looks like:
175+
```
176+
ffmpeg -i /tmp/46ee0a404a4b75d85c09d98a7c6b403579ee9f99.mp4 -codec copy -map 0 \
177+
-f segment -vbsf h264_mp4toannexb -flags -global_header -segment_format mpegts \
178+
-segment_list /path/to/dest_file_dir/dest_file_name.m3u8 -segment_time 10 \
179+
/path/to/dest_file_dir/dest_file_name-%06d.ts
180+
```
181+
182+
"46ee0a404a4b75d85c09d98a7c6b403579ee9f99.mp4" is a temporary encoded file which is not moved to destination folder yet.
183+
184+
163185

164186
### Thumbnail-only job
165187

@@ -259,6 +281,38 @@ Thumbnail-only job (160x90 in PNG format every 10% of the video).
259281

260282
Output: {"message":"The transcoder accepted your job.","job_id":"d4b1dfebe6860839b2c21b70f35938d870011682"}
261283

284+
285+
Segmenting job.
286+
287+
# curl -d '{"source_file": "/tmp/video.mp4", "destination_file": "/tmp/output/test.mp4", "encoder_options": "-vb 2000k -minrate 2000k -maxrate 2000k -bufsize 2000k -vf scale=min'(iw,1280)':-1 -s 1280x720 -acodec libfdk_aac -ab 192000 -ar 44100 -ac 2 -vcodec libx264 -movflags faststart -sn -r 29.97 -threads 0", "segments_options": {"segment_time": 10} }' http://localhost:8080/jobs
288+
289+
Output: {"message":"The transcoder accepted your job.","job_id":"7dc3c268783d7f3c737f3a134ccf1d4f15bb8442"}
290+
291+
Status of finished job:
292+
293+
# curl http://localhost:8080/jobs/7dc3c268783d7f3c737f3a134ccf1d4f15bb8442
294+
295+
```javascript
296+
Output:
297+
{
298+
"id": "7dc3c268783d7f3c737f3a134ccf1d4f15bb8442",
299+
"status": "success",
300+
"progress": 1,
301+
"duration": 1,
302+
"filesize": 783373,
303+
"message": "ffmpeg finished succesfully.",
304+
"playlist": "/tmp/output/test.m3u8",
305+
"segments": [
306+
"/tmp/output/test-000000.ts",
307+
"/tmp/output/test-000001.ts",
308+
"/tmp/output/test-000002.ts",
309+
"/tmp/output/test-000003.ts",
310+
"/tmp/output/test-000004.ts",
311+
"/tmp/output/test-000005.ts"
312+
]
313+
}
314+
```
315+
262316
## Issues and support
263317

264318
If you run into any issues while using codem-transcode please use the Github issue tracker to see if it is a known problem
@@ -269,4 +323,4 @@ commercial support or are already receiving commercial support, feel free to con
269323

270324
## License
271325

272-
Codem-transcode is released under the MIT license, see `LICENSE.txt`.
326+
Codem-transcode is released under the MIT license, see `LICENSE.txt`.

0 commit comments

Comments
 (0)