2013-01-25 93 views
4

我有一組圖像與我,我希望通過循環運行它們,並將其保存爲SD卡中的視頻文件。有沒有我可以使用的Android的任何默認工具。 ?任何可以滿足我的要求的圖書館。 ?將圖像轉換爲Android中的單個視頻文件

+0

http://stackoverflow.com/questions/13643046/how-to-convert-images-into-video-in-android-using-javacv –

+0

http://stackoverflow.com/questions/13643046/how-to-convert-images-into-video-in-android-using -javacv 訪問上面的鏈接... –

回答

0

有在支持此功能Android庫沒有內置。 This SO post建議使用通過Java端口或使用Android NDK以C/C++編寫的ffmpeg

-1

用於創建逐幀動畫的對象,由一系列Drawable對象定義,可用作View對象的背景。

創建逐幀動畫的最簡單方法是在XML文件中定義動畫,放置在res/drawable /文件夾中,並將其設置爲View對象的背景。然後,調用start()來運行動畫。

XML中定義的AnimationDrawable由單個元素和一系列嵌套標籤組成。每個項目定義了動畫的一個框架。看下面的例子。在res /繪製/文件夾

spin_animation.xml文件:

<!-- Animation frames are wheel0.png -- wheel5.png files inside the 
res/drawable/ folder --> 
<animation-list android:id="@+id/selected" android:oneshot="false"> 
    <item android:drawable="@drawable/wheel0" android:duration="50" /> 
    <item android:drawable="@drawable/wheel1" android:duration="50" /> 
    <item android:drawable="@drawable/wheel2" android:duration="50" /> 
    <item android:drawable="@drawable/wheel3" android:duration="50" /> 
    <item android:drawable="@drawable/wheel4" android:duration="50" /> 
    <item android:drawable="@drawable/wheel5" android:duration="50" /> 
</animation-list> 

這裏是加載和播放這個動畫的代碼。

// Load the ImageView that will host the animation and 
// set its background to our AnimationDrawable XML resource. 
ImageView img = (ImageView)findViewById(R.id.spinning_wheel_image); 
img.setBackgroundResource(R.drawable.spin_animation); 

// Get the background, which has been compiled to an AnimationDrawable object. 
AnimationDrawable frameAnimation = (AnimationDrawable) img.getBackground(); 

// Start the animation (looped playback by default). 
frameAnimation.start(); 
+0

謝謝@Aakash,但你打算如何保存它作爲一個視頻文件? –

+0

該代碼不能在我的電腦上工作 – deepak825

0

使用的Java javacpp.jarjavacv.jar在你的Android項目創建一系列圖像視頻

下面的代碼用於創建視頻

recorder = new FFmpegFrameRecorder("Videofilename", 480, 480); 

try { 
    recorder.setVideoCodec(13); 
    recorder.setFrameRate(0.4d); 
    recorder.setPixelFormat(0); 
    recorder.setVideoQuality(1.0d); 
    recorder.setVideoBitrate(4000); 

    startTime = System.currentTimeMillis(); 
    recorder.start(); 

    int time = Integer.parseInt(params[0]); 
    resp = "Slept for " + time + " milliseconds"; 

    for (int i = 0; i < iplimage.length; i++) { 
     long t = 1000 * (System.currentTimeMillis() - startTime); 
     if (t < recorder.getTimestamp()) { 
      t = recorder.getTimestamp() + 1000; 
     } 
     recorder.setTimestamp(t); 
     recorder.record(iplimage[i]); 
    } 
} catch (Exception e) { 
    e.printStackTrace(); 
} 
相關問題