[FFmpeg-user] Fetching partial FLVs?

Chris Pennello chris at redux.com
Wed Mar 26 03:39:02 CET 2014


I'm using FFmpeg with fast seeking to try to fetch a partial FLV (a) quickly and (b) in a manner such that FFmpeg will be able to copy the streams out of it and do further transcoding, etc.  However, it still seems to be fetching more data than is necessary by several orders of magnitude.  For SD streams, the extra time spent fetching the superfluous data doesn't have a significant impact, although it would be nice to minimize.  But for HD streams, the impact is unacceptable.  Below is pasted a transcript of a run of FFmpeg.  You can see that after the first couple of brief fetches, it does a range request for almost 150MB of data, and then another for over 50MB, despite the fact that the final stream output is under 5MB.

Why is it fetching so much extra data?  Is there a way to get it to fetch the portion of the FLV more quickly?

Much appreciated,
Chris

% time ffmpeg -loglevel debug -ss 895.582 -i http://media-cdn.twitch.tv/store81.media62/archives/2013-7-25/live_user_speeddemosarchivesda_1374791611.flv -t 24.825 -c copy -y asdf.flv
ffmpeg version git-2013-11-05-04047b6 Copyright (c) 2000-2013 the FFmpeg developers
  built on Nov 26 2013 15:43:04 with gcc 4.6 (Ubuntu/Linaro 4.6.3-1ubuntu5)
  configuration: --prefix=/usr/local/src/ffmpeg_build --extra-cflags=-I/usr/local/src/ffmpeg_build/include --extra-ldflags=-L/usr/local/src/ffmpeg_build/lib --bindir=/usr/local/bin --extra-libs=-ldl --enable-gpl --enable-libass --enable-libfaac --enable-libfdk-aac --enable-libmp3lame --enable-libtheora --enable-libvorbis --enable-libvpx --enable-libx264 --enable-nonfree
  libavutil      52. 51.100 / 52. 51.100
  libavcodec     55. 41.100 / 55. 41.100
  libavformat    55. 21.100 / 55. 21.100
  libavdevice    55.  5.100 / 55.  5.100
  libavfilter     3. 90.101 /  3. 90.101
  libswscale      2.  5.101 /  2.  5.101
  libswresample   0. 17.104 /  0. 17.104
  libpostproc    52.  3.100 / 52.  3.100
Splitting the commandline.
Reading option '-loglevel' ... matched as option 'loglevel' (set logging level) with argument 'debug'.
Reading option '-ss' ... matched as option 'ss' (set the start time offset) with argument '895.582'.
Reading option '-i' ... matched as input file with argument 'http://media-cdn.twitch.tv/store81.media62/archives/2013-7-25/live_user_speeddemosarchivesda_1374791611.flv'.
Reading option '-t' ... matched as option 't' (record or transcode "duration" seconds of audio/video) with argument '24.825'.
Reading option '-c' ... matched as option 'c' (codec name) with argument 'copy'.
Reading option '-y' ... matched as option 'y' (overwrite output files) with argument '1'.
Reading option 'asdf.flv' ... matched as output file.
Finished splitting the commandline.
Parsing a group of options: global .
Applying option loglevel (set logging level) with argument debug.
Applying option y (overwrite output files) with argument 1.
Successfully parsed a group of options.
Parsing a group of options: input file http://media-cdn.twitch.tv/store81.media62/archives/2013-7-25/live_user_speeddemosarchivesda_1374791611.flv.
Applying option ss (set the start time offset) with argument 895.582.
Successfully parsed a group of options.
Opening an input file: http://media-cdn.twitch.tv/store81.media62/archives/2013-7-25/live_user_speeddemosarchivesda_1374791611.flv.
[http @ 0x32a6f00] request: GET /store81.media62/archives/2013-7-25/live_user_speeddemosarchivesda_1374791611.flv HTTP/1.1
User-Agent: Lavf/55.21.100
Accept: */*
Range: bytes=0-
Connection: close
Host: media-cdn.twitch.tv


[http @ 0x32a6f00] header='HTTP/1.1 206 Partial Content'
[http @ 0x32a6f00] http_code=206
[http @ 0x32a6f00] header='Cache-Control: max-age=2592000'
[http @ 0x32a6f00] header='Content-Type: video/x-flv'
[http @ 0x32a6f00] header='Last-Modified: Sun, 27 Oct 2013 22:09:26 GMT'
[http @ 0x32a6f00] header='Accept-Ranges: bytes,bytes'
[http @ 0x32a6f00] header='Server: nginx'
[http @ 0x32a6f00] header='Expires: Thu, 24 Apr 2014 23:15:58 GMT'
[http @ 0x32a6f00] header='Date: Wed, 26 Mar 2014 01:47:48 GMT'
[http @ 0x32a6f00] header='Content-Length: 147384426'
[http @ 0x32a6f00] header='Content-Range: bytes 0-147384425/147384426'
[http @ 0x32a6f00] header='Connection: close'
[http @ 0x32a6f00] header=''
[flv @ 0x32a6940] Format flv probed with size=2048 and score=100
[flv @ 0x32a6940] File position before avformat_find_stream_info() is 13
[flv @ 0x32a6940] Stream discovered after head already parsed
[http @ 0x32a6f00] request: GET /store81.media62/archives/2013-7-25/live_user_speeddemosarchivesda_1374791611.flv HTTP/1.1
User-Agent: Lavf/55.21.100
Accept: */*
Range: bytes=147384422-
Connection: close
Host: media-cdn.twitch.tv


