This turns out to be a stupid mistake in my own code below. It's actually almost more amazing that it seemed to work correctly for all other files, but that probably has to do with the order of the tracks in the libvlc_media_track array. For completeness, in the below code there is a '(*mediatracks)' that should be changed to 'mediatracks[t]'. Thanks
Hi!
I'm writing a program that deals a lot with video files created with mobile phones. Because of this, a relatively large group of these videos are in portrait orientation. To detect this I use libvlc_media_tracks_get() to get track information and check the i_orientation field of the video track. For most videos this works fine, however with a couple of them, this field is set to 0 (libvlc_video_orient_top_left) even though the video is rotated. All of the files exhibiting this issue were created with iPhones and are in mov containers. Now, if the orientation information is simply not available in the file, that would be unfortunate but not my problem, however playing the file with VLC it is correctly rotated and checking 'Codec information' in VLC, I see 'Orientation: Left bottom'. So, apparently the info is somewhere in the file, I just don't know how to get it.
Here is a simple piece of code that exhibits this behavior:
Code: Select all
#include <iostream>
#include <thread>
#include <vlc/vlc.h>
int main(int argc, char *argv[])
{
libvlc_instance_t *vlcinstance = libvlc_new(0, NULL);
libvlc_media_t *vlcmedia = libvlc_media_new_path(vlcinstance, argv[1]);
libvlc_media_player_t *mediaplayer = libvlc_media_player_new_from_media(vlcmedia);
libvlc_media_player_play(mediaplayer);
std::this_thread::sleep_for(std::chrono::milliseconds{3000});
libvlc_media_track_t **mediatracks;
unsigned trackcount = libvlc_media_tracks_get(vlcmedia, &mediatracks);
for (uint t = 0; t < trackcount; ++t)
{
if (mediatracks[t]->i_type == libvlc_track_video)
{
libvlc_video_orient_t orient = (*mediatracks)->video->i_orientation;
std::cout << " - Orientation: " << orient << std::endl; // for all MOV files I have, this incorrectly prints 0, even though VLC seems to get the orientation right
}
else if (mediatracks[t]->i_type == libvlc_track_audio)
std::cout << "Audio track" << std::endl;
else
std::cout << "OTHER TRACK" << std::endl;
}
libvlc_media_tracks_release(mediatracks, trackcount);https://www.google.com/search?q=difference+between+mov+and+mp4+containers&ie=utf-8&oe=utf-8&client=firefox-b
libvlc_media_player_stop(mediaplayer);
libvlc_media_player_release(mediaplayer);
libvlc_media_release(vlcmedia);
libvlc_release(vlcinstance);
return 0;
}
thanks!