mirror of
https://git.ffmpeg.org/ffmpeg.git
synced 2024-12-28 10:22:10 +00:00
889a022cce
Current code tracks min/max pts for each stream separately; then when the file ends it combines them with last frame's duration to compute the total duration of each stream; finally it selects the longest of those durations as the file duration. This is incorrect - the total file duration is the largest timestamp difference between any frames, regardless of the stream. Also change the way the last frame information is reported from decoders to the muxer - previously it would be just the last frame's duration, now the end timestamp is sent, which is simpler. Changes the result of the fate-ffmpeg-streamloop-transcode-av test, where the timestamps are shifted slightly forward. Note that the matroska demuxer does not return the first audio packet after seeking (due to buggy interaction betwen the generic code and the demuxer), so there is a gap in audio.
57 lines
1.6 KiB
C
57 lines
1.6 KiB
C
/*
|
|
* This file is part of FFmpeg.
|
|
*
|
|
* FFmpeg is free software; you can redistribute it and/or
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
* License as published by the Free Software Foundation; either
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
*
|
|
* FFmpeg is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
* Lesser General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
* License along with FFmpeg; if not, write to the Free Software
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
*/
|
|
|
|
#ifndef FFTOOLS_FFMPEG_UTILS_H
|
|
#define FFTOOLS_FFMPEG_UTILS_H
|
|
|
|
#include <stdint.h>
|
|
|
|
#include "libavutil/common.h"
|
|
#include "libavutil/frame.h"
|
|
#include "libavutil/rational.h"
|
|
|
|
#include "libavcodec/packet.h"
|
|
|
|
typedef struct Timestamp {
|
|
int64_t ts;
|
|
AVRational tb;
|
|
} Timestamp;
|
|
|
|
/**
|
|
* Merge two return codes - return one of the error codes if at least one of
|
|
* them was negative, 0 otherwise.
|
|
* Currently just picks the first one, eventually we might want to do something
|
|
* more sophisticated, like sorting them by priority.
|
|
*/
|
|
static inline int err_merge(int err0, int err1)
|
|
{
|
|
return (err0 < 0) ? err0 : FFMIN(err1, 0);
|
|
}
|
|
|
|
static inline void pkt_move(void *dst, void *src)
|
|
{
|
|
av_packet_move_ref(dst, src);
|
|
}
|
|
|
|
static inline void frame_move(void *dst, void *src)
|
|
{
|
|
av_frame_move_ref(dst, src);
|
|
}
|
|
|
|
#endif // FFTOOLS_FFMPEG_UTILS_H
|