Changeset dfc8392cd3b2de84dc55e0f4dabf9de63e4d2a42
- Timestamp:
- 22/08/06 21:03:20
(2 years ago)
- Author:
- Gildas Bazin <gbazin@videolan.org>
- git-committer:
- Gildas Bazin <gbazin@videolan.org> 1156273400 +0000
- git-parent:
[834b64d0f742bf300b015afdfef91a5f3fa7382c]
- git-author:
- Gildas Bazin <gbazin@videolan.org> 1156273400 +0000
- Message:
* modules/codec/ffmpeg/mux.c: libavformat is much more happy with timestamps which start from 0.
-
Files:
-
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
| r63fa138 |
rdfc8392 |
|
| 60 | 60 | vlc_bool_t b_write_header; |
|---|
| 61 | 61 | vlc_bool_t b_error; |
|---|
| | 62 | |
|---|
| | 63 | int64_t i_initial_dts; |
|---|
| 62 | 64 | }; |
|---|
| 63 | 65 | |
|---|
| … | … | |
| 136 | 138 | p_sys->b_write_header = VLC_TRUE; |
|---|
| 137 | 139 | p_sys->b_error = VLC_FALSE; |
|---|
| | 140 | p_sys->i_initial_dts = 0; |
|---|
| 138 | 141 | |
|---|
| 139 | 142 | return VLC_SUCCESS; |
|---|
| … | … | |
| 288 | 291 | if( pi_stream ) *pi_stream = i_stream; |
|---|
| 289 | 292 | if( pi_dts ) *pi_dts = i_dts; |
|---|
| | 293 | if( !p_mux->p_sys->i_initial_dts ) p_mux->p_sys->i_initial_dts = i_dts; |
|---|
| 290 | 294 | return i_stream; |
|---|
| 291 | 295 | } |
|---|
| … | … | |
| 296 | 300 | block_t *p_data = block_FifoGet( p_input->p_fifo ); |
|---|
| 297 | 301 | int i_stream = *((int *)p_input->p_sys); |
|---|
| | 302 | AVStream *p_stream = p_sys->oc->streams[i_stream]; |
|---|
| 298 | 303 | AVPacket pkt = {0}; |
|---|
| 299 | 304 | |
|---|
| | 305 | av_init_packet(&pkt); |
|---|
| 300 | 306 | pkt.data = p_data->p_buffer; |
|---|
| 301 | 307 | pkt.size = p_data->i_buffer; |
|---|
| … | … | |
| 303 | 309 | |
|---|
| 304 | 310 | if( p_data->i_flags & BLOCK_FLAG_TYPE_I ) pkt.flags |= PKT_FLAG_KEY; |
|---|
| | 311 | |
|---|
| | 312 | /* avformat expects pts/dts which start from 0 */ |
|---|
| | 313 | p_data->i_dts -= p_mux->p_sys->i_initial_dts; |
|---|
| | 314 | p_data->i_pts -= p_mux->p_sys->i_initial_dts; |
|---|
| | 315 | |
|---|
| 305 | 316 | if( p_data->i_pts > 0 ) |
|---|
| 306 | | pkt.pts = p_data->i_pts * p_sys->oc->streams[i_stream]->time_base.den / |
|---|
| 307 | | I64C(1000000) / p_sys->oc->streams[i_stream]->time_base.num; |
|---|
| | 317 | pkt.pts = p_data->i_pts * p_stream->time_base.den / |
|---|
| | 318 | I64C(1000000) / p_stream->time_base.num; |
|---|
| 308 | 319 | if( p_data->i_dts > 0 ) |
|---|
| 309 | | pkt.dts = p_data->i_dts * p_sys->oc->streams[i_stream]->time_base.den / |
|---|
| 310 | | I64C(1000000) / p_sys->oc->streams[i_stream]->time_base.num; |
|---|
| | 320 | pkt.dts = p_data->i_dts * p_stream->time_base.den / |
|---|
| | 321 | I64C(1000000) / p_stream->time_base.num; |
|---|
| 311 | 322 | |
|---|
| 312 | 323 | if( av_write_frame( p_sys->oc, &pkt ) < 0 ) |
|---|
| … | … | |
| 315 | 326 | "(pkt pts: "I64Fd", dts: "I64Fd")", |
|---|
| 316 | 327 | p_data->i_pts, p_data->i_dts, pkt.pts, pkt.dts ); |
|---|
| | 328 | block_Release( p_data ); |
|---|
| 317 | 329 | return VLC_EGENERIC; |
|---|
| 318 | 330 | } |
|---|