K-S-V / Scripts

Collection of my scripts
GNU General Public License v3.0
635 stars 226 forks source link

Update metadata of result FLV file #5

Closed dangerden closed 11 years ago

dangerden commented 11 years ago

Hi K-S-V,

Could you please add a total duration of video into resulting FLV file?

After recording a bunch of fragments it is unknown until the end of playback how long the video is.

There is a bunch of FLV metadata injectors which could be used after your script but probably your script is the best way to do it. As example here is one injector: http://www.buraks.com/flvmdi/

Thanks, Denis.

ghost commented 11 years ago

You might want to state what file(s) this issue applies to. Dont assume it is "common knowledge".

dangerden commented 11 years ago

AdobeHDS.php The resulting file is a concatenated set of f4f files but without duration and other significant metadata for video playback.

ghost commented 11 years ago

Also, and more importantly, I have not experienced this issue. Can give an example link, and ffmpeg -i as well if possible.

dangerden commented 11 years ago

Here is ffmpeg output of this file http://ge.tt/4cquB7Q/v/0?c

./ffmpeg -i ./7a1ce1234b5ac025329a716dc48d6756.flv ffmpeg version 1.0 Copyright (c) 2000-2012 the FFmpeg developers built on Oct 1 2012 10:27:24 with llvm-gcc 4.2.1 (LLVM build 2336.11.00) configuration: --prefix=/Volumes/Ramdisk/sw --enable-gpl --enable-pthreads --enable-version3 --enable-libspeex --enable-libvpx --disable-decoder=libvpx --enable-libmp3lame --enable-libtheora --enable-libvorbis --enable-libx264 --enable-avfilter --enable-libopencore_amrwb --enable-libopencore_amrnb --enable-filters --enable-libgsm --arch=x86_64 --enable-runtime-cpudetect libavutil 51. 73.101 / 51. 73.101 libavcodec 54. 59.100 / 54. 59.100 libavformat 54. 29.104 / 54. 29.104 libavdevice 54. 2.101 / 54. 2.101 libavfilter 3. 17.100 / 3. 17.100 libswscale 2. 1.101 / 2. 1.101 libswresample 0. 15.100 / 0. 15.100 libpostproc 52. 0.100 / 52. 0.100 Input #0, flv, from './7a1ce1234b5ac025329a716dc48d6756.flv': Duration: 00:00:23.96, start: 0.033000, bitrate: 3563 kb/s Stream #0:0: Video: h264 (Main), yuv420p, 1024x576 [SAR 1:1 DAR 16:9], 25 tbr, 1k tbn, 50 tbc Stream #0:1: Audio: aac, 48000 Hz, stereo, s16

In Flash it is not possible to get duration property (it is not written into its metadata)

ghost commented 11 years ago

One, you have not provided a link to the video, as requested. Two, the link you did provide is broken. Side note, I downloaded a YouTube video, here is output for interested parties

$ ffmpeg -i videoplayback
Input #0, flv, from 'videoplayback':
  Metadata:
    starttime       : 0
    totalduration   : 106
    totaldatarate   : 309
    bytelength      : 4084868
    canseekontime   : true
    sourcedata      : B4A7DD6C4HH1351057469281154
    purl            :
    pmsg            :
  Duration: 00:01:45.72, start: 0.000000, bitrate: 309 kb/s
    Stream #0:0: Video: h264 (Main), yuv420p, 480x480, 179 kb/s, 25 tbr, 1k tbn,
 50 tbc
    Stream #0:1: Audio: aac, 44100 Hz, stereo, s16, 128 kb/s
dangerden commented 11 years ago

Your video file is much better. It contains metadata. I'm writing a video from DVR video stream if it makes sense.

Here is the link http://www.4shared.com/video/ZUUv5_rx/3e5ad2548a5e9e0c70413cba1c5648.html

./ffmpeg -i ./3e5ad2548a5e9e0c70413cba1c56488c-1.flv ffmpeg version 0.11.1 Copyright (c) 2000-2012 the FFmpeg developers built on Jun 9 2012 15:43:10 with llvm_gcc 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2336.9.00) configuration: --prefix=/Volumes/Ramdisk/sw --enable-gpl --enable-pthreads --enable-version3 --enable-libspeex --enable-libvpx --disable-decoder=libvpx --enable-libmp3lame --enable-libtheora --enable-libvorbis --enable-libx264 --enable-avfilter --enable-libopencore_amrwb --enable-libopencore_amrnb --enable-filters --arch=x86_64 --enable-runtime-cpudetect libavutil 51. 54.100 / 51. 54.100 libavcodec 54. 23.100 / 54. 23.100 libavformat 54. 6.100 / 54. 6.100 libavdevice 54. 0.100 / 54. 0.100 libavfilter 2. 77.100 / 2. 77.100 libswscale 2. 1.100 / 2. 1.100 libswresample 0. 15.100 / 0. 15.100 libpostproc 52. 0.100 / 52. 0.100 Input #0, flv, from './3e5ad2548a5e9e0c70413cba1c56488c-1.flv': Duration: 00:00:27.96, start: 0.012000, bitrate: 3079 kb/s Stream #0:0: Video: h264 (Main), yuv420p, 1024x576 [SAR 1:1 DAR 16:9], 25 tbr, 1k tbn, 50 tbc Stream #0:1: Audio: aac, 48000 Hz, stereo, s16 At least one output file must be specified

K-S-V commented 11 years ago

Script writes the metadata into output file except in following conditions.

  1. if stream is live then there is no known duration
  2. if start or duration switch is specified it invalidates the duration specified in manifest metadata

most players first check the metadata to get the duration. if it's not available then timestamp of last tag is used. so in above conditions avoiding metadata actually makes players detect duration correctly and display seek bar accordingly.

K-S-V commented 11 years ago

Also to alter the duration in metadata tag we need to include or write full AMF parser which IMO will be an overkill to make flash player happy.

dangerden commented 11 years ago

But not in Flash Player :-) Flash Player detects only injected metadata.

So, I have second scenario. I specify duration, but actual duration is set up according to concatenated fragments duration. Is it possible to add such a calculation into the script?

dangerden commented 11 years ago

Ok. Probably we will combine it with yamdi tool to embed metadata after concatenation.