W3C home > Mailing lists > Public > public-media-fragment@w3.org > March 2009

Re: Action 53 - Check whether ffmpeg can be used from clipping and cropping

From: Yves Lafon <ylafon@w3.org>
Date: Wed, 25 Mar 2009 13:43:14 -0400 (EDT)
To: Jack Jansen <Jack.Jansen@cwi.nl>
cc: Media Fragment <public-media-fragment@w3.org>
Message-ID: <Pine.LNX.4.64.0903251341360.28387@ubzre.j3.bet>
On Wed, 25 Mar 2009, Jack Jansen wrote:

> I've investigated using ffmpeg for clipping and cropping, and the results are 
> largely positive.
> Why positive:
> - ffmpeg can do temporal clipping

How? As the main issue is eing able to get the real time of the first and 
last frame, as they will be different than the requested second most of 
the time; and we really need that information.

> - ffmpeg can do spatial clipping
> - ffmpeg can do track selection
> - ffmpeg can usually[*] read from a pipe and write to a pipe (on 
> Unix/Linux/OSX), making it relatively easy to integrate.
> Why largely (as opposed to unqualified positive):
> - [*] reading from a pipe does not always work. For me, it worked for 
> ogg/vorbis/theora but not for mpeg-4/h264/aac.
> - the current ffmpeg (built from their subversion repository) appears to have 
> a glitch: some things I tried gave an error (such as unsupported conversion 
> or so) but re-running the exact same command would make it work.
> - using this still requires some knowledge of the media file, as can be seen 
> from the examples below[**]
> Here's how I configured an ffmpeg that could be used for cropping/clipping 
> both ogg/vorbis/theora and mpeg-4/h264/aac
> - Build and install libfaad, libfaac, libx64, libogg, libvorbis, libtheora 
> (or make sure they're available, or fix the configure below, at the expense 
> of not being able to do both formats)
> - Configure ffmpeg with
> 	./configure --enable-gpl --enable-libfaad --enable-libx264 
> --enable-libvorbis --enable-libtheora
> Here's how to use it. I'm using the examples from our "existing technology" 
> wikipage, creating a temporal clip from 12.3s to 21.16s, and a spatial crop 
> to l=25%, t=25%, w=50%, h=50%:
> Simplest, copy file-to-file, do a temporal clip
> 	ffmpeg -i fragf2f.ogv -ss 12.3 -t 8.86 fragf2f-clipped.ogv
> Same, but using pipes for input/output
> 	cat fragf2f.ogv | ./ffmpeg -i - -ss 12.3 -t 8.86 -acodec libvorbis 
> -f ogg - > fragf2f-clipped.ogv
> Same, but also do spatial cropping:
> 	cat fragf2f.ogv | ./ffmpeg -i - -ss 12.3 -t 8.86 -acodec libvorbis 
> -croptop 120 -cropbottom 120 -cropleft 160 -cropright 160 -f ogg - > 
> fragf2f-clipped-cropped.ogv
> Same, selecting only video stream:
> 	cat fragf2f.ogv | ./ffmpeg -i - -ss 12.3 -t 8.86 -an -croptop 120 
> -cropbottom 120 -cropleft 160 -cropright 160 -f ogg - > 
> fragf2f-clipped-cropped-vidonly.ogv
> [**] As you can see from these examples, code using ffmpeg to do clipping and 
> cropping will still need some knowledge of the media. For example, the 
> -cropXXX parameters cannot be computed from our media fragment without 
> knowing the native video size. Also, parameters like "-acodec libvorbis" and 
> "-f ogg" depend on the source/destination media format. Also,
> the video stream selection example depends on knowing there's only one audio 
> stream and one video stream in the source material.
> There's also an options to specify times in hh:mm:ss format, but I don't 
> think it's frame-accurate, I haven't investigated fully.
> All in all, if you would want to use this in a production system there would 
> still be a lot of things that would need more investigation, but for the 
> proof-of-concept implementations we're thinking of ffmpeg should be good 
> enough.
> --
> Jack Jansen, <Jack.Jansen@cwi.nl>, http://www.cwi.nl/~jack
> If I can't dance I don't want to be part of your revolution -- Emma Goldman

Baroula que barouleras, au tiéu toujou t'entourneras.

Received on Wednesday, 25 March 2009 17:43:25 UTC

This archive was generated by hypermail 2.4.0 : Friday, 17 January 2020 16:27:42 UTC