
Recherche avancée
Médias (1)
-
Bug de détection d’ogg
22 mars 2013, par
Mis à jour : Avril 2013
Langue : français
Type : Video
Autres articles (2)
-
Sélection de projets utilisant MediaSPIP
29 avril 2011, parLes exemples cités ci-dessous sont des éléments représentatifs d’usages spécifiques de MediaSPIP pour certains projets.
Vous pensez avoir un site "remarquable" réalisé avec MediaSPIP ? Faites le nous savoir ici.
Ferme MediaSPIP @ Infini
L’Association Infini développe des activités d’accueil, de point d’accès internet, de formation, de conduite de projets innovants dans le domaine des Technologies de l’Information et de la Communication, et l’hébergement de sites. Elle joue en la matière un rôle unique (...) -
Selection of projects using MediaSPIP
2 mai 2011, parThe examples below are representative elements of MediaSPIP specific uses for specific projects.
MediaSPIP farm @ Infini
The non profit organizationInfini develops hospitality activities, internet access point, training, realizing innovative projects in the field of information and communication technologies and Communication, and hosting of websites. It plays a unique and prominent role in the Brest (France) area, at the national level, among the half-dozen such association. Its members (...)
Sur d’autres sites (2050)
-
How to start ffprobe with Windows PowerShell
7 mars 2014, par sebastianI am using Zeranoes FFmpeg Builds for Windows and I can start the ff-prompt without installing anything. But how do I start
ff-prompt.bat
with Windows PowerShell ? I have tried a few things likeInvoke-Expression
or changing the$env:Path
but nothing seems to work, because all I get is the message"C :\Users\Administrator>ECHO OFF
bin\ffmpeg.exe could not be found."
Is it even possible to start ff-prompt with PowerShell ? Every suggestion / solution is more than welcome.
My goal is to have a solution that works like this here :
http://spreadys.wordpress.com/2012/12/03/ffprobe-and-windows-powershell/but I want to do that automatically for all my clips, thats why I need to start ffprobe with powershell.
ECHO OFF
REM FF Prompt 1.1
REM Open a command prompt to run ffmpeg/ffplay/ffprobe
REM Copyright (C) 2013 Kyle Schwarz
TITLE FF Prompt
IF NOT EXIST bin\ffmpeg.exe (
CLS
ECHO bin\ffmpeg.exe could not be found.
GOTO:error
)
CD bin || GOTO:error
PROMPT $G
CLS
ffmpeg -version
SET PATH=%CD%;%PATH%
ECHO.
ECHO For help run: ffmpeg -h
ECHO For formats run: ffmpeg -formats ^| more
ECHO For codecs run: ffmpeg -codecs ^| more
ECHO.
ECHO Current directory is now: "%CD%"
ECHO The bin directory has been added to PATH
ECHO.
CMD /F:ON /Q /K
GOTO:EOF
:error
ECHO.
ECHO Press any key to exit.
PAUSE >nul
GOTO:EOFOkay I tried something a little bit different this time :
$env:Path = ';C:\Users\Administrator\bin\'
$title = "A_Day_for_Cake_and_Accidents"
Start-Process ff-prompt.bat -ArgumentList "ffprobe -show_streams -select_streams v -print_format xml -count_frames C:\Users\Administrator\Desktop\dcp_bearbeitet\$title\$title.mov > C:\Users\Administrator\Desktop\dcp_bearbeitet\$title\totalframes.xml"This creates a file called "totalframes.xml" but without the needed information, the only thing I get is :
C :\Users\Administrator>ECHO OFF
ffmpeg version N-60959-g669043d
built on Feb 27 2014 22:01:58 with gcc 4.8.2 (GCC)
configuration : —enable-gpl —enable-version3 —disable-w32threads —enable-avisynth —enable-bzlib —enable-fontconfig —enable-frei0r —enable-gnutls —enable-iconv —enable-libass —enable-libbluray —enable-libcaca —enable-libfreetype —enable-libgsm —enable-libilbc —enable-libmodplug —enable-libmp3lame —enable-libopencore-amrnb —enable-libopencore-amrwb —enable-libopenjpeg —enable-libopus —enable-librtmp —enable-libschroedinger —enable-libsoxr —enable-libspeex —enable-libtheora —enable-libtwolame —enable-libvidstab —enable-libvo-aacenc —enable-libvo-amrwbenc —enable-libvorbis —enable-libvpx —enable-libwavpack —enable-libx264 —enable-libx265 —enable-libxavs —enable-libxvid —enable-zlib
libavutil 52. 66.100 / 52. 66.100
libavcodec 55. 52.102 / 55. 52.102
libavformat 55. 33.100 / 55. 33.100
libavdevice 55. 10.100 / 55. 10.100
libavfilter 4. 2.100 / 4. 2.100
libswscale 2. 5.101 / 2. 5.101
libswresample 0. 18.100 / 0. 18.100
libpostproc 52. 3.100 / 52. 3.100
For help run : ffmpeg -h
For formats run : ffmpeg -formats | more
For codecs run : ffmpeg -codecs | more
Current directory is now : "C :\Users\Administrator\bin"
The bin directory has been added to PATHSo basically the console pops up, writes this standard text and does not use my commands which I stated in
-Argument-List
. I do not have a clue why it is ignoring most of my commands, except for writing everything in a XML file. -
Apple HLS with ffmpeg and mediastreamsegmenter and vlc
6 août 2015, par user3387312I’m trying to stream using a ffmpeg stream from a windows box. Here is the command I’m running on the windows box
ffmpeg -f dshow -i audio=”Wave In 2 32130101 (Orban Optim” -acodec libmp3lame -ab 64k -f mpegts udp ://172.30.16.181:2222 ?pkt_size=188 ?buffer_size=128000
This part works and I’m able to listen to it on my mac via VLC and I’m streaming it out from VLC to port 20103
but when I use mediasegmenter
mediastreamsegmenter -s 3 -f /Users/vickkrish/ 127.0.0.1:2222This is what happens
Mar 6 2014 04:11:02.926 : audio pid set at 44
Mar 6 2014 04:11:03.165 : audio pid change to 44
Mar 6 2014 04:11:03.328 : audio pid change to 44
Mar 6 2014 04:11:03.583 : audio pid change to 44
Mar 6 2014 04:11:03.745 : audio pid change to 44
Mar 6 2014 04:11:03.989 : audio pid change to 44
Mar 6 2014 04:11:04.151 : audio pid change to 44
Mar 6 2014 04:11:04.316 : audio pid change to 44
Mar 6 2014 04:11:04.492 : audio pid change to 44
Mar 6 2014 04:11:04.740 : audio pid change to 44
Mar 6 2014 04:11:04.887 : audio pid change to 44
Mar 6 2014 04:11:05.175 : audio pid change to 44
Mar 6 2014 04:11:05.338 : audio pid change to 44
Mar 6 2014 04:11:05.582 : audio pid change to 44and no .ts files are created.
-
Stuttering rendering using ffmpeg and sdl2
22 décembre 2020, par Wiesen_WalleWith the following Code I get a stuttering rendering of the movie file. Interesstingly, when dumping information with ffmpeg it says it has 25 fps and a duration of 00:01:32.90 ; however when counting the frames and time it runs by myself it gives a time of about 252 seconds, I guess the code receiving the frames and sending the package (int cap(vid v)) draws the same frame multiple of times. But I cannot see what's wrong ?


//PKG_CONFIG_PATH=/usr/local/lib/pkgconfig/:/usr/lib64/pkgconfig/ --> add path to PKF_Config search path
//export PKG_CONFIG_PATH --> export PKG_Config search path to become visible for gcc
//gcc ffmpeg_capture_fl.c -Wall -pedantic -fPIC `pkg-config --cflags --libs libavdevice libavformat libavcodec libavutil libavdevice libavfilter libswscale libswresample sdl2`


#include <libavdevice></libavdevice>avdevice.h>
#include <libavutil></libavutil>opt.h>
#include <libavformat></libavformat>avformat.h>
#include <libavcodec></libavcodec>avcodec.h>
#include <libswscale></libswscale>swscale.h>
#include <libavutil></libavutil>imgutils.h>
#include 
#include 
#include <libavutil></libavutil>rational.h>
#include <sys></sys>time.h>
#include 


typedef struct vid{
AVFormatContext *inc;
AVInputFormat *iformat;
AVCodecContext *pCodecCtx;
AVCodec *pCodec;
AVFrame *pFrame;
int videoStream;} vid;

typedef struct sws{
struct SwsContext *ctx;
uint8_t **buffer;
int *linesize;
} sws;


vid cap_init_fl(char *fl);
int cap(vid v);
void cap_close(vid v);

sws init_swsctx(int width, int height, enum AVPixelFormat pix_fmt, int new_width, int new_height, enum AVPixelFormat new_pxf);
void conv_pxlformat(sws scale, uint8_t **src_data, int *src_linesize, int height);
void free_sws(sws inp);

#include <sdl2></sdl2>SDL.h>

typedef struct sdl_window{
 SDL_Window *window;
 SDL_Renderer *renderer;
 SDL_Texture *texture;
 SDL_Event *event;
 int width;
 int height;
 int pitch;
 uint32_t sdl_pxl_frmt;
 }sdl_window;

sdl_window init_windowBGR24_ffmpg(int width, int height);
int render_on_texture_update(sdl_window wow, uint8_t *data);
void close_window(sdl_window wow);


vid cap_init_fl(char *fl){
 vid v = {NULL, NULL, NULL, NULL, NULL, -1};
 int i;
 
 av_register_all();
 avdevice_register_all();

 if( 0 > avformat_open_input( &(v.inc), fl , v.iformat, NULL)) {
 printf("Input device could not been opened\n");
 cap_close(v);
 exit(1);
 }

 if(avformat_find_stream_info(v.inc, NULL)<0){
 printf("Stream information could not been found.\n");
 cap_close(v);
 exit(2);
 }

 // Dump information about file onto standard error
 av_dump_format(v.inc, 0, fl, 0);

 // Find the first video stream
 v.videoStream=-1;
 for(i=0; inb_streams; i++){
 if(v.inc->streams[i]->codecpar->codec_type==AVMEDIA_TYPE_VIDEO) {
 v.videoStream=i;
 break;
 }}

 if(v.videoStream==-1){
 printf("Could not find video stream.\n");
 cap_close(v);
 exit(3);
 }

 // Find the decoder for the video stream
 v.pCodec=avcodec_find_decoder(v.inc->streams[v.videoStream]->codecpar->codec_id);
 if(v.pCodec==NULL) {
 printf("Unsupported codec!\n");
 cap_close(v);
 exit(4);
 // Codec not found
 }

 

 // Get a pointer to the codec context for the video stream
 
 if((v.pCodecCtx=avcodec_alloc_context3(NULL)) == NULL){
 printf("Could not allocate codec context\n");
 cap_close(v);
 exit(10);}

 avcodec_parameters_to_context (v.pCodecCtx, v.inc->streams[v.videoStream]->codecpar); 
 
 // Open codec
 if(avcodec_open2(v.pCodecCtx, v.pCodec, NULL)<0){
 printf("Could not open codec");
 cap_close(v);
 exit(5);
 }
 
 
 // Allocate video frame
 v.pFrame=av_frame_alloc();
 if(v.pFrame==NULL){
 printf("Could not allocate AVframe");
 cap_close(v);
 exit(6);}

 
 return v;
}



int cap(vid v){
 int errorCodeRF, errorCodeSP, errorCodeRecFR;
 AVPacket pkt;
 
 if((errorCodeRF = av_read_frame(v.inc, &pkt)) >= 0){
 
 if (pkt.stream_index == v.videoStream) {
 
 errorCodeSP = avcodec_send_packet(v.pCodecCtx, &pkt);
 
 if (errorCodeSP >= 0 || errorCodeSP == AVERROR(EAGAIN)){
 
 errorCodeRecFR = avcodec_receive_frame(v.pCodecCtx, v.pFrame);
 
 if (errorCodeRecFR < 0){ 
 av_packet_unref(&pkt);
 return errorCodeRecFR;
 }
 else{
 av_packet_unref(&pkt);
 return 0;
 }
 
 }
 else{
 av_packet_unref(&pkt);
 return errorCodeSP;}
 
 }}
 
 else{
 return errorCodeRF;}
 return 1;
 }
 
 

void cap_close(vid v){
 if(v.pFrame != NULL) av_free(v.pFrame);
 avcodec_close(v.pCodecCtx);
 avformat_close_input(&(v.inc));
 if(v.inc != NULL) avformat_free_context(v.inc);
 
 v.inc = NULL;
 v.iformat = NULL;
 v.pCodecCtx = NULL;
 v.pCodec = NULL;
 v.pFrame = NULL;
 v.videoStream=-1;}



sws init_swsctx(int width, int height, enum AVPixelFormat pix_fmt, int new_width, int new_height, enum AVPixelFormat new_pxf){

int nwidth, nheight;
sws scale;

scale.buffer = (uint8_t **) malloc(4 * sizeof(uint8_t *));
scale.linesize = (int *) malloc(4 * sizeof(int));


nwidth = (new_width <= 0) ? width : new_width;
nheight = (new_height <= 0) ? height : new_height;

av_image_alloc(scale.buffer, scale.linesize, nwidth, nheight, new_pxf, 1);
scale.ctx = sws_getContext(width, height, pix_fmt, nwidth, nheight, new_pxf, SWS_BILINEAR, NULL, NULL, NULL);

if(scale.ctx==NULL){
 printf("Could not allocate SWS-Context\n");
 av_freep(&(scale.buffer)[0]);
 free(scale.buffer);
 free(scale.linesize);
 exit(12);
 }
 
return scale;}


void conv_pxlformat(sws scale, uint8_t **src_data, int *src_linesize, int height){ 
 sws_scale(scale.ctx, (const uint8_t **) src_data, src_linesize, 0, height, scale.buffer, scale.linesize);
 }


void free_sws(sws inp){
 av_freep(&(inp.buffer)[0]);
 free(inp.buffer);
 free(inp.linesize); 
}


sdl_window init_windowBGR24_ffmpg(int width, int height){

 sdl_window wow;
 
 if (SDL_Init(SDL_INIT_VIDEO) < 0) {
 printf("Couldn't initialize SDL in function: create_sdl_window(...)\n");
 exit(7);}
 
 wow.window = SDL_CreateWindow("SDL_CreateTexture",
 SDL_WINDOWPOS_UNDEFINED,
 SDL_WINDOWPOS_UNDEFINED,
 width, height,
 SDL_WINDOW_RESIZABLE);

 wow.renderer = SDL_CreateRenderer(wow.window, -1, SDL_RENDERER_ACCELERATED);
 wow.texture = SDL_CreateTexture(wow.renderer, SDL_PIXELFORMAT_BGR24, SDL_TEXTUREACCESS_STREAMING, width, height);
 wow.width = width;
 wow.height = height;
 wow.pitch = width * 3; //only true for 3 byte / 24bit packed formats like bgr24
 wow.sdl_pxl_frmt = SDL_PIXELFORMAT_BGR24;
 SDL_SetHint(SDL_HINT_RENDER_SCALE_QUALITY, "linear"); 
 SDL_SetHint(SDL_HINT_RENDER_VSYNC, "enable"); 
 SDL_RenderSetLogicalSize(wow.renderer, wow.width, wow.height);
 return wow;
}


int render_on_texture_update(sdl_window wow, uint8_t *data){
 
 if (SDL_UpdateTexture(wow.texture, NULL, data, wow.pitch)< 0){
 printf("SDL_render_on_texture_update_failed: %s\n", SDL_GetError());
 return -1;
 }
 SDL_RenderClear(wow.renderer);
 SDL_RenderCopy(wow.renderer, wow.texture, NULL, NULL);
 SDL_RenderPresent(wow.renderer);

 return 0; 
}


void close_window(sdl_window wow){
 SDL_DestroyRenderer(wow.renderer);
 SDL_Quit();
}




int main(){
 int n, vid_error;
 long int time_per_frame_usec, duration_usec;
 vid v;
 sdl_window wow;
 struct timeval tval_start, tval_start1, tval_end, tval_duration;
 sws scale;
 SDL_Event event;
 
 vid_error = AVERROR(EAGAIN);
 v = cap_init_fl("mw_maze_test.mp4"); 
 
 while(vid_error == AVERROR(EAGAIN)){
 vid_error =cap(v);}
 
 if(vid_error < 0){
 printf("Could not read from Capture\n");
 cap_close(v);
 return 0;
 }

 wow = init_windowBGR24_ffmpg((v.pCodecCtx)->width, (v.pCodecCtx)->height);
 scale = init_swsctx((v.pCodecCtx)->width, (v.pCodecCtx)->height, (v.pCodecCtx)->pix_fmt, 0, 0, AV_PIX_FMT_BGR24);
 
 time_per_frame_usec = ((long int)((v.inc)->streams[v.videoStream]->avg_frame_rate.den) * 1000000 / (long int) ((v.inc)->streams[v.videoStream]->avg_frame_rate.num));
 
 printf("Time per frame: %ld\n", time_per_frame_usec);
 n = 0;
 
 gettimeofday(&tval_start, NULL);
 gettimeofday(&tval_start1, NULL);
 
 while ((vid_error =cap(v)) >= 0) {
 
 if (SDL_PollEvent(&event) != 0) {
 if (event.type == SDL_QUIT)
 break;}
 
 conv_pxlformat(scale, (v.pFrame)->data, (v.pFrame)->linesize, (v.pCodecCtx)->height);
 gettimeofday(&tval_end, NULL);
 timersub(&tval_end, &tval_start, &tval_duration);
 duration_usec = (long int)tval_duration.tv_sec * 1000000 + (long int)tval_duration.tv_usec;
 
 while(duration_usec < time_per_frame_usec) {
 gettimeofday(&tval_end, NULL);
 timersub(&tval_end, &tval_start, &tval_duration);
 duration_usec = (long int)tval_duration.tv_sec * 1000000 + (long int)tval_duration.tv_usec;
 }
 
 gettimeofday(&tval_start, NULL);
 render_on_texture_update(wow, *(scale.buffer)); 
 n++;
 }
 
 gettimeofday(&tval_end, NULL);
 timersub(&tval_end, &tval_start1, &tval_duration);
 duration_usec = (long int)tval_duration.tv_sec * 1000000 + (long int)tval_duration.tv_usec;
 
 printf("Total time and frames; %ld %i\n", duration_usec, n);
 
 if(vid_error == AVERROR(EAGAIN)){
 printf("AVERROR(EAGAIN) occured\n)");
 } 
 
 
 sws_freeContext(scale.ctx);
 free_sws(scale);
 close_window(wow);
 cap_close(v); 
 return 0; 
}




the output is:

Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'mw_maze_test.mp4':
 Metadata:
 major_brand : mp42
 minor_version : 0
 compatible_brands: isommp42
 creation_time : 2014-02-14T21:09:52.000000Z
 Duration: 00:01:32.90, start: 0.000000, bitrate: 347 kb/s
 Stream #0:0(und): Video: h264 (Constrained Baseline) (avc1 / 0x31637661), yuv420p, 384x288 [SAR 1:1 DAR 4:3], 249 kb/s, 25 fps, 25 tbr, 25 tbn, 50 tbc (default)
 Metadata:
 handler_name : VideoHandler
 Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 96 kb/s (default)
 Metadata:
 creation_time : 2014-02-14T21:09:53.000000Z
 handler_name : IsoMedia File Produced by Google, 5-11-2011
Time per frame: 40000
Total time and frames; 252881576 6322