Interrogate MOV metadata for orientation of video so that software can determine if the video needs to be rotated for proper display. --- libavformat/isom.h | 1 + libavformat/mov.c | 5 +++++ 2 files changed, 6 insertions(+), 0 deletions(-) diff --git a/libavformat/isom.h b/libavformat/isom.h index 1df666f..dde1ba1 100644 --- a/libavformat/isom.h +++ b/libavformat/isom.h @@ -123,6 +123,7 @@ typedef struct MOVStreamContext { int width; ///< tkhd width int height; ///< tkhd height int dts_shift; ///< dts shift when ctts is negative + int rotation; ///< rotation 0 if normal, 180 if inverted } MOVStreamContext; typedef struct MOVContext { diff --git a/libavformat/mov.c b/libavformat/mov.c index e9435a9..7faa225 100644 --- a/libavformat/mov.c +++ b/libavformat/mov.c @@ -1907,6 +1907,11 @@ static int mov_read_tkhd(MOVContext *c, AVIOContext *pb, MOVAtom atom) sc->width = width >> 16; sc->height = height >> 16; + if(display_matrix[0][0] == -65536 && display_matrix[1][1] == -65536) { + sc->rotation = 180; + } + + // transform the display width/height according to the matrix // skip this if the display matrix is the default identity matrix // or if it is rotating the picture, ex iPhone 3GS
Hi Dave, On 03/26/2011 03:31 AM, Dave Badia wrote:
Interrogate MOV metadata for orientation of video so that software can determine if the video needs to be rotated for proper display. --- libavformat/isom.h | 1 + libavformat/mov.c | 5 +++++ 2 files changed, 6 insertions(+), 0 deletions(-)
diff --git a/libavformat/isom.h b/libavformat/isom.h index 1df666f..dde1ba1 100644 --- a/libavformat/isom.h +++ b/libavformat/isom.h @@ -123,6 +123,7 @@ typedef struct MOVStreamContext { int width; ///< tkhd width int height; ///< tkhd height int dts_shift; ///< dts shift when ctts is negative + int rotation; ///< rotation 0 if normal, 180 if inverted } MOVStreamContext;
typedef struct MOVContext { diff --git a/libavformat/mov.c b/libavformat/mov.c index e9435a9..7faa225 100644 --- a/libavformat/mov.c +++ b/libavformat/mov.c @@ -1907,6 +1907,11 @@ static int mov_read_tkhd(MOVContext *c, AVIOContext *pb, MOVAtom atom) sc->width = width >> 16; sc->height = height >> 16;
+ if(display_matrix[0][0] == -65536 && display_matrix[1][1] == -65536) { + sc->rotation = 180; + } + + // transform the display width/height according to the matrix // skip this if the display matrix is the default identity matrix // or if it is rotating the picture, ex iPhone 3GS
I'm not against this. You can export this information as metadata I think: use av_metadata_set with "rotate" on the AVStream, that way applications can retrieve it through the API. -- Baptiste COUDURIER Key fingerprint 8D77134D20CC9220201FC5DB0AC9325C5C1ABAAA FFmpeg maintainer http://www.ffmpeg.org
On Wed, Mar 30, 2011 at 11:18 AM, Baptiste Coudurier <baptiste.coudurier@gmail.com> wrote:
Hi Dave, <snip>
-- Baptiste COUDURIER Key fingerprint 8D77134D20CC9220201FC5DB0AC9325C5C1ABAAA FFmpeg maintainer http://www.ffmpeg.org _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Thanks for the feedback as I am very new to ffmpeg. I've revised my patch per you suggestions, hope I understood properly. Interrogate MOV metadata for orientation of video so that software can determine if the video needs to be rotated. --- libavformat/mov.c | 4 ++++ 1 files changed, 4 insertions(+), 0 deletions(-) diff --git a/libavformat/mov.c b/libavformat/mov.c index 23ba1d4..b12890f 100644 --- a/libavformat/mov.c +++ b/libavformat/mov.c @@ -1907,6 +1907,10 @@ static int mov_read_tkhd(MOVContext *c, AVIOContext *pb, MOVAtom atom) sc->width = width >> 16; sc->height = height >> 16; + if (display_matrix[0][0] == -65536 && display_matrix[1][1] == -65536) { + av_metadata_set2(&c->fc->metadata, "rotate", "180", 0); + } + // transform the display width/height according to the matrix // skip this if the display matrix is the default identity matrix // or if it is rotating the picture, ex iPhone 3GS
Hi Dave, On 04/05/2011 04:49 PM, Dave Badia wrote:
On Wed, Mar 30, 2011 at 11:18 AM, Baptiste Coudurier <baptiste.coudurier@gmail.com> wrote:
Hi Dave, <snip>
-- Baptiste COUDURIER Key fingerprint 8D77134D20CC9220201FC5DB0AC9325C5C1ABAAA FFmpeg maintainer http://www.ffmpeg.org _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Thanks for the feedback as I am very new to ffmpeg. I've revised my patch per you suggestions, hope I understood properly.
Interrogate MOV metadata for orientation of video so that software can determine if the video needs to be rotated. --- libavformat/mov.c | 4 ++++ 1 files changed, 4 insertions(+), 0 deletions(-)
diff --git a/libavformat/mov.c b/libavformat/mov.c index 23ba1d4..b12890f 100644 --- a/libavformat/mov.c +++ b/libavformat/mov.c @@ -1907,6 +1907,10 @@ static int mov_read_tkhd(MOVContext *c, AVIOContext *pb, MOVAtom atom) sc->width = width >> 16; sc->height = height >> 16;
+ if (display_matrix[0][0] == -65536 && display_matrix[1][1] == -65536) { + av_metadata_set2(&c->fc->metadata, "rotate", "180", 0); + }
Set the metadata on AVStream, not AVFormatContext. Are you sure that the check is 100% correct for the rotation ? -- Baptiste COUDURIER Key fingerprint 8D77134D20CC9220201FC5DB0AC9325C5C1ABAAA FFmpeg maintainer http://www.ffmpeg.org
On Tue, Apr 5, 2011 at 16:53, Baptiste Coudurier <baptiste.coudurier@gmail.com> wrote:
Hi Dave,
On 04/05/2011 04:49 PM, Dave Badia wrote:
On Wed, Mar 30, 2011 at 11:18 AM, Baptiste Coudurier <baptiste.coudurier@gmail.com> wrote:
Hi Dave, <snip>
-- Baptiste COUDURIER Key fingerprint 8D77134D20CC9220201FC5DB0AC9325C5C1ABAAA FFmpeg maintainer http://www.ffmpeg.org _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Thanks for the feedback as I am very new to ffmpeg. I've revised my patch per you suggestions, hope I understood properly.
Interrogate MOV metadata for orientation of video so that software can determine if the video needs to be rotated. --- libavformat/mov.c | 4 ++++ 1 files changed, 4 insertions(+), 0 deletions(-)
diff --git a/libavformat/mov.c b/libavformat/mov.c index 23ba1d4..b12890f 100644 --- a/libavformat/mov.c +++ b/libavformat/mov.c @@ -1907,6 +1907,10 @@ static int mov_read_tkhd(MOVContext *c, AVIOContext *pb, MOVAtom atom) sc->width = width >> 16; sc->height = height >> 16;
+ if (display_matrix[0][0] == -65536 && display_matrix[1][1] == -65536) { + av_metadata_set2(&c->fc->metadata, "rotate", "180", 0); + }
Set the metadata on AVStream, not AVFormatContext.
Are you sure that the check is 100% correct for the rotation ?
Couldn't this be more generically extracted as the acos of [0][0] then verified against [1][1]?
James Zern skrev 2011-04-06 02:50:
On Tue, Apr 5, 2011 at 16:53, Baptiste Coudurier <baptiste.coudurier@gmail.com> wrote:
Hi Dave,
On 04/05/2011 04:49 PM, Dave Badia wrote:
On Wed, Mar 30, 2011 at 11:18 AM, Baptiste Coudurier <baptiste.coudurier@gmail.com> wrote:
Hi Dave, <snip>
-- Baptiste COUDURIER Key fingerprint 8D77134D20CC9220201FC5DB0AC9325C5C1ABAAA FFmpeg maintainer http://www.ffmpeg.org _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Thanks for the feedback as I am very new to ffmpeg. I've revised my patch per you suggestions, hope I understood properly.
Interrogate MOV metadata for orientation of video so that software can determine if the video needs to be rotated. --- libavformat/mov.c | 4 ++++ 1 files changed, 4 insertions(+), 0 deletions(-)
diff --git a/libavformat/mov.c b/libavformat/mov.c index 23ba1d4..b12890f 100644 --- a/libavformat/mov.c +++ b/libavformat/mov.c @@ -1907,6 +1907,10 @@ static int mov_read_tkhd(MOVContext *c, AVIOContext *pb, MOVAtom atom) sc->width = width>> 16; sc->height = height>> 16;
+ if (display_matrix[0][0] == -65536&& display_matrix[1][1] == -65536) { + av_metadata_set2(&c->fc->metadata, "rotate", "180", 0); + }
Set the metadata on AVStream, not AVFormatContext.
Are you sure that the check is 100% correct for the rotation ?
Couldn't this be more generically extracted as the acos of [0][0] then verified against [1][1]?
Or even better, also verify [0][1] == -[1][0] and use atan2() of [0][0] and [0][1] (or [1][0], depending on how the matrix is stored). /Tomas
On Wed, Apr 6, 2011 at 3:12 AM, Tomas Härdin <tomas.hardin@codemill.se> wrote:
James Zern skrev 2011-04-06 02:50:
Couldn't this be more generically extracted as the acos of [0][0] then verified against [1][1]?
Or even better, also verify [0][1] == -[1][0] and use atan2() of [0][0] and [0][1] (or [1][0], depending on how the matrix is stored).
/Tomas
Sorry I'm afraid these suggestions are over my head as it's been too many years since I've taken trigonometry. I can help by testing any patches that are put out. Personally it doesn't matter to me how the patch functions as long as there is a way to extra this data at the application level. Thanks! Dave
Le 6 avr. 2011 à 02:50, James Zern a écrit :
On Tue, Apr 5, 2011 at 16:53, Baptiste Coudurier <baptiste.coudurier@gmail.com> wrote:
Hi Dave,
On 04/05/2011 04:49 PM, Dave Badia wrote:
On Wed, Mar 30, 2011 at 11:18 AM, Baptiste Coudurier <baptiste.coudurier@gmail.com> wrote:
Hi Dave, <snip>
-- Baptiste COUDURIER Key fingerprint 8D77134D20CC9220201FC5DB0AC9325C5C1ABAAA FFmpeg maintainer http://www.ffmpeg.org _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Thanks for the feedback as I am very new to ffmpeg. I've revised my patch per you suggestions, hope I understood properly.
Interrogate MOV metadata for orientation of video so that software can determine if the video needs to be rotated. --- libavformat/mov.c | 4 ++++ 1 files changed, 4 insertions(+), 0 deletions(-)
diff --git a/libavformat/mov.c b/libavformat/mov.c index 23ba1d4..b12890f 100644 --- a/libavformat/mov.c +++ b/libavformat/mov.c @@ -1907,6 +1907,10 @@ static int mov_read_tkhd(MOVContext *c, AVIOContext *pb, MOVAtom atom) sc->width = width >> 16; sc->height = height >> 16;
+ if (display_matrix[0][0] == -65536 && display_matrix[1][1] == -65536) { + av_metadata_set2(&c->fc->metadata, "rotate", "180", 0); + }
Set the metadata on AVStream, not AVFormatContext.
Are you sure that the check is 100% correct for the rotation ?
why not extracting the whole affine transform matrix ? -- Jean-Daniel
On Wed, Apr 06, 2011 at 09:51:33AM +0200, Jean-Daniel Dupas wrote:
Le 6 avr. 2011 à 02:50, James Zern a écrit :
On Tue, Apr 5, 2011 at 16:53, Baptiste Coudurier <baptiste.coudurier@gmail.com> wrote:
Hi Dave,
On 04/05/2011 04:49 PM, Dave Badia wrote:
On Wed, Mar 30, 2011 at 11:18 AM, Baptiste Coudurier <baptiste.coudurier@gmail.com> wrote:
Hi Dave, <snip>
-- Baptiste COUDURIER Key fingerprint 8D77134D20CC9220201FC5DB0AC9325C5C1ABAAA FFmpeg maintainer http://www.ffmpeg.org _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Thanks for the feedback as I am very new to ffmpeg. I've revised my patch per you suggestions, hope I understood properly.
Interrogate MOV metadata for orientation of video so that software can determine if the video needs to be rotated. --- libavformat/mov.c | 4 ++++ 1 files changed, 4 insertions(+), 0 deletions(-)
diff --git a/libavformat/mov.c b/libavformat/mov.c index 23ba1d4..b12890f 100644 --- a/libavformat/mov.c +++ b/libavformat/mov.c @@ -1907,6 +1907,10 @@ static int mov_read_tkhd(MOVContext *c, AVIOContext *pb, MOVAtom atom) sc->width = width >> 16; sc->height = height >> 16;
+ if (display_matrix[0][0] == -65536 && display_matrix[1][1] == -65536) { + av_metadata_set2(&c->fc->metadata, "rotate", "180", 0); + }
Set the metadata on AVStream, not AVFormatContext.
Are you sure that the check is 100% correct for the rotation ?
why not extracting the whole affine transform matrix ?
+1 but that doesnt mean i have any objections to just extract the rotation [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB The greatest way to live with honor in this world is to be what we pretend to be. -- Socrates
On 04/06/2011 03:19 AM, Michael Niedermayer wrote:
On Wed, Apr 06, 2011 at 09:51:33AM +0200, Jean-Daniel Dupas wrote:
Le 6 avr. 2011 à 02:50, James Zern a écrit :
On Tue, Apr 5, 2011 at 16:53, Baptiste Coudurier <baptiste.coudurier@gmail.com> wrote:
Hi Dave,
On 04/05/2011 04:49 PM, Dave Badia wrote:
On Wed, Mar 30, 2011 at 11:18 AM, Baptiste Coudurier <baptiste.coudurier@gmail.com> wrote:
Hi Dave, <snip>
-- Baptiste COUDURIER Key fingerprint 8D77134D20CC9220201FC5DB0AC9325C5C1ABAAA FFmpeg maintainer http://www.ffmpeg.org _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Thanks for the feedback as I am very new to ffmpeg. I've revised my patch per you suggestions, hope I understood properly.
Interrogate MOV metadata for orientation of video so that software can determine if the video needs to be rotated. --- libavformat/mov.c | 4 ++++ 1 files changed, 4 insertions(+), 0 deletions(-)
diff --git a/libavformat/mov.c b/libavformat/mov.c index 23ba1d4..b12890f 100644 --- a/libavformat/mov.c +++ b/libavformat/mov.c @@ -1907,6 +1907,10 @@ static int mov_read_tkhd(MOVContext *c, AVIOContext *pb, MOVAtom atom) sc->width = width >> 16; sc->height = height >> 16;
+ if (display_matrix[0][0] == -65536 && display_matrix[1][1] == -65536) { + av_metadata_set2(&c->fc->metadata, "rotate", "180", 0); + }
Set the metadata on AVStream, not AVFormatContext.
Are you sure that the check is 100% correct for the rotation ?
why not extracting the whole affine transform matrix ?
+1
but that doesnt mean i have any objections to just extract the rotation
That would be nice, but I would apply Dave patch (plus the AVStream metadata change) right now if it is 100% correct and won't cause side effects. Is the check correct currently ? -- Baptiste COUDURIER Key fingerprint 8D77134D20CC9220201FC5DB0AC9325C5C1ABAAA FFmpeg maintainer http://www.ffmpeg.org
On Wed, Apr 06, 2011 at 03:38:57PM -0700, Baptiste Coudurier wrote:
On 04/06/2011 03:19 AM, Michael Niedermayer wrote:
On Wed, Apr 06, 2011 at 09:51:33AM +0200, Jean-Daniel Dupas wrote:
Le 6 avr. 2011 à 02:50, James Zern a écrit :
On Tue, Apr 5, 2011 at 16:53, Baptiste Coudurier <baptiste.coudurier@gmail.com> wrote:
Hi Dave,
On 04/05/2011 04:49 PM, Dave Badia wrote:
On Wed, Mar 30, 2011 at 11:18 AM, Baptiste Coudurier <baptiste.coudurier@gmail.com> wrote: > Hi Dave, <snip> > > -- > Baptiste COUDURIER > Key fingerprint 8D77134D20CC9220201FC5DB0AC9325C5C1ABAAA > FFmpeg maintainer http://www.ffmpeg.org > _______________________________________________ > ffmpeg-devel mailing list > ffmpeg-devel@ffmpeg.org > http://ffmpeg.org/mailman/listinfo/ffmpeg-devel >
Thanks for the feedback as I am very new to ffmpeg. I've revised my patch per you suggestions, hope I understood properly.
Interrogate MOV metadata for orientation of video so that software can determine if the video needs to be rotated. --- libavformat/mov.c | 4 ++++ 1 files changed, 4 insertions(+), 0 deletions(-)
diff --git a/libavformat/mov.c b/libavformat/mov.c index 23ba1d4..b12890f 100644 --- a/libavformat/mov.c +++ b/libavformat/mov.c @@ -1907,6 +1907,10 @@ static int mov_read_tkhd(MOVContext *c, AVIOContext *pb, MOVAtom atom) sc->width = width >> 16; sc->height = height >> 16;
+ if (display_matrix[0][0] == -65536 && display_matrix[1][1] == -65536) { + av_metadata_set2(&c->fc->metadata, "rotate", "180", 0); + }
Set the metadata on AVStream, not AVFormatContext.
Are you sure that the check is 100% correct for the rotation ?
why not extracting the whole affine transform matrix ?
+1
but that doesnt mean i have any objections to just extract the rotation
That would be nice, but I would apply Dave patch (plus the AVStream metadata change) right now if it is 100% correct and won't cause side effects. Is the check correct currently ?
getting this 100% correct is more work than exporting the whole affine matrix but if you like the a b c d submatrix of a n*90° rotation / flip / scale has 2 diagonal entries 0 the absolute values of the other 2 represent x/y scale the signs and which are 0 represent the rotation and flip [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB I hate to see young programmers poisoned by the kind of thinking Ulrich Drepper puts forward since it is simply too narrow -- Roman Shaposhnik
Hi Baptiste - On Tue, Apr 5, 2011 at 7:53 PM, Baptiste Coudurier <baptiste.coudurier@gmail.com> wrote:
Set the metadata on AVStream, not AVFormatContext.
Are you sure that the check is 100% correct for the rotation ?
-- Baptiste COUDURIER Key fingerprint 8D77134D20CC9220201FC5DB0AC9325C5C1ABAAA FFmpeg maintainer http://www.ffmpeg.org
Ok, new patch with metadata set on AVStream. I'm quite sure the logic is correct as I have a couple of different samples from my iphone 4. I used dumpster to look at the raw matrix then integrated the code into ffmpeg and tested it in mythtv. Interrogate MOV metadata for orientation of video so that software can determine if the video needs to be rotated. Thanks Dave --- libavformat/mov.c | 4 ++++ 1 files changed, 4 insertions(+), 0 deletions(-) diff --git a/libavformat/mov.c b/libavformat/mov.c index 23ba1d4..8745d60 100644 --- a/libavformat/mov.c +++ b/libavformat/mov.c @@ -1907,6 +1907,10 @@ static int mov_read_tkhd(MOVContext *c, AVIOContext *pb, MOVAtom atom) sc->width = width >> 16; sc->height = height >> 16; + if (display_matrix[0][0] == -65536 && display_matrix[1][1] == -65536) { + av_metadata_set2(&st->metadata, "rotate", "180", 0); + } + // transform the display width/height according to the matrix // skip this if the display matrix is the default identity matrix // or if it is rotating the picture, ex iPhone 3GS
Hi Dave, On 4/7/11 5:31 AM, Dave Badia wrote:
Hi Baptiste -
On Tue, Apr 5, 2011 at 7:53 PM, Baptiste Coudurier <baptiste.coudurier@gmail.com> wrote:
Set the metadata on AVStream, not AVFormatContext.
Are you sure that the check is 100% correct for the rotation ?
-- Baptiste COUDURIER Key fingerprint 8D77134D20CC9220201FC5DB0AC9325C5C1ABAAA FFmpeg maintainer http://www.ffmpeg.org
Ok, new patch with metadata set on AVStream. I'm quite sure the logic is correct as I have a couple of different samples from my iphone 4. I used dumpster to look at the raw matrix then integrated the code into ffmpeg and tested it in mythtv.
Interrogate MOV metadata for orientation of video so that software can determine if the video needs to be rotated.
Thanks Dave
--- libavformat/mov.c | 4 ++++ 1 files changed, 4 insertions(+), 0 deletions(-)
diff --git a/libavformat/mov.c b/libavformat/mov.c index 23ba1d4..8745d60 100644 --- a/libavformat/mov.c +++ b/libavformat/mov.c @@ -1907,6 +1907,10 @@ static int mov_read_tkhd(MOVContext *c, AVIOContext *pb, MOVAtom atom) sc->width = width >> 16; sc->height = height >> 16;
+ if (display_matrix[0][0] == -65536 && display_matrix[1][1] == -65536) { + av_metadata_set2(&st->metadata, "rotate", "180", 0); + }
Are you sure it's 180 ? -- Baptiste COUDURIER Key fingerprint 8D77134D20CC9220201FC5DB0AC9325C5C1ABAAA FFmpeg maintainer http://www.ffmpeg.org
On Thu, Apr 7, 2011 at 7:27 PM, Baptiste Coudurier <baptiste.coudurier@gmail.com> wrote:
Hi Dave,
On 4/7/11 5:31 AM, Dave Badia wrote:
Hi Baptiste -
On Tue, Apr 5, 2011 at 7:53 PM, Baptiste Coudurier <baptiste.coudurier@gmail.com> wrote:
Set the metadata on AVStream, not AVFormatContext.
Are you sure that the check is 100% correct for the rotation ?
-- Baptiste COUDURIER Key fingerprint 8D77134D20CC9220201FC5DB0AC9325C5C1ABAAA FFmpeg maintainer http://www.ffmpeg.org
Ok, new patch with metadata set on AVStream. I'm quite sure the logic is correct as I have a couple of different samples from my iphone 4. I used dumpster to look at the raw matrix then integrated the code into ffmpeg and tested it in mythtv.
Interrogate MOV metadata for orientation of video so that software can determine if the video needs to be rotated.
Thanks Dave
--- libavformat/mov.c | 4 ++++ 1 files changed, 4 insertions(+), 0 deletions(-)
diff --git a/libavformat/mov.c b/libavformat/mov.c index 23ba1d4..8745d60 100644 --- a/libavformat/mov.c +++ b/libavformat/mov.c @@ -1907,6 +1907,10 @@ static int mov_read_tkhd(MOVContext *c, AVIOContext *pb, MOVAtom atom) sc->width = width >> 16; sc->height = height >> 16;
+ if (display_matrix[0][0] == -65536 && display_matrix[1][1] == -65536) { + av_metadata_set2(&st->metadata, "rotate", "180", 0); + }
Are you sure it's 180 ?
-- Baptiste COUDURIER Key fingerprint 8D77134D20CC9220201FC5DB0AC9325C5C1ABAAA FFmpeg maintainer http://www.ffmpeg.org
Ah yes.. 180 as in 180 degrees that it needs to be rotated to be right side up. Thanks Dave
On 04/07/2011 05:39 PM, Dave Badia wrote:
On Thu, Apr 7, 2011 at 7:27 PM, Baptiste Coudurier <baptiste.coudurier@gmail.com> wrote:
Hi Dave,
On 4/7/11 5:31 AM, Dave Badia wrote:
Hi Baptiste -
On Tue, Apr 5, 2011 at 7:53 PM, Baptiste Coudurier <baptiste.coudurier@gmail.com> wrote:
Set the metadata on AVStream, not AVFormatContext.
Are you sure that the check is 100% correct for the rotation ?
-- Baptiste COUDURIER Key fingerprint 8D77134D20CC9220201FC5DB0AC9325C5C1ABAAA FFmpeg maintainer http://www.ffmpeg.org
Ok, new patch with metadata set on AVStream. I'm quite sure the logic is correct as I have a couple of different samples from my iphone 4. I used dumpster to look at the raw matrix then integrated the code into ffmpeg and tested it in mythtv.
Interrogate MOV metadata for orientation of video so that software can determine if the video needs to be rotated.
Thanks Dave
--- libavformat/mov.c | 4 ++++ 1 files changed, 4 insertions(+), 0 deletions(-)
diff --git a/libavformat/mov.c b/libavformat/mov.c index 23ba1d4..8745d60 100644 --- a/libavformat/mov.c +++ b/libavformat/mov.c @@ -1907,6 +1907,10 @@ static int mov_read_tkhd(MOVContext *c, AVIOContext *pb, MOVAtom atom) sc->width = width >> 16; sc->height = height >> 16;
+ if (display_matrix[0][0] == -65536 && display_matrix[1][1] == -65536) { + av_metadata_set2(&st->metadata, "rotate", "180", 0); + }
Are you sure it's 180 ?
-- Baptiste COUDURIER Key fingerprint 8D77134D20CC9220201FC5DB0AC9325C5C1ABAAA FFmpeg maintainer http://www.ffmpeg.org
Ah yes.. 180 as in 180 degrees that it needs to be rotated to be right side up.
Interesting, I've never seen this kind of file, I've seen plenty of 90 degrees rotation though. Do you have this kind of files ? -- Baptiste COUDURIER Key fingerprint 8D77134D20CC9220201FC5DB0AC9325C5C1ABAAA FFmpeg maintainer http://www.ffmpeg.org
Interesting, I've never seen this kind of file, I've seen plenty of 90 degrees rotation though. Do you have this kind of files ?
-- Baptiste COUDURIER Key fingerprint 8D77134D20CC9220201FC5DB0AC9325C5C1ABAAA FFmpeg maintainer http://www.ffmpeg.org _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Here's a sample: http://www.filedropper.com/img0354 It was taken with an IPhone 4 Dave
Any other thoughts on this patch? Just curious as I'm working on a patch for mythtv but need to understand how the final ffmpeg patch will look first Thanks Dave
Hi Dave, On 04/19/2011 06:39 AM, Dave Badia wrote:
Any other thoughts on this patch? Just curious as I'm working on a patch for mythtv but need to understand how the final ffmpeg patch will look first
The patch looks good to me. I'll apply it soon. -- Baptiste COUDURIER Key fingerprint 8D77134D20CC9220201FC5DB0AC9325C5C1ABAAA FFmpeg maintainer http://www.ffmpeg.org
On Tue, Apr 19, 2011 at 12:28 PM, Baptiste Coudurier < baptiste.coudurier@gmail.com> wrote:
Hi Dave,
On 04/19/2011 06:39 AM, Dave Badia wrote:
Any other thoughts on this patch? Just curious as I'm working on a patch for mythtv but need to understand how the final ffmpeg patch will look first
The patch looks good to me. I'll apply it soon.
Did anyone push this patch ever?
-- Baptiste COUDURIER Key fingerprint 8D77134D20CC9220201FC5DB0AC9325C5C1ABAAA FFmpeg maintainer http://www.ffmpeg.org _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
On Thu, Jun 09, 2011 at 04:32:35PM -0700, Thierry Foucu wrote:
On Tue, Apr 19, 2011 at 12:28 PM, Baptiste Coudurier < baptiste.coudurier@gmail.com> wrote:
Hi Dave,
On 04/19/2011 06:39 AM, Dave Badia wrote:
Any other thoughts on this patch? Just curious as I'm working on a patch for mythtv but need to understand how the final ffmpeg patch will look first
The patch looks good to me. I'll apply it soon.
Did anyone push this patch ever?
locally commited will be pushed next time i push & if it passes tests [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB I have often repented speaking, but never of holding my tongue. -- Xenocrates
On Thu, Jun 09, 2011 at 04:32:35PM -0700, Thierry Foucu wrote:
On Tue, Apr 19, 2011 at 12:28 PM, Baptiste Coudurier < baptiste.coudurier@gmail.com> wrote:
Hi Dave,
On 04/19/2011 06:39 AM, Dave Badia wrote:
Any other thoughts on this patch? Just curious as I'm working on a patch for mythtv but need to understand how the final ffmpeg patch will look first
The patch looks good to me. I'll apply it soon.
Did anyone push this patch ever?
also if you spot other patches that where approved and never pushed please tell me so i can push them and thx for spoting this one [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB It is not what we do, but why we do it that matters.
I tried with this patch but it doesn't seems to be work. I recorded video in portrait mode in IPhone. But after encoding output video is 90 degree rotated. I am using 0.8.4 version libraries of FFMPEG. I just add this line and comment existing one (see below) but it doesn't work. It seems that it does not remember metadata information. Please help. //av_dict_set(&st->metadata, "rotate", "180", 0); av_metadata_set2(&st->metadata, "rotate", "180", 0);
On Tue, Sep 27, 2011 at 01:13:31PM +0000, Gagan wrote:
I tried with this patch but it doesn't seems to be work.
I recorded video in portrait mode in IPhone.
But after encoding output video is 90 degree rotated.
I am using 0.8.4 version libraries of FFMPEG.
I just add this line and comment existing one (see below) but it doesn't work.
It seems that it does not remember metadata information. Please help.
//av_dict_set(&st->metadata, "rotate", "180", 0); av_metadata_set2(&st->metadata, "rotate", "180", 0);
if iam not mistaken then this patch just extracts the rotation, it does not insert it in newly created movs... A patch doing so is welcome! [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB The bravest are surely those who have the clearest vision of what is before them, glory and danger alike, and yet notwithstanding go out to meet it. -- Thucydides
On date Tuesday 2011-04-05 16:53:32 -0700, Baptiste Coudurier encoded:
Hi Dave,
On 04/05/2011 04:49 PM, Dave Badia wrote: [...]
Interrogate MOV metadata for orientation of video so that software can determine if the video needs to be rotated. --- libavformat/mov.c | 4 ++++ 1 files changed, 4 insertions(+), 0 deletions(-)
diff --git a/libavformat/mov.c b/libavformat/mov.c index 23ba1d4..b12890f 100644 --- a/libavformat/mov.c +++ b/libavformat/mov.c @@ -1907,6 +1907,10 @@ static int mov_read_tkhd(MOVContext *c, AVIOContext *pb, MOVAtom atom) sc->width = width >> 16; sc->height = height >> 16;
+ if (display_matrix[0][0] == -65536 && display_matrix[1][1] == -65536) { + av_metadata_set2(&c->fc->metadata, "rotate", "180", 0); + }
It was already said, but why such a specific check? IMO it would much more useful to export the rotation information (e.g. 90, 180, etc.). Which are the acceptable rotation values? Also, how should we export this information to the application level (e.g. for auto-inserting a corresponding rotation filter at the begin of the filterchain)? IIRC Baptiste proposed some time ago a patch for adding that information to AVStream, what happened of that? -- FFmpeg = Funny and Freak Majestic Puritan Elitarian Game
Le 30 avr. 2011 à 00:55, Stefano Sabatini a écrit :
On date Tuesday 2011-04-05 16:53:32 -0700, Baptiste Coudurier encoded:
Hi Dave,
On 04/05/2011 04:49 PM, Dave Badia wrote: [...]
Interrogate MOV metadata for orientation of video so that software can determine if the video needs to be rotated. --- libavformat/mov.c | 4 ++++ 1 files changed, 4 insertions(+), 0 deletions(-)
diff --git a/libavformat/mov.c b/libavformat/mov.c index 23ba1d4..b12890f 100644 --- a/libavformat/mov.c +++ b/libavformat/mov.c @@ -1907,6 +1907,10 @@ static int mov_read_tkhd(MOVContext *c, AVIOContext *pb, MOVAtom atom) sc->width = width >> 16; sc->height = height >> 16;
+ if (display_matrix[0][0] == -65536 && display_matrix[1][1] == -65536) { + av_metadata_set2(&c->fc->metadata, "rotate", "180", 0); + }
It was already said, but why such a specific check? IMO it would much more useful to export the rotation information (e.g. 90, 180, etc.). Which are the acceptable rotation values?
Also, how should we export this information to the application level (e.g. for auto-inserting a corresponding rotation filter at the begin of the filterchain)?
If your goal is to apply a filter based on the track matrix, I don't understand what the point of extracting the rotation only. It would be easier to extract the whole matrix, and write an 'affine transform' filter to apply the matrix instead of bothering with rotation, which is just a special case of affine transform. If the track matrix specifies a rotation, a translation, and a scaling, applying only one transform will be wrong anyway. -- Jean-Daniel
On date Saturday 2011-04-30 01:09:15 +0200, Jean-Daniel Dupas encoded:
Le 30 avr. 2011 à 00:55, Stefano Sabatini a écrit :
On date Tuesday 2011-04-05 16:53:32 -0700, Baptiste Coudurier encoded:
Hi Dave,
On 04/05/2011 04:49 PM, Dave Badia wrote: [...]
Interrogate MOV metadata for orientation of video so that software can determine if the video needs to be rotated. --- libavformat/mov.c | 4 ++++ 1 files changed, 4 insertions(+), 0 deletions(-)
diff --git a/libavformat/mov.c b/libavformat/mov.c index 23ba1d4..b12890f 100644 --- a/libavformat/mov.c +++ b/libavformat/mov.c @@ -1907,6 +1907,10 @@ static int mov_read_tkhd(MOVContext *c, AVIOContext *pb, MOVAtom atom) sc->width = width >> 16; sc->height = height >> 16;
+ if (display_matrix[0][0] == -65536 && display_matrix[1][1] == -65536) { + av_metadata_set2(&c->fc->metadata, "rotate", "180", 0); + }
It was already said, but why such a specific check? IMO it would much more useful to export the rotation information (e.g. 90, 180, etc.). Which are the acceptable rotation values?
Also, how should we export this information to the application level (e.g. for auto-inserting a corresponding rotation filter at the begin of the filterchain)?
If your goal is to apply a filter based on the track matrix, I don't understand what the point of extracting the rotation only. It would be easier to extract the whole matrix, and write an 'affine transform' filter to apply the matrix instead of bothering with rotation, which is just a special case of affine transform.
If the track matrix specifies a rotation, a translation, and a scaling, applying only one transform will be wrong anyway.
Yes, now the point is how to expose this MOV specific affine transform matrix to AVStream/to the application level. -- FFmpeg = Fundamental & Fabulous Magical Prodigious Erroneous Gnome
On Sat, Apr 30, 2011 at 01:22:32AM +0200, Stefano Sabatini wrote:
On date Saturday 2011-04-30 01:09:15 +0200, Jean-Daniel Dupas encoded:
Le 30 avr. 2011 à 00:55, Stefano Sabatini a écrit :
On date Tuesday 2011-04-05 16:53:32 -0700, Baptiste Coudurier encoded:
Hi Dave,
On 04/05/2011 04:49 PM, Dave Badia wrote: [...]
Interrogate MOV metadata for orientation of video so that software can determine if the video needs to be rotated. --- libavformat/mov.c | 4 ++++ 1 files changed, 4 insertions(+), 0 deletions(-)
diff --git a/libavformat/mov.c b/libavformat/mov.c index 23ba1d4..b12890f 100644 --- a/libavformat/mov.c +++ b/libavformat/mov.c @@ -1907,6 +1907,10 @@ static int mov_read_tkhd(MOVContext *c, AVIOContext *pb, MOVAtom atom) sc->width = width >> 16; sc->height = height >> 16;
+ if (display_matrix[0][0] == -65536 && display_matrix[1][1] == -65536) { + av_metadata_set2(&c->fc->metadata, "rotate", "180", 0); + }
It was already said, but why such a specific check? IMO it would much more useful to export the rotation information (e.g. 90, 180, etc.). Which are the acceptable rotation values?
Also, how should we export this information to the application level (e.g. for auto-inserting a corresponding rotation filter at the begin of the filterchain)?
If your goal is to apply a filter based on the track matrix, I don't understand what the point of extracting the rotation only. It would be easier to extract the whole matrix, and write an 'affine transform' filter to apply the matrix instead of bothering with rotation, which is just a special case of affine transform.
If the track matrix specifies a rotation, a translation, and a scaling, applying only one transform will be wrong anyway.
Yes, now the point is how to expose this MOV specific affine transform matrix to AVStream/to the application level.
either AVStream int [3][3] or metadata of 3x3 integers Bikeshed time ... [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB In fact, the RIAA has been known to suggest that students drop out of college or go to community college in order to be able to afford settlements. -- The RIAA
Hi Dave, I tried with this patch but it doesn't seems to be work. I recorded video in portrait mode in IPhone. But after encoding output video is 90 degree rotated. I am using 0.8.4 version libraries of FFMPEG. I just add this line and comment existing one (see below) but it doesn't work. It seems that it does not remember metadata information. Please help. //av_dict_set(&st->metadata, "rotate", "180", 0); av_metadata_set2(&st->metadata, "rotate", "180", 0);
participants (9)
-
Baptiste Coudurier -
Dave Badia -
Gagan -
James Zern -
Jean-Daniel Dupas -
Michael Niedermayer -
Stefano Sabatini -
Thierry Foucu -
Tomas Härdin