tony2001 / ffmpeg-php

PHP extension for video editing, wrapping ffmpeg
GNU General Public License v2.0
84 stars 62 forks source link

Looks like your build is the best so... any way to figure out the orientation of the video #11

Open dathan opened 9 years ago

dathan commented 9 years ago

I am running into a problem where the video is taken in landscape mode, and picking a frame to make an image messes up the orientation of the image.

An example http://rocklivewests3-a.akamaihd.net/18357527/18321767_goi803evar8gzmolpth17i2jes79erme2q3j7bes.mp4

ffmpeg -i 18321767_goi803evar8gzmolpth17i2jes79erme2q3j7bes.mp4 -f ffmetadata Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '/Users/mikhail/Downloads/18321767_goi803evar8gzmolpth17i2jes79erme2q3j7bes.mp4': Metadata: major_brand : isom minor_version : 0 compatible_brands: isomiso2avc1 creation_time : 2014-12-16 14:54:34 Duration: 00:00:02.40, start: 0.000000, bitrate: 6588 kb/s Stream #0:0(eng): Video: h264 (Constrained Baseline) (avc1 / 0x31637661), yuv420p, 640x480, 7288 kb/s, SAR 65536:65536 DAR 4:3, 25.80 fps, 90k tbr, 90k tbn, 180k tbc (default) Metadata: rotate : 270 creation_time : 2014-12-16 14:54:32 Stream #0:1(eng): Audio: aac (mp4a / 0x6134706D), 48000 Hz, mono, fltp, 96 kb/s (default) Metadata: creation_time : 2014-12-16 14:54:32

The rotation is 270 and picking a frame

http://rocklivewests3-a.akamaihd.net/18357527/18321767_goi803evar8gzmolpth17i2jes79erme2q3j7bes.jpg

Produces A bad rotation.

I cannot read the metadata of the original mp4 file without shelling out? Is there an undocumented api for this?

Additionally producing the gdimage does not pass the exif orientation info.

    $mov = new \ffmpeg_movie($fileSource);
    $ff_frame = $mov->getFrame(3);
    if (!$ff_frame) {
        throw new \InvalidMovieException("Unable to pull the frame");
    }

    $gd_image = $ff_frame->toGDImage();

....

thus I cannot rotate the image.

Is there anyway to get the orientation info? Is there a way to pass orientation to the gd image?