[http @ 0x32a6f00] header='HTTP/1.1 206 Partial Content'
[http @ 0x32a6f00] http_code=206
[http @ 0x32a6f00] header='Cache-Control: max-age=2592000'
[http @ 0x32a6f00] header='Content-Type: video/x-flv'
[http @ 0x32a6f00] header='Last-Modified: Sun, 27 Oct 2013 22:09:26 GMT'
[http @ 0x32a6f00] header='Accept-Ranges: bytes,bytes'
[http @ 0x32a6f00] header='Server: nginx'
[http @ 0x32a6f00] header='Expires: Thu, 24 Apr 2014 23:15:58 GMT'
[http @ 0x32a6f00] header='Date: Wed, 26 Mar 2014 01:47:48 GMT'
[http @ 0x32a6f00] header='Content-Length: 4'
[http @ 0x32a6f00] header='Content-Range: bytes 147384422-147384425/147384426'
[http @ 0x32a6f00] header='Connection: close'
[http @ 0x32a6f00] header=''
[http @ 0x32a6f00] request: GET /store81.media62/archives/2013-7-25/live_user_speeddemosarchivesda_1374791611.flv HTTP/1.1
User-Agent: Lavf/55.21.100
Accept: */*
Range: bytes=147383960-
Connection: close
Host: media-cdn.twitch.tv


[http @ 0x32a6f00] header='HTTP/1.1 206 Partial Content'
[http @ 0x32a6f00] http_code=206
[http @ 0x32a6f00] header='Cache-Control: max-age=2592000'
[http @ 0x32a6f00] header='Content-Type: video/x-flv'
[http @ 0x32a6f00] header='Last-Modified: Sun, 27 Oct 2013 22:09:26 GMT'
[http @ 0x32a6f00] header='Accept-Ranges: bytes,bytes'
[http @ 0x32a6f00] header='Server: nginx'
[http @ 0x32a6f00] header='Expires: Thu, 24 Apr 2014 23:15:58 GMT'
[http @ 0x32a6f00] header='Date: Wed, 26 Mar 2014 01:47:48 GMT'
[http @ 0x32a6f00] header='Content-Length: 466'
[http @ 0x32a6f00] header='Content-Range: bytes 147383960-147384425/147384426'
[http @ 0x32a6f00] header='Connection: close'
[http @ 0x32a6f00] header=''
[http @ 0x32a6f00] request: GET /store81.media62/archives/2013-7-25/live_user_speeddemosarchivesda_1374791611.flv HTTP/1.1
User-Agent: Lavf/55.21.100
Accept: */*
Range: bytes=24-
Connection: close
Host: media-cdn.twitch.tv


[http @ 0x32a6f00] header='HTTP/1.1 206 Partial Content'
[http @ 0x32a6f00] http_code=206
[http @ 0x32a6f00] header='Cache-Control: max-age=2592000'
[http @ 0x32a6f00] header='Content-Type: video/x-flv'
[http @ 0x32a6f00] header='Last-Modified: Sun, 27 Oct 2013 22:09:26 GMT'
[http @ 0x32a6f00] header='Accept-Ranges: bytes,bytes'
[http @ 0x32a6f00] header='Server: nginx'
[http @ 0x32a6f00] header='Expires: Thu, 24 Apr 2014 23:15:58 GMT'
[http @ 0x32a6f00] header='Date: Wed, 26 Mar 2014 01:47:48 GMT'
[http @ 0x32a6f00] header='Content-Length: 147384402'
[http @ 0x32a6f00] header='Content-Range: bytes 24-147384425/147384426'
[http @ 0x32a6f00] header='Connection: close'
[http @ 0x32a6f00] header=''
[h264 @ 0x32ab700] no picture
[aac @ 0x32abec0] skip whole frame, skip left: 0
[flv @ 0x32a6940] All info found
rfps: 59.583333 0.018855
rfps: 59.666667 0.011118
rfps: 59.750000 0.005454
rfps: 59.833333 0.001862
rfps: 59.916667 0.000344
rfps: 60.000000 0.000899
    Last message repeated 1 times
rfps: 59.940060 0.000291
    Last message repeated 1 times
