I'm trying to copy the video and audio streams from a partial FLV, and it's able to copy only the audio. I'd like to figure out how to get the video out as well. This partial FLV is one that I've downloaded from a server that supports "pseudo-streaming". Such a file can be played in a Flash player. For example, when the user seeks ahead of buffered data, the Flash program consults a table of the keyframe time indexes and corresponding byte offsets, originally read from the video's metadata, and provides a query-string parameter to a "pseudo-streaming"-compatible web server containing the desired byte offset. The web server then supplies not only the video data starting at that byte offset, but it also prepends a 13-byte header which seems to identify the data as an FLV video. I have parsed and consulted this list of keyframe time indexes and corresponding byte offsets in order to obtain the FLV I'm feeding into FFmpeg. How can I get FFmpeg to be able to read the video out of this partial FLV? Find several invocations below. Much appreciated, Chris % ffprobe tmp/rangetest2.flv ffprobe version 2.0.1-tessus Copyright (c) 2007-2013 the FFmpeg developers built on Aug 10 2013 21:25:56 with llvm-gcc 4.2.1 (LLVM build 2336.1.00) configuration: --prefix=/Users/tessus/data/ext/ffmpeg/sw --as=yasm --extra-version=tessus --disable-shared --enable-static --disable-ffplay --enable-gpl --enable-pthreads --enable-postproc --enable-libmp3lame --enable-libtheora --enable-libvorbis --enable-libx264 --enable-libxvid --enable-libspeex --enable-bzlib --enable-zlib --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libxavs --enable-version3 --enable-libvo-aacenc --enable-libvo-amrwbenc --enable-libvpx --enable-libgsm --enable-libopus --enable-fontconfig --enable-libfreetype --enable-libass --enable-libbluray --enable-filters --enable-runtime-cpudetect libavutil 52. 38.100 / 52. 38.100 libavcodec 55. 18.102 / 55. 18.102 libavformat 55. 12.100 / 55. 12.100 libavdevice 55. 3.100 / 55. 3.100 libavfilter 3. 79.101 / 3. 79.101 libswscale 2. 3.100 / 2. 3.100 libswresample 0. 17.102 / 0. 17.102 libpostproc 52. 3.100 / 52. 3.100 [h264 @ 0x102014600] no frame! Last message repeated 133 times [h264 @ 0x102014600] non-existing PPS 1 referenced [h264 @ 0x102014600] decode_slice_header error [h264 @ 0x102014600] no frame! Last message repeated 16 times [h264 @ 0x102014600] non-existing SPS 0 referenced in buffering period [h264 @ 0x102014600] no frame! [flv @ 0x10200c000] decoding for stream 0 failed [flv @ 0x10200c000] Could not find codec parameters for stream 0 (Video: h264): unspecified size Consider increasing the value for the 'analyzeduration' and 'probesize' options Input #0, flv, from 'tmp/rangetest2.flv': Duration: 00:20:32.23, start: 1218.614000, bitrate: 5 kb/s Stream #0:0: Video: h264, 30 tbr, 1k tbn, 2k tbc Stream #0:1: Audio: aac, 44100 Hz, mono, fltp % ffmpeg -i tmp/rangetest2.flv -vcodec copy -acodec copy tmp/rangetest2.mp4 ffmpeg version 2.0.1-tessus Copyright (c) 2000-2013 the FFmpeg developers built on Aug 10 2013 21:25:56 with llvm-gcc 4.2.1 (LLVM build 2336.1.00) configuration: --prefix=/Users/tessus/data/ext/ffmpeg/sw --as=yasm --extra-version=tessus --disable-shared --enable-static --disable-ffplay --enable-gpl --enable-pthreads --enable-postproc --enable-libmp3lame --enable-libtheora --enable-libvorbis --enable-libx264 --enable-libxvid --enable-libspeex --enable-bzlib --enable-zlib --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libxavs --enable-version3 --enable-libvo-aacenc --enable-libvo-amrwbenc --enable-libvpx --enable-libgsm --enable-libopus --enable-fontconfig --enable-libfreetype --enable-libass --enable-libbluray --enable-filters --enable-runtime-cpudetect libavutil 52. 38.100 / 52. 38.100 libavcodec 55. 18.102 / 55. 18.102 libavformat 55. 12.100 / 55. 12.100 libavdevice 55. 3.100 / 55. 3.100 libavfilter 3. 79.101 / 3. 79.101 libswscale 2. 3.100 / 2. 3.100 libswresample 0. 17.102 / 0. 17.102 libpostproc 52. 3.100 / 52. 3.100 [h264 @ 0x102020c00] no frame! Last message repeated 133 times [h264 @ 0x102020c00] non-existing PPS 1 referenced [h264 @ 0x102020c00] decode_slice_header error [h264 @ 0x102020c00] no frame! Last message repeated 16 times [h264 @ 0x102020c00] non-existing SPS 0 referenced in buffering period [h264 @ 0x102020c00] no frame! [flv @ 0x102018600] decoding for stream 0 failed [flv @ 0x102018600] Could not find codec parameters for stream 0 (Video: h264): unspecified size Consider increasing the value for the 'analyzeduration' and 'probesize' options Input #0, flv, from 'tmp/rangetest2.flv': Duration: 00:20:32.23, start: 1218.614000, bitrate: 5 kb/s Stream #0:0: Video: h264, 30 tbr, 1k tbn, 2k tbc Stream #0:1: Audio: aac, 44100 Hz, mono, fltp File 'tmp/rangetest2.mp4' already exists. Overwrite ? [y/N] y Output #0, mp4, to 'tmp/rangetest2.mp4': Metadata: encoder : Lavf55.12.100 Stream #0:0: Audio: aac ([64][0][0][0] / 0x0040), 44100 Hz, mono Stream mapping: Stream #0:1 -> #0:0 (copy) Press [q] to stop, [?] for help [flv @ 0x102018600] Stream discovered after head already parsed [flv @ 0x102018600] New data stream 0:2 at pos:757450 and DTS:1231.23s size= 134kB time=00:00:14.14 bitrate= 77.6kbits/s video:0kB audio:131kB subtitle:0 global headers:0kB muxing overhead 2.402472%
Chris Pennello <chris <at> redux.com> writes:
% ffmpeg -i tmp/rangetest2.flv -vcodec copy -acodec copy tmp/rangetest2.mp4 ffmpeg version 2.0.1-tessus
Please try current git head.
[flv <at> 0x102018600] Could not find codec parameters for stream 0 (Video: h264): unspecified size Consider increasing the value for the 'analyzeduration' and 'probesize' options
Did you try this? If there really is software that can play this sample but current FFmpeg cannot, please provide the file. Carl Eugen
On Mar 19, 2014, at 2:23 PM, Carl Eugen Hoyos <cehoyos@ag.or.at> wrote:
ffmpeg version 2.0.1-tessus
Please try current git head.
Unfortunately, git head doesn't compile on my system. I get the same problem as here: http://fate.ffmpeg.org/report.cgi?time=20140319091724&slot=x86_64-darwin-clang-apple-5.1 Thanks for pointing out that my version was behind the times. I've updated via `brew install ffmpeg` to 2.1.4. However, this didn't help matters. The behavior of FFmpeg is as before. See the invocation below.
[flv <at> 0x102018600] Could not find codec parameters for stream 0 (Video: h264): unspecified size Consider increasing the value for the 'analyzeduration' and 'probesize' options
Did you try this?
I hadn't; but given your comment, I did. The output of ffprobe improved slightly--it can see the third Data stream now; but it still fails to extract the video. The sample file I have is under a megabyte and ~14 seconds long, so the default values of analyzeduration and probesize probably already covered it. Nevertheless, I pasted an invocation below.
If there really is software that can play this sample but current FFmpeg cannot, please provide the file.
Sure; here it is. https://www.dropbox.com/s/sqthlxffdjhf764/rangetest2.flv Note, though, that Flash can't play this without already having loaded up the non-"pseudo-streaming" resource. That is, in the example I gave, when a user seeks ahead of the buffer, the Flash player has already started playback from the very beginning of the file. So presumably, there is some additional metadata that Flash is aware of that enables it to transition to successfully decoding this partial FLV. Perhaps my question should be: what is the character of that additional metadata, and how can I provide it to FFmpeg to enable it to extract the video stream in addition to the audio stream? Another attempt I tried was to pull all of the data from the FLV preceding the first frame of video (I consulted the table of keyframes, and used the byte offset of time index 0 to get this data): it's almost 4K. I then prepended this (presumably fuller) header to the partial FLV fetched, replacing its existing 13-byte FLV header returned by the "pseudo-streaming"-compatible web server. This produced all the same results, though. % ffmpeg -i tmp/rangetest2.flv -vcodec copy -acodec copy tmp/rangetest2.mp4 ffmpeg version 2.1.4 Copyright (c) 2000-2014 the FFmpeg developers built on Mar 2 2014 13:38:24 with Apple LLVM version 5.0 (clang-500.2.79) (based on LLVM 3.3svn) configuration: --prefix=/usr/local/Cellar/ffmpeg/2.1.4 --enable-shared --enable-pthreads --enable-gpl --enable-version3 --enable-nonfree --enable-hardcoded-tables --enable-avresample --enable-vda --cc=clang --host-cflags= --host-ldflags= --enable-libx264 --enable-libfaac --enable-libmp3lame --enable-libxvid libavutil 52. 48.101 / 52. 48.101 libavcodec 55. 39.101 / 55. 39.101 libavformat 55. 19.104 / 55. 19.104 libavdevice 55. 5.100 / 55. 5.100 libavfilter 3. 90.100 / 3. 90.100 libavresample 1. 1. 0 / 1. 1. 0 libswscale 2. 5.101 / 2. 5.101 libswresample 0. 17.104 / 0. 17.104 libpostproc 52. 3.100 / 52. 3.100 [h264 @ 0x7fe589024e00] no frame! Last message repeated 133 times [h264 @ 0x7fe589024e00] non-existing PPS 1 referenced [h264 @ 0x7fe589024e00] decode_slice_header error [h264 @ 0x7fe589024e00] no frame! Last message repeated 16 times [h264 @ 0x7fe589024e00] SEI type 79 size 1104 truncated at 359 [h264 @ 0x7fe589024e00] no frame! [flv @ 0x7fe589004a00] decoding for stream 0 failed [flv @ 0x7fe589004a00] Could not find codec parameters for stream 0 (Video: h264): unspecified size Consider increasing the value for the 'analyzeduration' and 'probesize' options Input #0, flv, from 'tmp/rangetest2.flv': Duration: 00:20:32.23, start: 1218.614000, bitrate: 5 kb/s Stream #0:0: Video: h264, 30 tbr, 1k tbn, 2k tbc Stream #0:1: Audio: aac, 44100 Hz, mono, fltp File 'tmp/rangetest2.mp4' already exists. Overwrite ? [y/N] y Output #0, mp4, to 'tmp/rangetest2.mp4': Metadata: encoder : Lavf55.19.104 Stream #0:0: Audio: aac ([64][0][0][0] / 0x0040), 44100 Hz, mono Stream mapping: Stream #0:1 -> #0:0 (copy) Press [q] to stop, [?] for help [flv @ 0x7fe589004a00] Stream discovered after head already parsed [flv @ 0x7fe589004a00] New data stream 0:2 at pos:757450 and DTS:1231.23s size= 134kB time=00:00:14.14 bitrate= 77.6kbits/s video:0kB audio:131kB subtitle:0 global headers:0kB muxing overhead 2.402472% % ffprobe -analyzeduration 14000000 -probesize 1000000 tmp/rangetest2.flv ffprobe version 2.1.4 Copyright (c) 2007-2014 the FFmpeg developers built on Mar 2 2014 13:38:24 with Apple LLVM version 5.0 (clang-500.2.79) (based on LLVM 3.3svn) configuration: --prefix=/usr/local/Cellar/ffmpeg/2.1.4 --enable-shared --enable-pthreads --enable-gpl --enable-version3 --enable-nonfree --enable-hardcoded-tables --enable-avresample --enable-vda --cc=clang --host-cflags= --host-ldflags= --enable-libx264 --enable-libfaac --enable-libmp3lame --enable-libxvid libavutil 52. 48.101 / 52. 48.101 libavcodec 55. 39.101 / 55. 39.101 libavformat 55. 19.104 / 55. 19.104 libavdevice 55. 5.100 / 55. 5.100 libavfilter 3. 90.100 / 3. 90.100 libavresample 1. 1. 0 / 1. 1. 0 libswscale 2. 5.101 / 2. 5.101 libswresample 0. 17.104 / 0. 17.104 libpostproc 52. 3.100 / 52. 3.100 [h264 @ 0x7fc8f3818800] no frame! Last message repeated 133 times [h264 @ 0x7fc8f3818800] non-existing PPS 1 referenced [h264 @ 0x7fc8f3818800] decode_slice_header error [h264 @ 0x7fc8f3818800] no frame! Last message repeated 16 times [h264 @ 0x7fc8f3818800] SEI type 79 size 1104 truncated at 359 [h264 @ 0x7fc8f3818800] no frame! Last message repeated 49 times [h264 @ 0x7fc8f3818800] non-existing PPS 15 referenced [h264 @ 0x7fc8f3818800] decode_slice_header error [h264 @ 0x7fc8f3818800] no frame! Last message repeated 31 times [h264 @ 0x7fc8f3818800] Partitioned H.264 support is incomplete [h264 @ 0x7fc8f3818800] no frame! Last message repeated 79 times [h264 @ 0x7fc8f3818800] SEI type 84 size 1304 truncated at 1286 [h264 @ 0x7fc8f3818800] no frame! Last message repeated 13 times [h264 @ 0x7fc8f3818800] non-existing PPS 0 referenced [h264 @ 0x7fc8f3818800] decode_slice_header error [h264 @ 0x7fc8f3818800] no frame! [h264 @ 0x7fc8f3818800] sps_id out of range [h264 @ 0x7fc8f3818800] no frame! Last message repeated 50 times [flv @ 0x7fc8f3804a00] Stream discovered after head already parsed [h264 @ 0x7fc8f3818800] no frame! Last message repeated 11 times [h264 @ 0x7fc8f3818800] Partitioned H.264 support is incomplete [h264 @ 0x7fc8f3818800] no frame! Last message repeated 15 times [h264 @ 0x7fc8f3818800] slice type too large (24) at 0 0 [h264 @ 0x7fc8f3818800] decode_slice_header error [h264 @ 0x7fc8f3818800] no frame! Last message repeated 2 times [flv @ 0x7fc8f3804a00] decoding for stream 0 failed [flv @ 0x7fc8f3804a00] Could not find codec parameters for stream 0 (Video: h264): unspecified size Consider increasing the value for the 'analyzeduration' and 'probesize' options Input #0, flv, from 'tmp/rangetest2.flv': Duration: 00:20:32.23, start: 1218.614000, bitrate: 5 kb/s Stream #0:0: Video: h264, 30 tbr, 1k tbn, 2k tbc Stream #0:1: Audio: aac, 44100 Hz, mono, fltp Stream #0:2: Data: none Unsupported codec with id 0 for input stream 2
Chris Pennello <chris <at> redux.com> writes:
Note, though, that Flash can't play this without already having loaded up the non-"pseudo-streaming" resource.
Meaning the global header which is needed for h264 decoding is missing from the file. I don't think there is anything you can do. Carl Eugen
On Mar 20, 2014, at 1:24 AM, Carl Eugen Hoyos <cehoyos@ag.or.at> wrote:
Chris Pennello <chris <at> redux.com> writes:
Note, though, that Flash can't play this without already having loaded up the non-"pseudo-streaming" resource.
Meaning the global header which is needed for h264 decoding is missing from the file. I don't think there is anything you can do.
Yeah, that's what I somewhat suspected. Neither Flash nor FFmpeg would play the file where I stitched together the global header with the partial FLV. It's too bad--it seems like it should be somehow possible given that Flash can play them after seeking ahead. In any case, the solution I ended up going with was to pull only the global header, read the keyframes, and then use the time indexes with fast seeking: -ss *preceding* the URL of the resource passed with -i. So I used FFmpeg to quickly pull the partial FLV in a way it could then parse instead of doing the partial fetch with Range headers, or by using the "pseudo-streaming" features of the web server.
participants (2)
-
Carl Eugen Hoyos -
Chris Pennello