
Recherche avancée
Médias (2)
-
Core Media Video
4 avril 2013, par
Mis à jour : Juin 2013
Langue : français
Type : Video
-
Video d’abeille en portrait
14 mai 2011, par
Mis à jour : Février 2012
Langue : français
Type : Video
Autres articles (87)
-
Personnaliser en ajoutant son logo, sa bannière ou son image de fond
5 septembre 2013, parCertains thèmes prennent en compte trois éléments de personnalisation : l’ajout d’un logo ; l’ajout d’une bannière l’ajout d’une image de fond ;
-
Ecrire une actualité
21 juin 2013, parPrésentez les changements dans votre MédiaSPIP ou les actualités de vos projets sur votre MédiaSPIP grâce à la rubrique actualités.
Dans le thème par défaut spipeo de MédiaSPIP, les actualités sont affichées en bas de la page principale sous les éditoriaux.
Vous pouvez personnaliser le formulaire de création d’une actualité.
Formulaire de création d’une actualité Dans le cas d’un document de type actualité, les champs proposés par défaut sont : Date de publication ( personnaliser la date de publication ) (...) -
Publier sur MédiaSpip
13 juin 2013Puis-je poster des contenus à partir d’une tablette Ipad ?
Oui, si votre Médiaspip installé est à la version 0.2 ou supérieure. Contacter au besoin l’administrateur de votre MédiaSpip pour le savoir
Sur d’autres sites (9010)
-
Join two ISMV files
18 février 2015, par Violeta GrigorovaI am currently working on a project involving some task with ismv and ismc files. First of all let me give a brief explanation for the current situation. We are using windows based products only. We are getting some ismv and ismc video files from standard CCTV server. The ouput is only ismv in beggning but after indexing we get ismc file too. For each one hour long stream we are getting one ismv file and one ismc file.
What i need to do now is figure out a way to join multiple one hour streams. For example having a four hour long video will consist of 4 ismv video files.So far I tried ffmpeg codec, but without any success. The same goes for mp4split.
The error for ffmpeg is the following :
Could not find codec parameters for
stream 0 (Video : h264 (avc1 / 0x31637661), none, 586x480, 500 kb/s) : unspecifie
d pixel format
Consider increasing the value for the ’analyzeduration’ and ’probesize’ options
[concat @ 000000000436bd60]Executed with the following command :
ffmpeg.exe -f concat -i F.txt -c copy outputHere is the codec of the video taken with Media Info : http://tinypic.com/r/ff0h8z/8
I did not manage to find a version of mp4split to use. Can you please help me solve this problem ?
The final result should be one video only. This video should be a join between the videos given as input.
ERROR LOG :cmd : >>
ffmpeg.exe -f concat -i F.txt -c copy output.ismv >> c:\test.log
ffmpeg version N-67586-g3e1ac10 Copyright (c) 2000-2014 the FFmpeg developers
built on Nov 12 2014 22:10:14 with gcc 4.9.2 (GCC)
configuration: --enable-gpl --enable-version3 --disable-w32threads --enable-av
isynth --enable-bzlib --enable-fontconfig --enable-frei0r --enable-gnutls --enab
le-iconv --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --
enable-libfreetype --enable-libgme --enable-libgsm --enable-libilbc --enable-lib
modplug --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrw
b --enable-libopenjpeg --enable-libopus --enable-librtmp --enable-libschroedinge
r --enable-libsoxr --enable-libspeex --enable-libtheora --enable-libtwolame --en
able-libvidstab --enable-libvo-aacenc --enable-libvo-amrwbenc --enable-libvorbis
--enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-
libx265 --enable-libxavs --enable-libxvid --enable-zlib
libavutil 54. 11.100 / 54. 11.100
libavcodec 56. 12.100 / 56. 12.100
libavformat 56. 12.103 / 56. 12.103
libavdevice 56. 2.100 / 56. 2.100
libavfilter 5. 2.103 / 5. 2.103
libswscale 3. 1.101 / 3. 1.101
libswresample 1. 1.100 / 1. 1.100
libpostproc 53. 3.100 / 53. 3.100
[h264 @ 0000000004417f80] AVC: nal size -729776398
[h264 @ 0000000004417f80] no frame!
[h264 @ 0000000004417f80] AVC: nal size -1586392803
[h264 @ 0000000004417f80] no frame!
[h264 @ 0000000004417f80] AVC: nal size -201009241
[h264 @ 0000000004417f80] no frame!
[h264 @ 0000000004417f80] AVC: nal size 1525559282
[h264 @ 0000000004417f80] no frame!
[h264 @ 0000000004417f80] AVC: nal size -1669219084
[h264 @ 0000000004417f80] no frame!
[h264 @ 0000000004417f80] AVC: nal size -1691392434
[h264 @ 0000000004417f80] no frame!
[h264 @ 0000000004417f80] AVC: nal size 1990351320
[h264 @ 0000000004417f80] no frame!
[h264 @ 0000000004417f80] AVC: nal size -634604097
[h264 @ 0000000004417f80] no frame!
[h264 @ 0000000004417f80] AVC: nal size 1469591056
[h264 @ 0000000004417f80] no frame!
[h264 @ 0000000004417f80] AVC: nal size -1438535317
[h264 @ 0000000004417f80] no frame!
[h264 @ 0000000004417f80] AVC: nal size 1449123893
[h264 @ 0000000004417f80] no frame!
[h264 @ 0000000004417f80] AVC: nal size 1691583710
[h264 @ 0000000004417f80] no frame!
[h264 @ 0000000004417f80] AVC: nal size -351019013
[h264 @ 0000000004417f80] no frame!
[h264 @ 0000000004417f80] AVC: nal size 309254841
[h264 @ 0000000004417f80] no frame!
[h264 @ 0000000004417f80] AVC: nal size 473575423
[h264 @ 0000000004417f80] no frame!
[h264 @ 0000000004417f80] AVC: nal size -1179057153
[h264 @ 0000000004417f80] no frame!
[h264 @ 0000000004417f80] AVC: nal size -1745148207
[h264 @ 0000000004417f80] no frame!
[h264 @ 0000000004417f80] AVC: nal size -1161919613
[h264 @ 0000000004417f80] no frame!
[h264 @ 0000000004417f80] AVC: nal size -1424567262
[h264 @ 0000000004417f80] no frame!
[h264 @ 0000000004417f80] AVC: nal size -1671905020
[h264 @ 0000000004417f80] no frame!
[h264 @ 0000000004417f80] AVC: nal size -276201527
[h264 @ 0000000004417f80] no frame!
[h264 @ 0000000004417f80] AVC: nal size 2129258231
[h264 @ 0000000004417f80] no frame!
[h264 @ 0000000004417f80] AVC: nal size -1382747181
[h264 @ 0000000004417f80] no frame!
[h264 @ 0000000004417f80] AVC: nal size -53947666
[h264 @ 0000000004417f80] no frame!
[h264 @ 0000000004417f80] AVC: nal size -494363989
[h264 @ 0000000004417f80] no frame!
[h264 @ 0000000004417f80] AVC: nal size 675772942
[h264 @ 0000000004417f80] no frame!
[h264 @ 0000000004417f80] AVC: nal size 1778317799
[h264 @ 0000000004417f80] no frame!
[h264 @ 0000000004417f80] AVC: nal size -1694646357
[h264 @ 0000000004417f80] no frame!
[h264 @ 0000000004417f80] AVC: nal size 322181480
[h264 @ 0000000004417f80] no frame!
[h264 @ 0000000004417f80] AVC: nal size -129268567
[h264 @ 0000000004417f80] no frame!
[h264 @ 0000000004417f80] AVC: nal size 161790146
[h264 @ 0000000004417f80] no frame!
[h264 @ 0000000004417f80] AVC: nal size -182677717
[h264 @ 0000000004417f80] no frame!
[h264 @ 0000000004417f80] AVC: nal size -1764646342
[h264 @ 0000000004417f80] no frame!
[h264 @ 0000000004417f80] AVC: nal size 43163370
[h264 @ 0000000004417f80] no frame!
[h264 @ 0000000004417f80] AVC: nal size -1896031063
[h264 @ 0000000004417f80] no frame!
[h264 @ 0000000004417f80] AVC: nal size 1945651533
[h264 @ 0000000004417f80] no frame!
[h264 @ 0000000004417f80] AVC: nal size -1279624828
[h264 @ 0000000004417f80] no frame!
[h264 @ 0000000004417f80] AVC: nal size -789496900
[h264 @ 0000000004417f80] no frame!
[h264 @ 0000000004417f80] AVC: nal size 1843265261
[h264 @ 0000000004417f80] no frame!
[h264 @ 0000000004417f80] AVC: nal size -159919440
[h264 @ 0000000004417f80] no frame!
[h264 @ 0000000004417f80] AVC: nal size -782702414
[h264 @ 0000000004417f80] no frame!
[h264 @ 0000000004417f80] AVC: nal size -340957996
[h264 @ 0000000004417f80] no frame!
[h264 @ 0000000004417f80] AVC: nal size 301061149
[h264 @ 0000000004417f80] no frame!
[h264 @ 0000000004417f80] AVC: nal size -433378048
[h264 @ 0000000004417f80] no frame!
[h264 @ 0000000004417f80] AVC: nal size 510092259
[h264 @ 0000000004417f80] no frame!
[h264 @ 0000000004417f80] AVC: nal size -539818905
[h264 @ 0000000004417f80] no frame!
[h264 @ 0000000004417f80] AVC: nal size -211670405
[h264 @ 0000000004417f80] no frame!
[h264 @ 0000000004417f80] AVC: nal size -1489865369
[h264 @ 0000000004417f80] no frame!
[h264 @ 0000000004417f80] AVC: nal size 1093843445
[h264 @ 0000000004417f80] no frame!
[h264 @ 0000000004417f80] AVC: nal size -911953424
[h264 @ 0000000004417f80] no frame!
[h264 @ 0000000004417f80] AVC: nal size 405867055
[h264 @ 0000000004417f80] no frame!
[h264 @ 0000000004417f80] AVC: nal size 1506095107
[h264 @ 0000000004417f80] no frame!
[h264 @ 0000000004417f80] AVC: nal size 1756726661
[h264 @ 0000000004417f80] no frame!
[h264 @ 0000000004417f80] AVC: nal size -1252304115
[h264 @ 0000000004417f80] no frame!
[h264 @ 0000000004417f80] AVC: nal size -956720060
[h264 @ 0000000004417f80] no frame!
[h264 @ 0000000004417f80] AVC: nal size 1972752503
[h264 @ 0000000004417f80] no frame!
[h264 @ 0000000004417f80] AVC: nal size 22752285
[h264 @ 0000000004417f80] no frame!
[h264 @ 0000000004417f80] AVC: nal size 148807245
[h264 @ 0000000004417f80] no frame!
[h264 @ 0000000004417f80] AVC: nal size 1593789403
[h264 @ 0000000004417f80] no frame!
[h264 @ 0000000004417f80] AVC: nal size 341071185
[h264 @ 0000000004417f80] no frame!
[h264 @ 0000000004417f80] AVC: nal size -1209592176
[h264 @ 0000000004417f80] no frame!
[h264 @ 0000000004417f80] AVC: nal size -1045063878
[h264 @ 0000000004417f80] no frame!
[h264 @ 0000000004417f80] AVC: nal size 1595886078
[h264 @ 0000000004417f80] no frame!
[h264 @ 0000000004417f80] AVC: nal size 1454822618
[h264 @ 0000000004417f80] no frame!
[h264 @ 0000000004417f80] AVC: nal size 1202334437
[h264 @ 0000000004417f80] no frame!
[h264 @ 0000000004417f80] AVC: nal size 853741989
[h264 @ 0000000004417f80] no frame!
[h264 @ 0000000004417f80] AVC: nal size 562229559
[h264 @ 0000000004417f80] no frame!
[h264 @ 0000000004417f80] AVC: nal size -1846206258
[h264 @ 0000000004417f80] no frame!
[h264 @ 0000000004417f80] AVC: nal size -949647435
[h264 @ 0000000004417f80] no frame!
[h264 @ 0000000004417f80] AVC: nal size 2035288695
[h264 @ 0000000004417f80] no frame!
[h264 @ 0000000004417f80] AVC: nal size -1153464594
[h264 @ 0000000004417f80] no frame!
[h264 @ 0000000004417f80] AVC: nal size 1586433152
[h264 @ 0000000004417f80] no frame!
[h264 @ 0000000004417f80] AVC: nal size 204824048
[h264 @ 0000000004417f80] no frame!
[h264 @ 0000000004417f80] AVC: nal size -68386554
[h264 @ 0000000004417f80] no frame!
[h264 @ 0000000004417f80] AVC: nal size -1052945868
[h264 @ 0000000004417f80] no frame!
[h264 @ 0000000004417f80] AVC: nal size -232379875
[h264 @ 0000000004417f80] no frame!
[h264 @ 0000000004417f80] AVC: nal size -769469796
[h264 @ 0000000004417f80] no frame!
[h264 @ 0000000004417f80] AVC: nal size 1476243902
[h264 @ 0000000004417f80] no frame!
[h264 @ 0000000004417f80] AVC: nal size 944865348
[h264 @ 0000000004417f80] no frame!
[h264 @ 0000000004417f80] AVC: nal size 680117868
[h264 @ 0000000004417f80] no frame!
[h264 @ 0000000004417f80] AVC: nal size -416140149
[h264 @ 0000000004417f80] no frame!
[h264 @ 0000000004417f80] AVC: nal size 1156708360
[h264 @ 0000000004417f80] no frame!
[h264 @ 0000000004417f80] AVC: nal size -264356271
[h264 @ 0000000004417f80] no frame!
[h264 @ 0000000004417f80] AVC: nal size -1709052362
[h264 @ 0000000004417f80] no frame!
[h264 @ 0000000004417f80] AVC: nal size -1592065758
[h264 @ 0000000004417f80] no frame!
[h264 @ 0000000004417f80] AVC: nal size 737752675
[h264 @ 0000000004417f80] no frame!
[h264 @ 0000000004417f80] AVC: nal size 2064970227
[h264 @ 0000000004417f80] no frame!
[h264 @ 0000000004417f80] AVC: nal size 27608298
[h264 @ 0000000004417f80] no frame!
[h264 @ 0000000004417f80] AVC: nal size 1489266222
[h264 @ 0000000004417f80] no frame!
[h264 @ 0000000004417f80] AVC: nal size 946041170
[h264 @ 0000000004417f80] no frame!
[h264 @ 0000000004417f80] AVC: nal size 1999898747
[h264 @ 0000000004417f80] no frame!
[h264 @ 0000000004417f80] AVC: nal size -1002118094
[h264 @ 0000000004417f80] no frame!
[h264 @ 0000000004417f80] AVC: nal size 881674828
[h264 @ 0000000004417f80] no frame!
[h264 @ 0000000004417f80] AVC: nal size -1170312534
[h264 @ 0000000004417f80] no frame!
[h264 @ 0000000004417f80] AVC: nal size 991631349
[h264 @ 0000000004417f80] no frame!
[h264 @ 0000000004417f80] AVC: nal size -1218616840
[h264 @ 0000000004417f80] no frame!
[h264 @ 0000000004417f80] AVC: nal size 916839245
[h264 @ 0000000004417f80] no frame!
[h264 @ 0000000004417f80] AVC: nal size 2133503346
[h264 @ 0000000004417f80] no frame!
[h264 @ 0000000004417f80] AVC: nal size -2041791480
[h264 @ 0000000004417f80] no frame!
[h264 @ 0000000004417f80] AVC: nal size -1857022891
[h264 @ 0000000004417f80] no frame!
[h264 @ 0000000004417f80] AVC: nal size 1901147878
[h264 @ 0000000004417f80] no frame!
[h264 @ 0000000004417f80] AVC: nal size 594072630
[h264 @ 0000000004417f80] no frame!
[h264 @ 0000000004417f80] AVC: nal size 580451068
[h264 @ 0000000004417f80] no frame!
[h264 @ 0000000004417f80] AVC: nal size 1595477547
[h264 @ 0000000004417f80] no frame!
[h264 @ 0000000004417f80] AVC: nal size 1755470860
[h264 @ 0000000004417f80] no frame!
[h264 @ 0000000004417f80] AVC: nal size 22914809
[h264 @ 0000000004417f80] no frame!
[h264 @ 0000000004417f80] AVC: nal size 861184964
[h264 @ 0000000004417f80] no frame!
[h264 @ 0000000004417f80] AVC: nal size 538973456
[h264 @ 0000000004417f80] no frame!
[h264 @ 0000000004417f80] AVC: nal size -354806072
[h264 @ 0000000004417f80] no frame!
[h264 @ 0000000004417f80] AVC: nal size -540053632
[h264 @ 0000000004417f80] no frame!
[h264 @ 0000000004417f80] AVC: nal size -327661798
[h264 @ 0000000004417f80] no frame!
[h264 @ 0000000004417f80] AVC: nal size 1232758622
[h264 @ 0000000004417f80] no frame!
[h264 @ 0000000004417f80] AVC: nal size 2099868463
[h264 @ 0000000004417f80] no frame!
[h264 @ 0000000004417f80] AVC: nal size -866724819
[h264 @ 0000000004417f80] no frame!
[h264 @ 0000000004417f80] AVC: nal size -291115259
[h264 @ 0000000004417f80] no frame!
[h264 @ 0000000004417f80] AVC: nal size 1748168392
[h264 @ 0000000004417f80] no frame!
[h264 @ 0000000004417f80] AVC: nal size 2019118774
[h264 @ 0000000004417f80] no frame!
[h264 @ 0000000004417f80] AVC: nal size -928523944
[h264 @ 0000000004417f80] no frame!
[h264 @ 0000000004417f80] AVC: nal size 1292590826
[h264 @ 0000000004417f80] no frame!
[h264 @ 0000000004417f80] AVC: nal size -1183926090
[h264 @ 0000000004417f80] no frame!
[h264 @ 0000000004417f80] AVC: nal size -24524382
[h264 @ 0000000004417f80] no frame!
[h264 @ 0000000004417f80] AVC: nal size 901119803
[h264 @ 0000000004417f80] no frame!
[h264 @ 0000000004417f80] AVC: nal size 1866763900
[h264 @ 0000000004417f80] no frame!
[h264 @ 0000000004417f80] AVC: nal size 838469106
[h264 @ 0000000004417f80] no frame!
[h264 @ 0000000004417f80] AVC: nal size -388249262
[h264 @ 0000000004417f80] no frame!
[mov,mp4,m4a,3gp,3g2,mj2 @ 000000000441ce80] decoding for stream 0 failed
[mov,mp4,m4a,3gp,3g2,mj2 @ 000000000441ce80] Could not find codec parameters for
stream 0 (Video: h264 (avc1 / 0x31637661), none, 586x480, 500 kb/s): unspecifie
d pixel format
Consider increasing the value for the 'analyzeduration' and 'probesize' options
[concat @ 000000000441bd60] Impossible to open 'C:\Segment059\CCameraStream.ismv'
F.txt: Operation not permittedThe F.txt file contains :
file 'C:\Segment059\CameraStream.ismv'
file 'C:\Segment060\CameraStream.ismv'Reference for the approach : https://trac.ffmpeg.org/wiki/Concatenate#samecodec
-
Video Recording on Android from Frames using javaCV
23 juin 2016, par jawad bin zafarI am using this library javaCV to record video on android. They have provided a sample VideoRecording Activity But There is some bug which I could not figure out what I am doing it wrong or what is missing which causing this bug.
package org.bytedeco.javacv.recordactivity;
import android.app.Activity;
import android.content.Context;
import android.content.pm.ActivityInfo;
import android.hardware.Camera;
import android.hardware.Camera.PreviewCallback;
import android.media.AudioFormat;
import android.media.AudioRecord;
import android.media.MediaRecorder;
import android.os.Bundle;
import android.os.PowerManager;
import android.util.Log;
import android.view.Display;
import android.view.KeyEvent;
import android.view.LayoutInflater;
import android.view.SurfaceHolder;
import android.view.SurfaceView;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.WindowManager;
import android.widget.Button;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import java.io.IOException;
import java.nio.ShortBuffer;
import org.bytedeco.javacv.FFmpegFrameRecorder;
import static org.bytedeco.javacpp.opencv_core.*;
public class RecordActivity extends Activity implements OnClickListener {
private final static String CLASS_LABEL = "RecordActivity";
private final static String LOG_TAG = CLASS_LABEL;
private PowerManager.WakeLock mWakeLock;
private String ffmpeg_link = "/mnt/sdcard/stream.flv";
long startTime = 0;
boolean recording = false;
private volatile FFmpegFrameRecorder recorder;
private boolean isPreviewOn = false;
private int sampleAudioRateInHz = 44100;
private int imageWidth = 320;
private int imageHeight = 240;
private int frameRate = 30;
/* audio data getting thread */
private AudioRecord audioRecord;
private AudioRecordRunnable audioRecordRunnable;
private Thread audioThread;
volatile boolean runAudioThread = true;
/* video data getting thread */
private Camera cameraDevice;
private CameraView cameraView;
private IplImage yuvIplimage = null;
/* layout setting */
private final int bg_screen_bx = 232;
private final int bg_screen_by = 128;
private final int bg_screen_width = 700;
private final int bg_screen_height = 500;
private final int bg_width = 1123;
private final int bg_height = 715;
private final int live_width = 640;
private final int live_height = 480;
private int screenWidth, screenHeight;
private Button btnRecorderControl;
/** The number of seconds in the continuous record loop (or 0 to disable loop). */
final int RECORD_LENGTH = 10;
IplImage[] images;
long[] timestamps;
ShortBuffer[] samples;
int imagesIndex, samplesIndex;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
setContentView(R.layout.main);
PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE);
mWakeLock = pm.newWakeLock(PowerManager.SCREEN_BRIGHT_WAKE_LOCK, CLASS_LABEL);
mWakeLock.acquire();
initLayout();
}
@Override
protected void onResume() {
super.onResume();
if (mWakeLock == null) {
PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE);
mWakeLock = pm.newWakeLock(PowerManager.SCREEN_BRIGHT_WAKE_LOCK, CLASS_LABEL);
mWakeLock.acquire();
}
}
@Override
protected void onPause() {
super.onPause();
if (mWakeLock != null) {
mWakeLock.release();
mWakeLock = null;
}
}
@Override
protected void onDestroy() {
super.onDestroy();
recording = false;
if (cameraView != null) {
cameraView.stopPreview();
}
if(cameraDevice != null) {
cameraDevice.stopPreview();
cameraDevice.release();
cameraDevice = null;
}
if (mWakeLock != null) {
mWakeLock.release();
mWakeLock = null;
}
}
private void initLayout() {
/* get size of screen */
Display display = ((WindowManager) getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay();
screenWidth = display.getWidth();
screenHeight = display.getHeight();
RelativeLayout.LayoutParams layoutParam = null;
LayoutInflater myInflate = null;
myInflate = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
RelativeLayout topLayout = new RelativeLayout(this);
setContentView(topLayout);
LinearLayout preViewLayout = (LinearLayout) myInflate.inflate(R.layout.main, null);
layoutParam = new RelativeLayout.LayoutParams(screenWidth, screenHeight);
topLayout.addView(preViewLayout, layoutParam);
/* add control button: start and stop */
btnRecorderControl = (Button) findViewById(R.id.recorder_control);
btnRecorderControl.setText("Start");
btnRecorderControl.setOnClickListener(this);
/* add camera view */
int display_width_d = (int) (1.0 * bg_screen_width * screenWidth / bg_width);
int display_height_d = (int) (1.0 * bg_screen_height * screenHeight / bg_height);
int prev_rw, prev_rh;
if (1.0 * display_width_d / display_height_d > 1.0 * live_width / live_height) {
prev_rh = display_height_d;
prev_rw = (int) (1.0 * display_height_d * live_width / live_height);
} else {
prev_rw = display_width_d;
prev_rh = (int) (1.0 * display_width_d * live_height / live_width);
}
layoutParam = new RelativeLayout.LayoutParams(prev_rw, prev_rh);
layoutParam.topMargin = (int) (1.0 * bg_screen_by * screenHeight / bg_height);
layoutParam.leftMargin = (int) (1.0 * bg_screen_bx * screenWidth / bg_width);
cameraDevice = Camera.open();
Log.i(LOG_TAG, "cameara open");
cameraView = new CameraView(this, cameraDevice);
topLayout.addView(cameraView, layoutParam);
Log.i(LOG_TAG, "cameara preview start: OK");
}
//---------------------------------------
// initialize ffmpeg_recorder
//---------------------------------------
private void initRecorder() {
Log.w(LOG_TAG,"init recorder");
if (RECORD_LENGTH > 0) {
imagesIndex = 0;
images = new IplImage[RECORD_LENGTH * frameRate];
timestamps = new long[images.length];
for (int i = 0; i < images.length; i++) {
images[i] = IplImage.create(imageWidth, imageHeight, IPL_DEPTH_8U, 2);
timestamps[i] = -1;
}
} else if (yuvIplimage == null) {
yuvIplimage = IplImage.create(imageWidth, imageHeight, IPL_DEPTH_8U, 2);
Log.i(LOG_TAG, "create yuvIplimage");
}
Log.i(LOG_TAG, "ffmpeg_url: " + ffmpeg_link);
recorder = new FFmpegFrameRecorder(ffmpeg_link, imageWidth, imageHeight, 1);
recorder.setFormat("flv");
recorder.setSampleRate(sampleAudioRateInHz);
// Set in the surface changed method
recorder.setFrameRate(frameRate);
Log.i(LOG_TAG, "recorder initialize success");
audioRecordRunnable = new AudioRecordRunnable();
audioThread = new Thread(audioRecordRunnable);
runAudioThread = true;
}
public void startRecording() {
initRecorder();
try {
recorder.start();
startTime = System.currentTimeMillis();
recording = true;
audioThread.start();
} catch (FFmpegFrameRecorder.Exception e) {
e.printStackTrace();
}
}
public void stopRecording() {
runAudioThread = false;
try {
audioThread.join();
} catch (InterruptedException e) {
e.printStackTrace();
}
audioRecordRunnable = null;
audioThread = null;
if (recorder != null && recording) {
if (RECORD_LENGTH > 0) {
Log.v(LOG_TAG,"Writing frames");
try {
int firstIndex = imagesIndex % samples.length;
int lastIndex = (imagesIndex - 1) % images.length;
if (imagesIndex <= images.length) {
firstIndex = 0;
lastIndex = imagesIndex - 1;
}
if ((startTime = timestamps[lastIndex] - RECORD_LENGTH * 1000000L) < 0) {
startTime = 0;
}
if (lastIndex < firstIndex) {
lastIndex += images.length;
}
for (int i = firstIndex; i <= lastIndex; i++) {
long t = timestamps[i % timestamps.length] - startTime;
if (t >= 0) {
if (t > recorder.getTimestamp()) {
recorder.setTimestamp(t);
}
recorder.record(images[i % images.length]);
}
}
firstIndex = samplesIndex % samples.length;
lastIndex = (samplesIndex - 1) % samples.length;
if (samplesIndex <= samples.length) {
firstIndex = 0;
lastIndex = samplesIndex - 1;
}
if (lastIndex < firstIndex) {
lastIndex += samples.length;
}
for (int i = firstIndex; i <= lastIndex; i++) {
recorder.record(samples[i % samples.length]);
}
} catch (FFmpegFrameRecorder.Exception e) {
Log.v(LOG_TAG,e.getMessage());
e.printStackTrace();
}
}
recording = false;
Log.v(LOG_TAG,"Finishing recording, calling stop and release on recorder");
try {
recorder.stop();
recorder.release();
} catch (FFmpegFrameRecorder.Exception e) {
e.printStackTrace();
}
recorder = null;
}
}
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
if (keyCode == KeyEvent.KEYCODE_BACK) {
if (recording) {
stopRecording();
}
finish();
return true;
}
return super.onKeyDown(keyCode, event);
}
//---------------------------------------------
// audio thread, gets and encodes audio data
//---------------------------------------------
class AudioRecordRunnable implements Runnable {
@Override
public void run() {
android.os.Process.setThreadPriority(android.os.Process.THREAD_PRIORITY_URGENT_AUDIO);
// Audio
int bufferSize;
ShortBuffer audioData;
int bufferReadResult;
bufferSize = AudioRecord.getMinBufferSize(sampleAudioRateInHz,
AudioFormat.CHANNEL_IN_MONO, AudioFormat.ENCODING_PCM_16BIT);
audioRecord = new AudioRecord(MediaRecorder.AudioSource.MIC, sampleAudioRateInHz,
AudioFormat.CHANNEL_IN_MONO, AudioFormat.ENCODING_PCM_16BIT, bufferSize);
if (RECORD_LENGTH > 0) {
samplesIndex = 0;
samples = new ShortBuffer[RECORD_LENGTH * sampleAudioRateInHz * 2 / bufferSize + 1];
for (int i = 0; i < samples.length; i++) {
samples[i] = ShortBuffer.allocate(bufferSize);
}
} else {
audioData = ShortBuffer.allocate(bufferSize);
}
Log.d(LOG_TAG, "audioRecord.startRecording()");
audioRecord.startRecording();
/* ffmpeg_audio encoding loop */
while (runAudioThread) {
if (RECORD_LENGTH > 0) {
audioData = samples[samplesIndex++ % samples.length];
audioData.position(0).limit(0);
}
//Log.v(LOG_TAG,"recording? " + recording);
bufferReadResult = audioRecord.read(audioData.array(), 0, audioData.capacity());
audioData.limit(bufferReadResult);
if (bufferReadResult > 0) {
Log.v(LOG_TAG,"bufferReadResult: " + bufferReadResult);
// If "recording" isn't true when start this thread, it never get's set according to this if statement...!!!
// Why? Good question...
if (recording) {
if (RECORD_LENGTH <= 0) try {
recorder.record(audioData);
//Log.v(LOG_TAG,"recording " + 1024*i + " to " + 1024*i+1024);
} catch (FFmpegFrameRecorder.Exception e) {
Log.v(LOG_TAG,e.getMessage());
e.printStackTrace();
}
}
}
}
Log.v(LOG_TAG,"AudioThread Finished, release audioRecord");
/* encoding finish, release recorder */
if (audioRecord != null) {
audioRecord.stop();
audioRecord.release();
audioRecord = null;
Log.v(LOG_TAG,"audioRecord released");
}
}
}
//---------------------------------------------
// camera thread, gets and encodes video data
//---------------------------------------------
class CameraView extends SurfaceView implements SurfaceHolder.Callback, PreviewCallback {
private SurfaceHolder mHolder;
private Camera mCamera;
public CameraView(Context context, Camera camera) {
super(context);
Log.w("camera","camera view");
mCamera = camera;
mHolder = getHolder();
mHolder.addCallback(CameraView.this);
mHolder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);
mCamera.setPreviewCallback(CameraView.this);
}
@Override
public void surfaceCreated(SurfaceHolder holder) {
try {
stopPreview();
mCamera.setPreviewDisplay(holder);
} catch (IOException exception) {
mCamera.release();
mCamera = null;
}
}
public void surfaceChanged(SurfaceHolder holder, int format, int width, int height) {
Log.v(LOG_TAG,"Setting imageWidth: " + imageWidth + " imageHeight: " + imageHeight + " frameRate: " + frameRate);
Camera.Parameters camParams = mCamera.getParameters();
camParams.setPreviewSize(imageWidth, imageHeight);
Log.v(LOG_TAG,"Preview Framerate: " + camParams.getPreviewFrameRate());
camParams.setPreviewFrameRate(frameRate);
mCamera.setParameters(camParams);
startPreview();
}
@Override
public void surfaceDestroyed(SurfaceHolder holder) {
try {
mHolder.addCallback(null);
mCamera.setPreviewCallback(null);
} catch (RuntimeException e) {
// The camera has probably just been released, ignore.
}
}
public void startPreview() {
if (!isPreviewOn && mCamera != null) {
isPreviewOn = true;
mCamera.startPreview();
}
}
public void stopPreview() {
if (isPreviewOn && mCamera != null) {
isPreviewOn = false;
mCamera.stopPreview();
}
}
@Override
public void onPreviewFrame(byte[] data, Camera camera) {
if (audioRecord == null || audioRecord.getRecordingState() != AudioRecord.RECORDSTATE_RECORDING) {
startTime = System.currentTimeMillis();
return;
}
if (RECORD_LENGTH > 0) {
int i = imagesIndex++ % images.length;
yuvIplimage = images[i];
timestamps[i] = 1000 * (System.currentTimeMillis() - startTime);
}
/* get video data */
if (yuvIplimage != null && recording) {
yuvIplimage.getByteBuffer().put(data);
if (RECORD_LENGTH <= 0) try {
Log.v(LOG_TAG,"Writing Frame");
long t = 1000 * (System.currentTimeMillis() - startTime);
if (t > recorder.getTimestamp()) {
recorder.setTimestamp(t);
}
recorder.record(yuvIplimage);
} catch (FFmpegFrameRecorder.Exception e) {
Log.v(LOG_TAG,e.getMessage());
e.printStackTrace();
}
}
}
}
@Override
public void onClick(View v) {
if (!recording) {
startRecording();
Log.w(LOG_TAG, "Start Button Pushed");
btnRecorderControl.setText("Stop");
} else {
// This will trigger the audio recording loop to stop and then set isRecorderStart = false;
stopRecording();
Log.w(LOG_TAG, "Stop Button Pushed");
btnRecorderControl.setText("Start");
}
}
}I am getting this error
The type org.bytedeco.javacpp.avutil$AVFrame cannot be resolved. It is indirectly referenced from required .class files
at following line in the above code
if (RECORD_LENGTH <= 0) try {
recorder.record(audioData);
//Log.v(LOG_TAG,"recording " + 1024*i + " to " + 1024*i+1024);
}at recorder.record(audioData). I don’t know what I am doing wrong here. New to JavaCV. Any help will be appreciated.
-
How can I merge webm and wav file without using FFMpeg lib in PHP shared hosting ?
4 janvier 2015, par SarwarCSEI want to merge webm video with a WAV audio file. Is there any way to do that in shared php hosting ?
My final target is :
I have two files (Webm & WAV). I want to upload a video into youtube
programmatically. But my audio & video file are different. I have
only shared PHP server so I can’t use FFMpeg or node.js to merge. So
Is there any way to do this ?Please advice me.