[FFmpeg-user] Ffmpeg issues multiple HTTP requests when starting a video from a URL
Vladimir Grishchenko
vladgri at hotmail.com
Fri Jul 17 09:21:11 EEST 2020
A bit more details. I don't fully understand why 3 connections are necessary to begin the conversion. My best guess is ffmpeg detects some sort of inconsistency from the initial data and tries to confirm additional details by analyzing the end if the file.
First connection opened with Range: bytes=0-:
[https @ 000001faa550d840] [] header='HTTP/1.1 206 Partial Content'
....
[mov,mp4,m4a,3gp,3g2,mj2 @ 000001faa550d080] [debug] Format mov,mp4,m4a,3gp,3g2,mj2 probed with size=2048 and score=100
[mov,mp4,m4a,3gp,3g2,mj2 @ 000001faa550d080] [] type:'ftyp' parent:'root' sz: 32 8 9495632
[mov,mp4,m4a,3gp,3g2,mj2 @ 000001faa550d080] [debug] ISO: File Type Major Brand: isom
[mov,mp4,m4a,3gp,3g2,mj2 @ 000001faa550d080] [] type:'free' parent:'root' sz: 8 40 9495632
[mov,mp4,m4a,3gp,3g2,mj2 @ 000001faa550d080] [] type:'mdat' parent:'root' sz: 9468817 48 9495632
Then presumably the first connection is closed, and the second connection is opened with Range: bytes=9468857- header, this offset is close to the end of the file, and this output is generated:
[https @ 000001faa550d840] [] header='HTTP/1.1 206 Partial Content'
...
[mov,mp4,m4a,3gp,3g2,mj2 @ 000001faa550d080] [] type:'moov' parent:'root' sz: 26775 9468865 9495632
[mov,mp4,m4a,3gp,3g2,mj2 @ 000001faa550d080] [] type:'mvhd' parent:'moov' sz: 108 8 26767
[mov,mp4,m4a,3gp,3g2,mj2 @ 000001faa550d080] [] time scale = 1000
[mov,mp4,m4a,3gp,3g2,mj2 @ 000001faa550d080] [] type:'trak' parent:'moov' sz: 7933 116 26767
[mov,mp4,m4a,3gp,3g2,mj2 @ 000001faa550d080] [] type:'tkhd' parent:'trak' sz: 92 8 7925
[mov,mp4,m4a,3gp,3g2,mj2 @ 000001faa550d080] [] type:'edts' parent:'trak' sz: 36 100 7925
[mov,mp4,m4a,3gp,3g2,mj2 @ 000001faa550d080] [] type:'elst' parent:'edts' sz: 28 8 28
[mov,mp4,m4a,3gp,3g2,mj2 @ 000001faa550d080] [] track[0].edit_count = 1
[mov,mp4,m4a,3gp,3g2,mj2 @ 000001faa550d080] [] duration=30008 time=0 rate=1.000000
[mov,mp4,m4a,3gp,3g2,mj2 @ 000001faa550d080] [] type:'mdia' parent:'trak' sz: 7797 136 7925
[mov,mp4,m4a,3gp,3g2,mj2 @ 000001faa550d080] [] type:'mdhd' parent:'mdia' sz: 32 8 7789
[mov,mp4,m4a,3gp,3g2,mj2 @ 000001faa550d080] [] type:'hdlr' parent:'mdia' sz: 45 40 7789
[mov,mp4,m4a,3gp,3g2,mj2 @ 000001faa550d080] [] ctype=[0][0][0][0]
[mov,mp4,m4a,3gp,3g2,mj2 @ 000001faa550d080] [] stype=vide
[mov,mp4,m4a,3gp,3g2,mj2 @ 000001faa550d080] [] type:'minf' parent:'mdia' sz: 7712 85 7789
[mov,mp4,m4a,3gp,3g2,mj2 @ 000001faa550d080] [] type:'vmhd' parent:'minf' sz: 20 8 7704
[mov,mp4,m4a,3gp,3g2,mj2 @ 000001faa550d080] [] type:'dinf' parent:'minf' sz: 36 28 7704
[mov,mp4,m4a,3gp,3g2,mj2 @ 000001faa550d080] [] type:'dref' parent:'dinf' sz: 28 8 28
[mov,mp4,m4a,3gp,3g2,mj2 @ 000001faa550d080] [debug] Unknown dref type 0x206c7275 size 12
[mov,mp4,m4a,3gp,3g2,mj2 @ 000001faa550d080] [] type:'stbl' parent:'minf' sz: 7648 64 7704
[mov,mp4,m4a,3gp,3g2,mj2 @ 000001faa550d080] [] type:'stsd' parent:'stbl' sz: 176 8 7640
[mov,mp4,m4a,3gp,3g2,mj2 @ 000001faa550d080] [] size=160 4CC=avc1 codec_type=0
[mov,mp4,m4a,3gp,3g2,mj2 @ 000001faa550d080] [] type:'avcC' parent:'stsd' sz: 58 8 74
[mov,mp4,m4a,3gp,3g2,mj2 @ 000001faa550d080] [] type:'pasp' parent:'stsd' sz: 16 66 74
[mov,mp4,m4a,3gp,3g2,mj2 @ 000001faa550d080] [] type:'stts' parent:'stbl' sz: 32 184 7640
[mov,mp4,m4a,3gp,3g2,mj2 @ 000001faa550d080] [] track[0].stts.entries = 2
[mov,mp4,m4a,3gp,3g2,mj2 @ 000001faa550d080] [] sample_count=899, sample_duration=1001
[mov,mp4,m4a,3gp,3g2,mj2 @ 000001faa550d080] [] sample_count=1, sample_duration=341
[mov,mp4,m4a,3gp,3g2,mj2 @ 000001faa550d080] [] type:'stss' parent:'stbl' sz: 160 216 7640
[mov,mp4,m4a,3gp,3g2,mj2 @ 000001faa550d080] [] keyframe_count = 36
[mov,mp4,m4a,3gp,3g2,mj2 @ 000001faa550d080] [] type:'stsc' parent:'stbl' sz: 40 376 7640
[mov,mp4,m4a,3gp,3g2,mj2 @ 000001faa550d080] [] track[0].stsc.entries = 2
[mov,mp4,m4a,3gp,3g2,mj2 @ 000001faa550d080] [] type:'stsz' parent:'stbl' sz: 3620 416 7640
[mov,mp4,m4a,3gp,3g2,mj2 @ 000001faa550d080] [] sample_size = 0 sample_count = 900
[mov,mp4,m4a,3gp,3g2,mj2 @ 000001faa550d080] [] type:'stco' parent:'stbl' sz: 3612 4036 7640
[mov,mp4,m4a,3gp,3g2,mj2 @ 000001faa550d080] [] AVIndex stream 0, sample 0, offset 30, dts 0, size 76339, distance 0, keyframe 1
[mov,mp4,m4a,3gp,3g2,mj2 @ 000001faa550d080] [] AVIndex stream 0, sample 1, offset 12e25, dts 1001, size 1230, distance 1, keyframe 0
[mov,mp4,m4a,3gp,3g2,mj2 @ 000001faa550d080] [] AVIndex stream 0, sample 2, offset 134ec, dts 2002, size 1462, distance 2, keyframe 0
[mov,mp4,m4a,3gp,3g2,mj2 @ 000001faa550d080] [] AVIndex stream 0, sample 3, offset 13e90, dts 3003, size 2454, distance 3, keyframe 0
[mov,mp4,m4a,3gp,3g2,mj2 @ 000001faa550d080] [] AVIndex stream 0, sample 4, offset 14a5b, dts 4004, size 2478, distance 4, keyframe 0
[mov,mp4,m4a,3gp,3g2,mj2 @ 000001faa550d080] [] AVIndex stream 0, sample 5, offset 15849, dts 5005, size 2031, distance 5, keyframe 0
[mov,mp4,m4a,3gp,3g2,mj2 @ 000001faa550d080] [] AVIndex stream 0, sample 6, offset 1621e, dts 6006, size 5535, distance 6, keyframe 0
[mov,mp4,m4a,3gp,3g2,mj2 @ 000001faa550d080] [] AVIndex stream 0, sample 7, offset 17beb, dts 7007, size 2850, distance 7, keyframe 0
[mov,mp4,m4a,3gp,3g2,mj2 @ 000001faa550d080] [] AVIndex stream 0, sample 8, offset 18938, dts 8008, size 4666, distance 8, keyframe 0
[mov,mp4,m4a,3gp,3g2,mj2 @ 000001faa550d080] [] AVIndex stream 0, sample 9, offset 19d81, dts 9009, size 5106, distance 9, keyframe 0
....
[mov,mp4,m4a,3gp,3g2,mj2 @ 000001faa550d080] [debug] Processing st: 0, edit list 0 - media time: 0, duration: 900240
[mov,mp4,m4a,3gp,3g2,mj2 @ 000001faa550d080] [] type:'trak' parent:'moov' sz: 18628 8049 26767
[mov,mp4,m4a,3gp,3g2,mj2 @ 000001faa550d080] [] type:'tkhd' parent:'trak' sz: 92 8 18620
[mov,mp4,m4a,3gp,3g2,mj2 @ 000001faa550d080] [] type:'edts' parent:'trak' sz: 36 100 18620
[mov,mp4,m4a,3gp,3g2,mj2 @ 000001faa550d080] [] type:'elst' parent:'edts' sz: 28 8 28
[mov,mp4,m4a,3gp,3g2,mj2 @ 000001faa550d080] [] track[1].edit_count = 1
[mov,mp4,m4a,3gp,3g2,mj2 @ 000001faa550d080] [] duration=29954 time=0 rate=1.000000
[mov,mp4,m4a,3gp,3g2,mj2 @ 000001faa550d080] [] type:'mdia' parent:'trak' sz: 18492 136 18620
[mov,mp4,m4a,3gp,3g2,mj2 @ 000001faa550d080] [] type:'mdhd' parent:'mdia' sz: 32 8 18484
[mov,mp4,m4a,3gp,3g2,mj2 @ 000001faa550d080] [] type:'hdlr' parent:'mdia' sz: 45 40 18484
[mov,mp4,m4a,3gp,3g2,mj2 @ 000001faa550d080] [] ctype=[0][0][0][0]
[mov,mp4,m4a,3gp,3g2,mj2 @ 000001faa550d080] [] stype=soun
[mov,mp4,m4a,3gp,3g2,mj2 @ 000001faa550d080] [] type:'minf' parent:'mdia' sz: 18407 85 18484
[mov,mp4,m4a,3gp,3g2,mj2 @ 000001faa550d080] [] type:'smhd' parent:'minf' sz: 16 8 18399
[mov,mp4,m4a,3gp,3g2,mj2 @ 000001faa550d080] [] type:'dinf' parent:'minf' sz: 36 24 18399
[mov,mp4,m4a,3gp,3g2,mj2 @ 000001faa550d080] [] type:'dref' parent:'dinf' sz: 28 8 28
[mov,mp4,m4a,3gp,3g2,mj2 @ 000001faa550d080] [debug] Unknown dref type 0x206c7275 size 12
[mov,mp4,m4a,3gp,3g2,mj2 @ 000001faa550d080] [] type:'stbl' parent:'minf' sz: 18347 60 18399
[mov,mp4,m4a,3gp,3g2,mj2 @ 000001faa550d080] [] type:'stsd' parent:'stbl' sz: 103 8 18339
[mov,mp4,m4a,3gp,3g2,mj2 @ 000001faa550d080] [] size=87 4CC=mp4a codec_type=1
[mov,mp4,m4a,3gp,3g2,mj2 @ 000001faa550d080] [] audio channels 2
[mov,mp4,m4a,3gp,3g2,mj2 @ 000001faa550d080] [] version =0, isom =1
[mov,mp4,m4a,3gp,3g2,mj2 @ 000001faa550d080] [] type:'esds' parent:'stsd' sz: 51 8 51
[mov,mp4,m4a,3gp,3g2,mj2 @ 000001faa550d080] [] MPEG-4 description: tag=0x03 len=34
[mov,mp4,m4a,3gp,3g2,mj2 @ 000001faa550d080] [] MPEG-4 description: tag=0x04 len=20
[mov,mp4,m4a,3gp,3g2,mj2 @ 000001faa550d080] [] esds object type id 0x40
[mov,mp4,m4a,3gp,3g2,mj2 @ 000001faa550d080] [] MPEG-4 description: tag=0x05 len=2
[mov,mp4,m4a,3gp,3g2,mj2 @ 000001faa550d080] [] Specific MPEG-4 header len=2
[mov,mp4,m4a,3gp,3g2,mj2 @ 000001faa550d080] [] mp4a config channels 2 obj 2 ext obj 0 sample rate 44100 ext sample rate 0
[mov,mp4,m4a,3gp,3g2,mj2 @ 000001faa550d080] [] type:'stts' parent:'stbl' sz: 24 111 18339
[mov,mp4,m4a,3gp,3g2,mj2 @ 000001faa550d080] [] track[1].stts.entries = 1
[mov,mp4,m4a,3gp,3g2,mj2 @ 000001faa550d080] [] sample_count=1290, sample_duration=1024
[mov,mp4,m4a,3gp,3g2,mj2 @ 000001faa550d080] [] type:'stsc' parent:'stbl' sz: 9424 135 18339
[mov,mp4,m4a,3gp,3g2,mj2 @ 000001faa550d080] [] track[1].stsc.entries = 784
[mov,mp4,m4a,3gp,3g2,mj2 @ 000001faa550d080] [] type:'stsz' parent:'stbl' sz: 5180 9559 18339
[mov,mp4,m4a,3gp,3g2,mj2 @ 000001faa550d080] [] sample_size = 0 sample_count = 1290
[mov,mp4,m4a,3gp,3g2,mj2 @ 000001faa550d080] [] type:'stco' parent:'stbl' sz: 3608 14739 18339
[mov,mp4,m4a,3gp,3g2,mj2 @ 000001faa550d080] [] AVIndex stream 1, sample 0, offset 12a63, dts 0, size 472, distance 0, keyframe 1
[mov,mp4,m4a,3gp,3g2,mj2 @ 000001faa550d080] [] AVIndex stream 1, sample 1, offset 12c3b, dts 1024, size 490, distance 0, keyframe 1
[mov,mp4,m4a,3gp,3g2,mj2 @ 000001faa550d080] [] AVIndex stream 1, sample 2, offset 132f3, dts 2048, size 505, distance 0, keyframe 1
[mov,mp4,m4a,3gp,3g2,mj2 @ 000001faa550d080] [] AVIndex stream 1, sample 3, offset 13aa2, dts 3072, size 500, distance 0, keyframe 1
[mov,mp4,m4a,3gp,3g2,mj2 @ 000001faa550d080] [] AVIndex stream 1, sample 4, offset 13c96, dts 4096, size 506, distance 0, keyframe 1
[mov,mp4,m4a,3gp,3g2,mj2 @ 000001faa550d080] [] AVIndex stream 1, sample 5, offset 14826, dts 5120, size 565, distance 0, keyframe 1
[mov,mp4,m4a,3gp,3g2,mj2 @ 000001faa550d080] [] AVIndex stream 1, sample 6, offset 15409, dts 6144, size 564, distance 0, keyframe 1
....
[mov,mp4,m4a,3gp,3g2,mj2 @ 000001faa550d080] [debug] Processing st: 1, edit list 0 - media time: 0, duration: 1320971
[mov,mp4,m4a,3gp,3g2,mj2 @ 000001faa550d080] [] type:'udta' parent:'moov' sz: 98 26677 26767
[mov,mp4,m4a,3gp,3g2,mj2 @ 000001faa550d080] [] type:'meta' parent:'udta' sz: 90 8 90
[mov,mp4,m4a,3gp,3g2,mj2 @ 000001faa550d080] [] type:'hdlr' parent:'meta' sz: 33 8 78
[mov,mp4,m4a,3gp,3g2,mj2 @ 000001faa550d080] [] ctype=[0][0][0][0]
[mov,mp4,m4a,3gp,3g2,mj2 @ 000001faa550d080] [] stype=mdir
[mov,mp4,m4a,3gp,3g2,mj2 @ 000001faa550d080] [] type:'ilst' parent:'meta' sz: 45 41 78
[mov,mp4,m4a,3gp,3g2,mj2 @ 000001faa550d080] [] type:'[169]too' parent:'ilst' sz: 37 8 37
[mov,mp4,m4a,3gp,3g2,mj2 @ 000001faa550d080] [] on_parse_exit_offset=9495632
[mov,mp4,m4a,3gp,3g2,mj2 @ 000001faa550d080] [debug] Before avformat_find_stream_info() pos: 9495632 bytes read:43135 seeks:1 nb_streams:2
[h264 @ 000001faa5a04a00] [debug] nal_unit_type: 7(SPS), nal_ref_idc: 1
[h264 @ 000001faa5a04a00] [debug] nal_unit_type: 8(PPS), nal_ref_idc: 1
[mov,mp4,m4a,3gp,3g2,mj2 @ 000001faa550d080] [] stream 0, sample 0, dts 0
[mov,mp4,m4a,3gp,3g2,mj2 @ 000001faa550d080] [] stream 1, sample 0, dts 0
And finally the third connection is opened with Range: bytes=48- and the conversion starts, no additional connections are opened.
[https @ 000001faa550d840] [] header='HTTP/1.1 206 Partial Content'
...
[h264 @ 000001faa5a04a00] [debug] nal_unit_type: 6(SEI), nal_ref_idc: 0
[h264 @ 000001faa5a04a00] [debug] nal_unit_type: 5(IDR), nal_ref_idc: 1
[h264 @ 000001faa5a04a00] [debug] ct_type:0 pic_struct:0
[h264 @ 000001faa5a04a00] [debug] Format yuv420p chosen by get_format().
[h264 @ 000001faa5a04a00] [verbose] Reinit context to 1280x720, pix_fmt: yuv420p
[mov,mp4,m4a,3gp,3g2,mj2 @ 000001faa550d080] [] stream 0, sample 1, dts 33367
[mov,mp4,m4a,3gp,3g2,mj2 @ 000001faa550d080] [] stream 1, sample 0, dts 0
[mov,mp4,m4a,3gp,3g2,mj2 @ 000001faa550d080] [debug] All info found
[mov,mp4,m4a,3gp,3g2,mj2 @ 000001faa550d080] [] stream 0: start_time: 0.000 duration: 30.008
[mov,mp4,m4a,3gp,3g2,mj2 @ 000001faa550d080] [] stream 1: start_time: 0.000 duration: 29.954
[mov,mp4,m4a,3gp,3g2,mj2 @ 000001faa550d080] [] format: start_time: 0.000 duration: 30.008 bitrate=2531 kb/s
[mov,mp4,m4a,3gp,3g2,mj2 @ 000001faa550d080] [debug] After avformat_find_stream_info() pos: 76859 bytes read:129305 seeks:2 frames:2
[info] Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'https://host/file.mp4':
[info] Metadata:
[info] major_brand : isom
[info] minor_version : 512
[info] compatible_brands: isomiso2avc1mp41
[info] encoder : Lavf57.71.100
[info] Duration: 00:00:30.01, start: 0.000000, bitrate: 2531 kb/s
[info] Stream #0:0(und), 1, 1/30000: Video: h264 (Main) (avc1 / 0x31637661), yuv420p, 1280x720 [SAR 1:1 DAR 16:9], 2330 kb/s, 29.99 fps, 29.97 tbr, 30k tbn, 59.94 tbc (default)
[info] Metadata:
[info] handler_name : VideoHandler
[info] Stream #0:1(und), 1, 1/44100: Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 194 kb/s (default)
[info] Metadata:
[info] handler_name : SoundHandler
[debug] Successfully opened the file.
________________________________
From: ffmpeg-user <ffmpeg-user-bounces at ffmpeg.org> on behalf of Vladimir Grishchenko <vladgri at hotmail.com>
Sent: Thursday, July 16, 2020 5:04 PM
To: ffmpeg-user at ffmpeg.org <ffmpeg-user at ffmpeg.org>
Subject: [FFmpeg-user] Ffmpeg issues multiple HTTP requests when starting a video from a URL
I'm using ffmpeg to read an mp4 video from a HTTP URL and in some cases it issues up to 3 HTTP calls before it actually starts the conversion. There is no attempt to seek the video on the command line. The server returns HTTP/1.1 206 Partial Content initially and ffmpeg then tries to get data at different offsets before it prints "All info found" and proceeds with the conversion. Multiple connections cause an additional delay which I'd like to avoid no matter how small it is. Is there a mechanism to override this behavior and have ffmpeg to work with the data stream as it is being read? I'm using version 4.2.1. Thanks.
-Vlad
_______________________________________________
ffmpeg-user mailing list
ffmpeg-user at ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-user
To unsubscribe, visit link above, or email
ffmpeg-user-request at ffmpeg.org with subject "unsubscribe".
More information about the ffmpeg-user
mailing list