On Thu, Jun 30, 2011 at 10:17 AM, Mike Miller <mbmiller+l at gmail.com> wrote:
> On Wed, 29 Jun 2011, Donovan wrote:
>
>> We're doing some video encoding using FFMpeg and we're getting some videos
>> coming in that are rotated and would like to automatically detect the
>> rotation and flip them.  From what I've been able to research, there is a
>> rotation flag/variable in the files that say if it's rotated and to what
>> degree (ie: 90, 180, etc).  I can't for the life of me figure out how to
>> find this info.  I've tried using mplayer/midentify but it doesn't seem to
>> display anything.
>>
>> I know it can be done as processing the same videos through encoding.com
>> shows the rotation value but we're trying to roll our own solution. Hoping
>> somebody else has run into this.
>
>
> Are you familiar with exiftool?  It's a nice perl script that I have used
> often to work with metadata.  I have used it mostly with JPEG image files,
> but it can read, at least, data from all sorts of files.  Here' ssome info:
>
> http://www.sno.phy.queensu.ca/~phil/exiftool/exiftool_pod.html
>
> I have used it to change metadata in JPEG files and I would think that it
> can do that for some image formats.
>
> Regarding flipping -- I don't know anything about video, but with image
> files it is possible to do lossless rotation.  It is a little tricky to do
> it, though.  The code snippet below gives a clue on how I've been doing this
> with JPEG files.  Again, I'm not sure how it works with video data. I would
> think one would either have to rotate every frame to truly rotate the video.
>  If the problem is that the software is showing the wrong orientation
> because of some tag, the tag could be fixed, but this presumes that the
> software can rotate the video display.
>
> Mike
>
>
> # Perform lossless rotation of JPEGs preserving all EXIF data.  This
> # requires the exifautotran script and the C programs it calls --
> # jpegtran and jpegexiforient -- all written by someone else.  When
> # the Orientation tag is set incorrectly, this step will do nothing
> # and you will have to run the scripts "rotleft" and/or "rotright" (or
> # use other software) to achieve the desired lossless rotation.
>
> if [ $has_JPEG -gt 0 ]; then
>   exifautotran *.jpg
> fi
>
> # update the File Modification Date/Time EXIF field in all JPEG files
> # so that it is the same as in the Date/Time Original EXIF field
>
> if [ $has_JPEG -gt 0 ]; then
>   for file in $(ls -1 | grep -E '\.jpg$'); do
>      exiftool '-DateTimeOriginal>FileModifyDate' "${file}" > /dev/null
>   done
> fi
>
> _______________________________________________
> TCLUG Mailing List - Minneapolis/St. Paul, Minnesota
> tclug-list at mn-linux.org
> http://mailman.mn-linux.org/mailman/listinfo/tclug-list
>


This looks like it might do the trick.  I'm outsourcing the encoding
for now but I'll get back into trying to roll our encoding again
shortly so I'll have to give this a try.

Thanks for the tip!

-- 
Donovan Niesen