
Recherche avancée
Médias (1)
-
Revolution of Open-source and film making towards open film making
6 octobre 2011, par
Mis à jour : Juillet 2013
Langue : English
Type : Texte
Autres articles (85)
-
Demande de création d’un canal
12 mars 2010, parEn fonction de la configuration de la plateforme, l’utilisateur peu avoir à sa disposition deux méthodes différentes de demande de création de canal. La première est au moment de son inscription, la seconde, après son inscription en remplissant un formulaire de demande.
Les deux manières demandent les mêmes choses fonctionnent à peu près de la même manière, le futur utilisateur doit remplir une série de champ de formulaire permettant tout d’abord aux administrateurs d’avoir des informations quant à (...) -
Websites made with MediaSPIP
2 mai 2011, parThis page lists some websites based on MediaSPIP.
-
La file d’attente de SPIPmotion
28 novembre 2010, parUne file d’attente stockée dans la base de donnée
Lors de son installation, SPIPmotion crée une nouvelle table dans la base de donnée intitulée spip_spipmotion_attentes.
Cette nouvelle table est constituée des champs suivants : id_spipmotion_attente, l’identifiant numérique unique de la tâche à traiter ; id_document, l’identifiant numérique du document original à encoder ; id_objet l’identifiant unique de l’objet auquel le document encodé devra être attaché automatiquement ; objet, le type d’objet auquel (...)
Sur d’autres sites (10312)
-
ffmpeg c++/cli wrapper for using in c# . AccessViolationException after call dll function by it's pointer
4 octobre 2017, par skynet_vMy target is to write a c++/cli wrap arount ffmpeg library, using by importing ffmpeg functions from dll-modules.
Later I will use this interface in c#.
This is my challenge, don’t ask me why))So i’ve implemented Wrap class, which is listed below :
namespace FFMpegWrapLib
{
public class Wrap
{
private:
public:
//wstring libavcodecDllName = "avcodec-56.dll";
//wstring libavformatDllName = "avformat-56.dll";
//wstring libswscaleDllName = "swscale-3.dll";
//wstring libavutilDllName = "avutil-54.dll";
HMODULE libavcodecDLL;
HMODULE libavformatDLL;
HMODULE libswsscaleDLL;
HMODULE libavutilDLL;
AVFormatContext **pFormatCtx = nullptr;
AVCodecContext *pCodecCtxOrig = nullptr;
AVCodecContext *pCodecCtx = nullptr;
AVCodec **pCodec = nullptr;
AVFrame **pFrame = nullptr;
AVFrame **pFrameRGB = nullptr;
AVPacket *packet = nullptr;
int *frameFinished;
int numBytes;
uint8_t *buffer = nullptr;
struct SwsContext *sws_ctx = nullptr;
void Init();
void AVRegisterAll();
void Release();
bool SaveFrame(const char *pFileName, AVFrame * frame, int w, int h);
bool GetStreamInfo();
int FindVideoStream();
bool OpenInput(const char* file);
AVCodec* FindDecoder();
AVCodecContext* AllocContext3();
bool CopyContext();
bool OpenCodec2();
AVFrame* AllocFrame();
int PictureGetSize();
void* Alloc(size_t size);
int PictureFill(AVPicture *, const uint8_t *, enum AVPixelFormat, int, int);
SwsContext* GetSwsContext(int, int, enum AVPixelFormat, int, int, enum AVPixelFormat, int, SwsFilter *, SwsFilter *, const double *);
int ReadFrame(AVFormatContext *s, AVPacket *pkt);
int DecodeVideo2(AVCodecContext *avctx, AVFrame *picture, int *got_picture_ptr, const AVPacket *avpkt);
int SwsScale(struct SwsContext *c, const uint8_t *const srcSlice[], const int srcStride[], int srcSliceY, int srcSliceH, uint8_t *const dst[], const int dstStride[]);
void PacketFree(AVPacket *pkt);
void BufferFree(void *ptr);
void FrameFree(AVFrame **frame);
int CodecClose(AVCodecContext *);
void CloseInput(AVFormatContext **);
bool SeekFrame(AVFormatContext *s, int stream_index, int64_t timestamp, int flags);
Wrap();
~Wrap();
bool GetVideoFrame(char* str_in_file, char* str_out_img, uint64_t time);
};
public ref class managedWrap
{
public:
managedWrap(){}
~managedWrap(){ delete unmanagedWrap; }
bool GetVideoFrameToFile(char* str_in_file, char* str_out_img, uint64_t time)
{
return unmanagedWrap->GetVideoFrame(str_in_file, str_out_img, time);
}
static Wrap* unmanagedWrap = new Wrap();
};
}So the imports to libavcodec and etc. are succesful.
The problem is in AccessViolationException during calling dll func, for example, in OpenInput (i.e. av_open_input in native ffmpeg library)The OpenInput func code is below :
bool FFMpegWrapLib::Wrap::OpenInput(const char* file)
{
typedef int avformat_open_input(AVFormatContext **, const char *, AVInputFormat *, AVDictionary **);
avformat_open_input* pavformat_open_input = (avformat_open_input *)GetProcAddress(libavformatDLL, "avformat_open_input");
if (pavformat_open_input == nullptr)
{
throw exception("Unable to find avformat_open_input function address in libavformat module");
return false;
}
//pin_ptr<avformatcontext> pinFormatContext = &(new interior_ptr<avformatcontext>(pCodecCtx));
pFormatCtx = new AVFormatContext*;
//*pFormatCtx = new AVFormatContext;
int ret = pavformat_open_input(pFormatCtx, file, NULL, NULL); // here it fails
return ret == 0;
}
</avformatcontext></avformatcontext>So the problem, i think, is that class-fields of Wrap class are in secure memory. And ffmpeg works with native memory, initialising pFormatCtx variable by it’s address.
Can I avoid this, or it is impossible ? -
Android : Select from images extracted with FFMPEG
21 juillet 2017, par TixI’m currently able to extract images(frames) from a video, and display all the extracted images using the code below, how do i make it so that the displayed images could be selected by user and passed as a bitmap to another activity ?
FFMPEG Compiled using
compile ’com.writingminds:FFmpegAndroid:0.3.2’
Complex Command used to get the frames/images
String[] complexCommand = "-y", "-i", yourRealPath, "-an", "-framerate", "60", "-vf", "select=’gte(n,45)’", "-vsync", "0", dest.getAbsolutePath() ;
Main Activity
/**
* Command for extracting images from video
*/
private void extractImagesVideo(int startMs, int endMs) {
File moviesDir = Environment.getExternalStoragePublicDirectory(
Environment.DIRECTORY_PICTURES
);
String filePrefix = "extract_picture";
String fileExtn = ".jpg";
String yourRealPath = getPath(MainActivity.this, selectedVideoUri);
File dir = new File(moviesDir, "VideoEditor");
int fileNo = 0;
while (dir.exists()) {
fileNo++;
dir = new File(moviesDir, "VideoEditor" + fileNo);
}
dir.mkdir();
filePath = dir.getAbsolutePath();
File dest = new File(dir, filePrefix + "%03d" + fileExtn);
Log.d(TAG, "startTrim: src: " + yourRealPath);
Log.d(TAG, "startTrim: dest: " + dest.getAbsolutePath());
String[] complexCommand = {"-y", "-i", yourRealPath, "-an", "-r", "1/2", "-ss", "" + startMs / 1000, "-t", "" + (endMs - startMs) / 1000, dest.getAbsolutePath()};
execFFmpegBinary(complexCommand);
}
/**
* Executing ffmpeg binary
*/
private void execFFmpegBinary(final String[] command) {
try {
ffmpeg.execute(command, new ExecuteBinaryResponseHandler() {
@Override
public void onFailure(String s) {
Log.d(TAG, "FAILED with output : " + s);
}
@Override
public void onSuccess(String s) {
Log.d(TAG, "SUCCESS with output : " + s);
if (choice == 1 || choice == 2 || choice == 5 || choice == 6 || choice == 7) {
Intent intent = new Intent(MainActivity.this, PreviewActivity.class);
intent.putExtra(FILEPATH, filePath);
startActivity(intent);
} else if (choice == 3) {
Intent intent = new Intent(MainActivity.this, PreviewImageActivity.class);
intent.putExtra(FILEPATH, filePath);
startActivity(intent);
} else if (choice == 4) {
Intent intent = new Intent(MainActivity.this, AudioPreviewActivity.class);
intent.putExtra(FILEPATH, filePath);
startActivity(intent);
} else if (choice == 8) {
choice = 9;
reverseVideoCommand();
} else if (Arrays.equals(command, lastReverseCommand)) {
choice = 10;
concatVideoCommand();
} else if (choice == 10) {
File moviesDir = Environment.getExternalStoragePublicDirectory(
Environment.DIRECTORY_MOVIES
);
File destDir = new File(moviesDir, ".VideoPartsReverse");
File dir = new File(moviesDir, ".VideoSplit");
if (dir.exists())
deleteDir(dir);
if (destDir.exists())
deleteDir(destDir);
choice = 11;
Intent intent = new Intent(MainActivity.this, PreviewActivity.class);
intent.putExtra(FILEPATH, filePath);
startActivity(intent);
}
}PreviewImageActivity
public class PreviewImageActivity extends AppCompatActivity {
private static final String FILEPATH = "filepath";
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_gallery);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
getSupportActionBar().setDisplayShowHomeEnabled(true);
TextView tvInstruction=(TextView)findViewById(R.id.tvInstruction) ;
GridLayoutManager lLayoutlLayout = new GridLayoutManager(PreviewImageActivity.this, 4);
RecyclerView rView = (RecyclerView)findViewById(R.id.recycler_view);
rView.setHasFixedSize(true);
rView.setLayoutManager(lLayoutlLayout);
String filePath = getIntent().getStringExtra(FILEPATH);
ArrayList<string> f = new ArrayList<string>();
File dir = new File(filePath);
tvInstruction.setText("Images stored at path "+filePath);
File[] listFile;
listFile = dir.listFiles();
for(File e:listFile)
{
f.add(e.getAbsolutePath());
}
PreviewImageAdapter rcAdapter = new PreviewImageAdapter( f);
rView.setAdapter(rcAdapter);
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
// handle arrow click here
if (item.getItemId() == android.R.id.home) {
finish(); // close this activity and return to preview activity (if there is any)
}
return super.onOptionsItemSelected(item);
}
}
</string></string>PreviewImageAdapter
public class PreviewImageAdapter extends RecyclerView.Adapter {
private ArrayList<string> paths;
public PreviewImageAdapter( ArrayList<string> paths) {
this.paths = paths;
}
@Override
public MyViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
View itemView = LayoutInflater.from(parent.getContext())
.inflate(R.layout.item_gallery, parent, false);
return new MyViewHolder(itemView);
}
@Override
public void onBindViewHolder(MyViewHolder holder, int position) {
Bitmap bmp = BitmapFactory.decodeFile(paths.get(position));
holder.ivPhoto.setImageBitmap(bmp);
}
@Override
public int getItemCount() {
return paths.size();
}
public class MyViewHolder extends RecyclerView.ViewHolder {
private ImageView ivPhoto;
public MyViewHolder(View itemView) {
super(itemView);
ivPhoto = (ImageView) itemView.findViewById(R.id.ivPhoto);
}
}
}
</string></string> -
A ffmpeg comman canwork in cmd but not in Python using subprocess.call() or os.system()
6 juin 2018, par StarryskyI wanna transfer a .mp3 to .wav. This is my command :
ffmpeg -i a.mp3 -ar 16000 -ac 1 -acodec pcm_s16le a.wav
It worked well in cmd
C:\Users\starrysky\Documents\GitHub\bing_pic\html>ffmpeg -i a.mp3 -ar 16000 -ac 1 -acodec pcm_s16le a.wav
ffmpeg version N-86482-gbc40674 Copyright (c) 2000-2017 the FFmpeg developers
built with gcc 7.1.0 (GCC)
configuration: --enable-gpl --enable-version3 --enable-cuda --enable-cuvid --enable-d3d11va --enable-dxva2 --enable-libmfx --enable-nvenc --enable-avisynth --enable-bzlib --enable-fontconfig --enable-frei0r --enable-gnutls --enable-iconv --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libfreetype --enable-libgme --enable-libgsm --enable-libilbc --enable-libmodplug --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenh264 --enable-libopenjpeg --enable-libopus --enable-librtmp --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvo-amrwbenc --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxavs --enable-libxvid --enable-libzimg --enable-lzma --enable-zlib
libavutil 55. 66.100 / 55. 66.100
libavcodec 57. 99.100 / 57. 99.100
libavformat 57. 73.100 / 57. 73.100
libavdevice 57. 7.100 / 57. 7.100
libavfilter 6. 92.100 / 6. 92.100
libswscale 4. 7.101 / 4. 7.101
libswresample 2. 8.100 / 2. 8.100
libpostproc 54. 6.100 / 54. 6.100
Input #0, mp3, from 'a.mp3':
Metadata:
encoder : Lavf54.6.100
Duration: 00:00:01.87, start: 0.000000, bitrate: 8 kb/s
Stream #0:0: Audio: mp3, 8000 Hz, mono, s16p, 8 kb/s
Stream mapping:
Stream #0:0 -> #0:0 (mp3 (native) -> pcm_s16le (native))
Press [q] to stop, [?] for help
Output #0, wav, to 'a.wav':
Metadata:
ISFT : Lavf57.73.100
Stream #0:0: Audio: pcm_s16le ([1][0][0][0] / 0x0001), 16000 Hz, mono, s16, 256 kb/s
Metadata:
encoder : Lavc57.99.100 pcm_s16le
size= 59kB time=00:00:01.87 bitrate= 256.3kbits/s speed= 187x
video:0kB audio:58kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.130208%but when I moved it into my python program, something strange happened.
>>> C:\Users\starrysky\Documents\GitHub\bing_pic\html\
'ffmpeg' �����ڲ����ⲿ���Ҳ���ǿ����еij���
�����������
1 Command 'ffmpeg -i a.mp3 -ar 16000 -ac 1 -acodec pcm_s16le a.wav' returned non-zero exit status 1.
文件错误啊,亲
[WinError 2] 系统找不到指定的文件。: 'a.wav'This is part of my python code :
@bot.register(wife, RECORDING)
def translate_sound(msg):
msg.get_file(save_path='a.mp3')
path = os.path.abspath('.')+'\\'
print(path)
try:
subprocess.check_call('ffmpeg -i a.mp3 -ar 16000 -ac 1 -acodec pcm_s16le a.wav', shell=True)
# ''
except Exception as e:
print(1, e)
wav_to_text('a.wav')
try:
os.remove('a.wav')
except Exception as e:
print(e)# 调用百度语音识别API
def get_token():
URL = 'http://openapi.baidu.com/oauth/2.0/token'
_params = urllib.parse.urlencode({'grant_type': b'client_credentials',
'client_id': b''
'client_secret': b''})
_res = urllib.request.Request(URL, _params.encode())
_response = urllib.request.urlopen(_res)
_data = _response.read()
_data = json.loads(_data)
return _data['access_token']
def wav_to_text(wav_file):
try:
wav_file = open(wav_file, 'rb')
except IOError:
print('文件错误啊,亲')
return
wav_file = wave.open(wav_file)
n_frames = wav_file.getnframes()
print('n_frames ', n_frames)
frame_rate = wav_file.getframerate()
print("frame_rate ", frame_rate)
if n_frames == 1 or frame_rate not in (8000, 16000):
print('不符合格式')
return
audio = wav_file.readframes(n_frames)
seconds = n_frames/frame_rate+1
minute = int(seconds/60 + 1)
for i in range(0, minute):
sub_audio = audio[i*60*frame_rate:(i+1)*60*frame_rate]
base_data = base64.b64encode(sub_audio)
data = {"format": "wav",
"token": get_token(),
"len": len(sub_audio),
"rate": frame_rate,
"speech": base_data.decode(),
"cuid": "B8-AC-6F-2D-7A-94",
"channel": 1}
data = json.dumps(data)
res = urllib.request.Request('http://vop.baidu.com/server_api',
data.encode(),
{'content-type': 'application/json'})
response = urllib.request.urlopen(res)
res_data = json.loads(response.read())
try:
print(res_data['result'][0])
except Exception as e:
print(e)What happened ?