Activity › Forums › Compression Techniques › Generate FLV “on the fly”: duration not set
-
Generate FLV “on the fly”: duration not set
Posted by Marcos Bori on May 17, 2011 at 8:13 pmHi,
I want to generate FLV files on the fly, as the user request them via web. Whe I get the request I call ffmpeg to generate the desired FLV file with the output to stdout (“-“).The problem I’m experiencing is that ffmpeg does not set the duration metadata to the final FLV file, so the player in the client side does not properly track the video position.
Is there any workaroud for this?
thanks!Marcos Bori replied 15 years, 2 months ago 2 Members · 3 Replies -
3 Replies
-
Marcos Bori
May 18, 2011 at 12:14 pmWhat I’m trying to do is to watermark the videos “on the fly” in my site, so I don’t need to store the watermarked ones.
I use PHP in the server side.I’m trying to do it calling ffmpeg:
1.-The user requests the video
2.-The server executes a PHP script to deliver it:
The PHP script calls ffmpeg using “passthru”. The command is something like:
ffmpeg -i original.flv -sameq -vf "movie='thewatermark.png' [logo],[in][logo] overlay=10:main_h/2-60 [out]" -f flv - 2>/tmp/ffmpeg.log
Two problems arise:
1.-The “Duration” metadata is not properly set by ffmpeg when outputting to stdout. This implies flash video player (flowplayer in my case) can’t handle seek features.2.-When executing the ffmpeg command from PHP I get an error: When I execute the ffmpeg command manually in the server, it generates the final video correctly, but when executed from within the PHP script, after some seconds generating the video, the following error arises:
av_interleaved_write_frame(): Operation not permitted
If I decrease the quality (removing the -sameq parameter) of the resulting video, it is executed without this error. It seems there’s some kind of limitation executing it from PHP, but I can’t figure it out (I’ve increased the memory and time limits with no results).
Any idea?
thanks! -
Michael Rampe
May 24, 2011 at 10:17 pm[Marcos Bori] “The “Duration” metadata is not properly set by ffmpeg when outputting to stdout. “
FFmpeg cannot give the duration because it is encoding with passthrough… therefore it has no idea what the final duration will be until it is finished.
[Marcos Bori] “If I decrease the quality (removing the -sameq parameter) of the resulting video, it is executed without this error. “
This seems to be an issue with the encoder not being able to keep up in realtime using the -sameq flag. If you really need -sameq, try to drop the framesize or framerate. Otherwise, work at a lower quality so the encoder can work in realtime.
Michael
-
Marcos Bori
May 25, 2011 at 9:14 amThank you for your answer, Michael.
What I’m trying to do with ffmpeg is, whenever a user requests for a video in my web site, to take that video and dynamically add a watermark on it and deliver it to the user.
Therefore, I know the final duration of the resulting video. Is there any way in ffmpeg to tell it the final duration of the video beforehand, so it sets the duration metadata in the final video, even using ‘passthrough’?I need the timing information in the resulting video so that the video player in the client’s browser can seek using the control bar.
Thanks!
Reply to this Discussion! Login or Sign Up