summaryrefslogtreecommitdiff
path: root/libavformat/mux.c
diff options
context:
space:
mode:
authorLimin Wang <lance.lmwang@gmail.com>2020-04-21 23:35:24 +0800
committerLimin Wang <lance.lmwang@gmail.com>2020-05-07 07:12:24 +0800
commit96e5e6abb9851d7a26ba21703955d5826ac857c0 (patch)
tree67429da0ec084928b83cd6ca69f0cbfc9f04fcc0 /libavformat/mux.c
parent74aa332157b5098e0a2cfd43ae71febb755b9352 (diff)
avformat/mux: Set AV_PKT_FLAG_KEY for is_intra_only packet
The patch will make audio and subtitle packets be marked as AV_PKT_FLAG_KEY. For audio, it'll caused the audio sample to be sync sample. To verify ref/fate/movenc results: 1. Get the movenc test data [lmwang@vpn ffmpeg]$ libavformat/tests/movenc -w && mkdir -p audio_old && mv *.mp4 audio_old_ After applied the patch: [lmwang@vpn ffmpeg]$ make fate-movenc SAMPLES=../fate-suite [lmwang@vpn ffmpeg]$ libavformat/tests/movenc -w && mkdir -p audio_key && mv *.mp4 audio_key 2. Get l-smash and build boxdumper https://github.com/l-smash/l-smash.git 3. dump the box of crc change mp4 and diff -u [lmwang@vpn ffmpeg]$ ../l-smash/cli/boxdumper --box audio_key/non-empty-moov-no-elst.mp4 > audio_key/non-empty-moov-no-elst.log [lmwang@vpn ffmpeg]$ ../l-smash/cli/boxdumper --box audio_old/non-empty-moov-no-elst.mp4 > audio_old/non-empty-moov-no-elst.log [lmwang@vpn ffmpeg]$ diff -u audio_key/non-empty-moov-no-elst.log audio_old/non-empty-moov-no-elst.log - default_sample_flags = 0x02000000 - independent - sync sample + default_sample_flags = 0x01010000 + dependent + non-sync sample 4. have checked the change of crc are caused by default_sample_flags non-empty-moov.mp4, non-empty-moov-elst.mp4, non-empty-moov-no-elst.mp4, empty-moov.mp4, delay-moov-content.mp4, empty-moov-second-frag.mp4, empty-moov-second-frag-discont.mp4, delay-moov-second-frag-discont.mp4, delay-moov-elst-second-frag.mp4 etc 5 For subtitle, it'll effect for tests/ref/fate/binsub-movtextenc and tests/ref/fate/sub2video, that's expecting result for the subtitle is marked as keyframe. Below is the checking result of binsub-movtextenc: [lmwang@vpn ffmpeg]$ ./ffmpeg -i ../fate-suite/sub/MovText_capability_tester.mp4 -map 0 -scodec mov_text -f mp4 -flags +bitexact -fflags +bitexact -movflags frag_keyframe+empty_moov audio_key/binsub-movtextenc.mp4 [lmwang@vpn ffmpeg]$ ./ffmpeg -i ../fate-suite/sub/MovText_capability_tester.mp4 -map 0 -scodec mov_text -f mp4 -flags +bitexact -fflags +bitexact -movflags frag_keyframe+empty_moov audio_old/binsub-movtextenc.mp4 [lmwang@vpn ffmpeg]$../l-smash/cli/boxdumper audio_key/binsub-movtextenc.mp4 > audio_key/binsub-movtextenc.log [lmwang@vpn ffmpeg]$../l-smash/cli/boxdumper audio_old/binsub-movtextenc.mp4 > audio_old/binsub-movtextenc.log [lmwang@vpn ffmpeg]$ diff -u audio_key/binsub-movtextenc.log audio_old/binsub-movtextenc.log .... // the key difference is the flag for sync sample - flags = 0x000701 + flags = 0x000301 data-offset-present sample-duration-present sample-size-present - sample-flags-present sample_count = 6 - data_offset = 188 + data_offset = 164 sample[0] sample_duration = 1570000 sample_size = 21 - sample_flags = 0x02000000 - independent - sync sample - degradation_priority = 0 sample[1] sample_duration = 510000 sample_size = 2 - sample_flags = 0x01010000 - dependent - non-sync sample - degradation_priority = 0 sample[2] sample_duration = 1690000 sample_size = 9 - sample_flags = 0x02000000 - independent - sync sample - degradation_priority = 0 Suggested-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com> Suggested-by: Nicolas George <george@nsup.org> Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
Diffstat (limited to 'libavformat/mux.c')
-rw-r--r--libavformat/mux.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/libavformat/mux.c b/libavformat/mux.c
index 3d1f71ab1a..d9bf5d35ea 100644
--- a/libavformat/mux.c
+++ b/libavformat/mux.c
@@ -344,6 +344,8 @@ FF_ENABLE_DEPRECATION_WARNINGS
if (desc && desc->props & AV_CODEC_PROP_REORDER)
st->internal->reorder = 1;
+ st->internal->is_intra_only = ff_is_intra_only(par->codec_id);
+
if (of->codec_tag) {
if ( par->codec_tag
&& par->codec_id == AV_CODEC_ID_RAWVIDEO
@@ -760,6 +762,7 @@ static int check_packet(AVFormatContext *s, AVPacket *pkt)
static int prepare_input_packet(AVFormatContext *s, AVPacket *pkt)
{
int ret;
+ AVStream *st = s->streams[pkt->stream_index];
ret = check_packet(s, pkt);
if (ret < 0)
@@ -768,7 +771,6 @@ static int prepare_input_packet(AVFormatContext *s, AVPacket *pkt)
#if !FF_API_COMPUTE_PKT_FIELDS2 || !FF_API_LAVF_AVCTX
/* sanitize the timestamps */
if (!(s->oformat->flags & AVFMT_NOTIMESTAMPS)) {
- AVStream *st = s->streams[pkt->stream_index];
/* when there is no reordering (so dts is equal to pts), but
* only one of them is set, set the other as well */
@@ -805,6 +807,9 @@ static int prepare_input_packet(AVFormatContext *s, AVPacket *pkt)
}
}
#endif
+ /* update flags */
+ if (st->internal->is_intra_only)
+ pkt->flags |= AV_PKT_FLAG_KEY;
return 0;
}