[flv @ 0x32a6940] File position after avformat_find_stream_info() is 122532
[http @ 0x32a6f00] request: GET /store81.media62/archives/2013-7-25/live_user_speeddemosarchivesda_1374791611.flv HTTP/1.1
User-Agent: Lavf/55.21.100
Accept: */*
Range: bytes=5132-
Connection: close
Host: media-cdn.twitch.tv


[http @ 0x32a6f00] header='HTTP/1.1 206 Partial Content'
[http @ 0x32a6f00] http_code=206
[http @ 0x32a6f00] header='Cache-Control: max-age=2592000'
[http @ 0x32a6f00] header='Content-Type: video/x-flv'
[http @ 0x32a6f00] header='Last-Modified: Sun, 27 Oct 2013 22:09:26 GMT'
[http @ 0x32a6f00] header='Accept-Ranges: bytes,bytes'
[http @ 0x32a6f00] header='Server: nginx'
[http @ 0x32a6f00] header='Expires: Thu, 24 Apr 2014 23:15:58 GMT'
[http @ 0x32a6f00] header='Date: Wed, 26 Mar 2014 01:47:48 GMT'
[http @ 0x32a6f00] header='Content-Length: 147379294'
[http @ 0x32a6f00] header='Content-Range: bytes 5132-147384425/147384426'
[http @ 0x32a6f00] header='Connection: close'
[http @ 0x32a6f00] header=''
[http @ 0x32a6f00] request: GET /store81.media62/archives/2013-7-25/live_user_speeddemosarchivesda_1374791611.flv HTTP/1.1
User-Agent: Lavf/55.21.100
Accept: */*
Range: bytes=96297954-
Connection: close
Host: media-cdn.twitch.tv


[http @ 0x32a6f00] header='HTTP/1.1 206 Partial Content'
[http @ 0x32a6f00] http_code=206
[http @ 0x32a6f00] header='Cache-Control: max-age=2592000'
[http @ 0x32a6f00] header='Content-Type: video/x-flv'
[http @ 0x32a6f00] header='Last-Modified: Sun, 27 Oct 2013 22:09:26 GMT'
[http @ 0x32a6f00] header='Accept-Ranges: bytes,bytes'
[http @ 0x32a6f00] header='Server: nginx'
[http @ 0x32a6f00] header='Expires: Thu, 24 Apr 2014 23:15:58 GMT'
[http @ 0x32a6f00] header='Date: Wed, 26 Mar 2014 01:50:23 GMT'
[http @ 0x32a6f00] header='Content-Length: 51086472'
[http @ 0x32a6f00] header='Content-Range: bytes 96297954-147384425/147384426'
[http @ 0x32a6f00] header='Connection: close'
[http @ 0x32a6f00] header=''
Input #0, flv, from 'http://media-cdn.twitch.tv/store81.media62/archives/2013-7-25/live_user_speeddemosarchivesda_1374791611.flv':
  Duration: 00:20:32.67, start: 0.000000, bitrate: 956 kb/s
    Stream #0:0, 41, 1/1000: Video: h264 (High), yuv420p, 1280x720, 83417/10000000, 59.94 tbr, 1k tbn, 119.88 tbc
    Stream #0:1, 57, 1/1000: Audio: aac, 44100 Hz, stereo, fltp
    Stream #0:2, 1, 1/1000: Data: none, 0/1
Successfully opened the file.
Parsing a group of options: output file asdf.flv.
Applying option t (record or transcode "duration" seconds of audio/video) with argument 24.825.
Applying option c (codec name) with argument copy.
Successfully parsed a group of options.
Opening an output file: asdf.flv.
Successfully opened the file.
Output #0, flv, to 'asdf.flv':
  Metadata:
    encoder         : Lavf55.21.100
    Stream #0:0, 0, 1/1000: Video: h264 ([7][0][0][0] / 0x0007), yuv420p, 1280x720, 1/1000, q=2-31, 1k tbn, 1k tbc
    Stream #0:1, 0, 1/1000: Audio: aac ([10][0][0][0] / 0x000A), 44100 Hz, stereo
Stream mapping:
  Stream #0:0 -> #0:0 (copy)
  Stream #0:1 -> #0:1 (copy)
Press [q] to stop, [?] for help
No more output streams to write to, finishing.
frame=  750 fps=0.0 q=-1.0 Lsize=    4285kB time=00:00:24.84 bitrate=1413.0kbits/s
video:3792kB audio:460kB subtitle:0 global headers:0kB muxing overhead 0.771462%
0 frames successfully decoded, 0 decoding errors
[AVIOContext @ 0x32ac6e0] Statistics: 3 seeks, 1828 writeouts
[AVIOContext @ 0x32b3360] Statistics: 102207166 bytes read, 5 seeks
ffmpeg -loglevel debug -ss 895.582 -i  -t 24.825 -c copy -y asdf.flv  0.40s user 0.56s system 0% cpu 2:35.95 total

% ls -l asdf.flv
-rw-rw-r-- 1 chris eng 4387923 Mar 25 18:50 asdf.flv


More information about the ffmpeg-user mailing list