[FFmpeg-devel] [PATCH 3/5] concatdec: move duration calculating code to open_file
Nicolas George
george at nsup.org
Sun Oct 25 15:06:04 CET 2015
Le tridi 3 brumaire, an CCXXIV, Marton Balint a écrit :
> Signed-off-by: Marton Balint <cus at passwd.hu>
> ---
> libavformat/concatdec.c | 16 ++++++++--------
> 1 file changed, 8 insertions(+), 8 deletions(-)
>
> diff --git a/libavformat/concatdec.c b/libavformat/concatdec.c
> index 7686f28..f262d44 100644
> --- a/libavformat/concatdec.c
> +++ b/libavformat/concatdec.c
> @@ -316,6 +316,14 @@ static int open_file(AVFormatContext *avf, unsigned fileno)
> cat->files[fileno - 1].duration;
> file->file_start_time = (cat->avf->start_time == AV_NOPTS_VALUE) ? 0 : cat->avf->start_time;
> file->file_inpoint = (file->inpoint == AV_NOPTS_VALUE) ? file->file_start_time : file->inpoint;
> + if (file->duration == AV_NOPTS_VALUE) {
> + file->duration = cat->avf->duration;
> + if (file->inpoint != AV_NOPTS_VALUE)
> + file->duration -= (file->inpoint - file->file_start_time);
> + if (file->outpoint != AV_NOPTS_VALUE)
> + file->duration -= cat->avf->duration - (file->outpoint - file->file_start_time);
> + }
At this point, the file duration is not reliable, so unless I am mistaken
this change would produce wrong timestamps when stitching, for example, MP3
files without extra headers.
> +
> if ((ret = match_streams(avf)) < 0)
> return ret;
> if (file->inpoint != AV_NOPTS_VALUE) {
> @@ -469,14 +477,6 @@ static int open_next_file(AVFormatContext *avf)
> ConcatContext *cat = avf->priv_data;
> unsigned fileno = cat->cur_file - cat->files;
>
> - if (cat->cur_file->duration == AV_NOPTS_VALUE) {
> - cat->cur_file->duration = cat->avf->duration;
> - if (cat->cur_file->inpoint != AV_NOPTS_VALUE)
> - cat->cur_file->duration -= (cat->cur_file->inpoint - cat->cur_file->file_start_time);
> - if (cat->cur_file->outpoint != AV_NOPTS_VALUE)
> - cat->cur_file->duration -= cat->avf->duration - (cat->cur_file->outpoint - cat->cur_file->file_start_time);
> - }
> -
> if (++fileno >= cat->nb_files) {
> cat->eof = 1;
> return AVERROR_EOF;
Regards,
--
Nicolas George
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20151025/5953cd9c/attachment.sig>
More information about the ffmpeg-devel
mailing list