Android : how can i rotate the video landscape to portrait while triming video using textmp4parser in android?

on Thursday, October 30, 2014


I am using developing the app to videoediting.In my app videoediting(triming) worked fine .But video wil after triming video ladnscapevideo wil rotate the portrait portrait wil rotate the landscape.


I am using the following code to triming code



File folder = Ut.getTestMp4ParserVideosDir(this);
Movie movie = MovieCreator.build(new FileInputStream(new File(strImagePath)).getChannel());
List<Track> tracks = movie.getTracks();
movie.setTracks(new LinkedList<Track>());
// remove all tracks we will create new tracks from the old
Log.e("No. of tracks==","<>"+tracks.size()+" Start="+start);
double startTime = start;//0;
double endTime =(double) getDuration(tracks.get(0)) / tracks.get(0).getTrackMetaData().getTimescale();
endTime= Math.min(endTime, end);
Log.e("endTime","<>"+endTime);
boolean timeCorrected = false;

// Here we try to find a track that has sync samples. Since we can only start decoding
// at such a sample we SHOULD make sure that the start of the new fragment is exactly
// such a frame
for (Track track : tracks)
{
if (track.getSyncSamples() != null && track.getSyncSamples().length > 0) {
if (timeCorrected)
{
// This exception here could be a false positive in case we have multiple tracks
// with sync samples at exactly the same positions. E.g. a single movie containing
// multiple qualities of the same video (Microsoft Smooth Streaming file)

throw new RuntimeException("The startTime has already been corrected by another track with SyncSample. Not Supported.");
}
startTime = correctTimeToSyncSample(track, startTime, false);
endTime = correctTimeToSyncSample(track, endTime, true);
timeCorrected = true;
}
}

for (Track track : tracks)
{
long currentSample = 0;
double currentTime = 0;
long startSample = -1;
long endSample = -1;

for (int i = 0; i < track.getDecodingTimeEntries().size(); i++)
{
TimeToSampleBox.Entry entry = track.getDecodingTimeEntries().get(i);
for (int j = 0; j < entry.getCount(); j++)
{
// entry.getDelta() is the amount of time the current sample covers.

if (currentTime <= startTime)
{
// current sample is still before the new starttime
startSample = currentSample;
}else if (currentTime <= endTime)
{
// current sample is after the new start time and still before the new endtime
endSample = currentSample;
} else
{
// current sample is after the end of the cropped video
break;
}
currentTime += (double) entry.getDelta() / (double) track.getTrackMetaData().getTimescale();
currentSample++;
}
}
Log.e("<>=","startSample="+startSample+" endSample"+endSample);
movie.addTrack(new CroppedTrack(track, startSample, endSample));


Log.e("<><>>","<><><");
}
long start1 = System.currentTimeMillis();
IsoFile out = new DefaultMp4Builder().build(movie);
long start2 = System.currentTimeMillis();

// FileOutputStream fos = new FileOutputStream(String.format("output-%f-%f.mp4", startTime, endTime));
String timeStamp = new SimpleDateFormat("yyyyMMdd_HHmmss").format(new Date());
filename1 = folder.getPath() + File.separator + String.format("Trimming", startTime, endTime) + "_" + timeStamp + ".mp4";
FileOutputStream fos = new FileOutputStream(filename1);
Log.e("after trim","after trim ing videopath ashok<><><><><><><"+filename1.toString());
FileChannel fc = fos.getChannel();
out.getBox(fc);
fc.close();
fos.close();
long start3 = System.currentTimeMillis();


I am using the textMp4parser for videoediting.please help how to rotate the videofile in landscape to portrait mode .please tell me anyone known


Advance thanks to all


0 comments:

Post a Comment