
Recherche avancée
Autres articles (86)
-
Les tâches Cron régulières de la ferme
1er décembre 2010, parLa gestion de la ferme passe par l’exécution à intervalle régulier de plusieurs tâches répétitives dites Cron.
Le super Cron (gestion_mutu_super_cron)
Cette tâche, planifiée chaque minute, a pour simple effet d’appeler le Cron de l’ensemble des instances de la mutualisation régulièrement. Couplée avec un Cron système sur le site central de la mutualisation, cela permet de simplement générer des visites régulières sur les différents sites et éviter que les tâches des sites peu visités soient trop (...) -
Encoding and processing into web-friendly formats
13 avril 2011, parMediaSPIP automatically converts uploaded files to internet-compatible formats.
Video files are encoded in MP4, Ogv and WebM (supported by HTML5) and MP4 (supported by Flash).
Audio files are encoded in MP3 and Ogg (supported by HTML5) and MP3 (supported by Flash).
Where possible, text is analyzed in order to retrieve the data needed for search engine detection, and then exported as a series of image files.
All uploaded files are stored online in their original format, so you can (...) -
MediaSPIP Player : problèmes potentiels
22 février 2011, parLe lecteur ne fonctionne pas sur Internet Explorer
Sur Internet Explorer (8 et 7 au moins), le plugin utilise le lecteur Flash flowplayer pour lire vidéos et son. Si le lecteur ne semble pas fonctionner, cela peut venir de la configuration du mod_deflate d’Apache.
Si dans la configuration de ce module Apache vous avez une ligne qui ressemble à la suivante, essayez de la supprimer ou de la commenter pour voir si le lecteur fonctionne correctement : /** * GeSHi (C) 2004 - 2007 Nigel McNie, (...)
Sur d’autres sites (11712)
-
C++ h264 ffmpeg/libav encode/decode(lossless) issues
1er février 2017, par MrSmithInsights to encode/decode video with ffmpeg h264 (lossless)
So I got something working on the encoding part, encode an avi in 264 however VLC wont play it, however Totem will.
Decoding the same file proves troublesome. (I want the exact same data/frame going in as going out), I get these ;saving frame 5
Video decoding
[h264 @ 0x1d19880] decode_slice_header error
frame :6
saving frame 6
Video decoding
[h264 @ 0x1d19880] error while decoding MB 15 7, bytestream -27
[h264 @ 0x1d19880] concealing 194 DC, 194 AC, 194 MV errors in I frame
frame :7
saving frame 7
Video decoding
[h264 @ 0x1d19880] decode_slice_header errorand ultimatly this
[H264 Decoder @ 0x7f1320766040] frame :11
Broken frame packetizing
[h264 @ 0x1d19880] SPS changed in the middle of the frame
[h264 @ 0x1d19880] decode_slice_header error
[h264 @ 0x1d19880] no frame!
Error while decoding frame 11GAME OVER.
Now I suspect that I have to go back to 1. the encoding part, there is problary a good reason VLC wont play it !
I encode like this.
void encode(char *Y,char *U,char *V){
av_init_packet(&pkt);
pkt.data = NULL; // packet data will be allocated by the encoder
pkt.size = 0;
fflush(stdout);
frame->data[0] = (uint8_t*)Y;
frame->data[1] = (uint8_t*)U;
frame->data[2] = (uint8_t*)V;
frame->pts = ++i;
ret = avcodec_encode_video2(c, &pkt, frame, &got_output);
if (ret < 0) {
fprintf(stderr, "Error encoding frame\n");
exit (EXIT_FAILURE);
}
if (got_output) {
printf("Write frame %3d (size=%5d)\n", i, pkt.size);
fwrite(pkt.data, 1, pkt.size, f);
av_free_packet(&pkt);
}
}And the codec is setup like this :
AVCodecID dasd = AV_CODEC_ID_H264;
codec = avcodec_find_encoder(dasd);
c = avcodec_alloc_context3(codec);
c->bit_rate = 400000;
c->width = 320;
c->height = 240;
c->time_base= (AVRational){1,25};
c->gop_size = 10;
c->max_b_frames=1;
c->pix_fmt = AV_PIX_FMT_YUV420P;
av_opt_set(c->priv_data, "preset", "slow", 0);
avcodec_open2(c, codec, NULL);Since I am going for lossless i am not dealing with delayed frames(is this a correct assumption ?)
I may not actually be encoding lossless, it seems like I may have to go with something likeAVDictionary *param;
av_dict_set(&param, "qp", "0", 0);And then open...
So I guess me questions is these :
- What are the correct codec params for lossless encoding (and advice if h264 is a terrible idea in this regard).
- Do I need to handle delayed frames when going for lossless ?
- Why is VLC mad at me ?
Thanks.
-
path issues with FFMPEG Bash script to concat and encode across multiple subfolders
27 décembre 2022, par NoobCoderI'm trying to write a bash script for Mac OSx Terminal to compress a series of GoPro .MP4 videos from the SDcard directly into a smaller .MP4s on a local network server. The GoPro saves .MP4s in the 100GOPRO folder on the card. After filming, I will through that folder and manually put .MP4s from each game into subfolders within the 100GOPRO folder, named A1, A2, A3, etc.


Folder structure


/GoPro/DCIM/100GOPRO/
 -------/A1/
 -----GX01xxx1.mp4
 -----GX01xxx2.mp4
 -------/A2/
 -----GX01xxx3.mp4
 -----GX01xxx4.mp4
 -----GX01xxx5.mp4
 -----GX01xxx6.mp4



...etc


I would like then like to run a script from the 100GOPRO folder that will do these steps :


- 

- Within each subfolder, auto-create a file.txt with the names of the subfolder's .MP4s in the format to concat the files (each line has "file 'GX01xxx3.mp4'")
- Pass that subfolder's file.txt as the input to ffmpeg to reencode and save to a network folder with the name A1.mp4 or A2.mp4
- Repeat for each subfolder and quit.








I'm getting hung up on the dynamic path to the subfolder's file.txt. My code just creates a file.txt in the 100GOPRO folder, and appends all the subfolder contents into that single long combined text file. The output then would create a correct first MP4, but second MP4 contains folder 1 and 2, then 3 contains 1, 2, and 3, etc.


Here's the script I ran :


#!/bin/bash
for f in A*/*.mp4 ; do
echo file \'$f\' >> list.txt ;
done && ffmpeg -f concat -safe 0 -i list.txt /Volume/Server/Videos/A$f.mp4 && rm list.txt



Clearly, failing in how that path for echo to save in the subfolder A*, how to call that subfolder's file.txt as the input for ffmpeg, and how to name the output after the folder.


Thanks for any help you can offer.


-
Ffmpeg video and audio issues
17 décembre 2020, par ExpressingxI'm using ffmpeg
libav
and I have two problems. I'm automatically finding the decoder for audio and video input, but encoding to H264/AAC, always.

The first problem is that if the camera is capturing in low light the file gets messed up. E.g. If I record
12 secs
, the resulting file is indeed12 secs
, but the actual frames are playing till7 sec
and also it is 'fast-forwarded', like the speed isX2, X3
than the actual frame representation. While capturing with good light everything is fine. Not really sure what's happening.

Second problem is video and audio sync. First 10-15mins the synchronization is fine, but after that audio gradually falls behind. E.g. 1 hour file, at the end audio is behind 2-3 seconds.


Some code :


Creating decoders


private void CreateAudioDecoder()
 {
 AVCodecParameters* audioCodecParams = InputFormatContext->streams[AudioStreamIndex]->codecpar;
 AVCodec* audioDecoder = ffmpeg.avcodec_find_decoder(audioCodecParams->codec_id);

 AudioDecodeContext = ffmpeg.avcodec_alloc_context3(audioDecoder);

 if (ffmpeg.avcodec_parameters_to_context(AudioDecodeContext, audioCodecParams) < 0)
 {
 }

 if (ffmpeg.avcodec_open2(AudioDecodeContext, audioDecoder, null) < 0)
 {
 }
 }

 private void CreateVideoDecoder()
 {
 AVStream* videoStream = InputFormatContext->streams[VideoStreamIndex];
 AVCodecParameters* videoCodecParams = videoStream->codecpar;
 AVCodec* videoDecoder = ffmpeg.avcodec_find_decoder(videoCodecParams->codec_id);

 VideoDecodeContext = ffmpeg.avcodec_alloc_context3(videoDecoder);

 if (ffmpeg.avcodec_parameters_to_context(VideoDecodeContext, videoCodecParams) < 0)
 {
 }

 if (ffmpeg.avcodec_open2(VideoDecodeContext, videoDecoder, null) < 0)
 {
 }
 }



Input format context :


private AVFormatContext* CreateFormatContext()
 {
 AVDictionary* options = null;

 ffmpeg.av_dict_set(&options, "packet-buffering", "0", 0);
 ffmpeg.av_dict_set(&options, "sync", "1", 0);
 ffmpeg.av_dict_set(&options, "rtsp_transport", "tcp", 0);
 ffmpeg.av_dict_set(&options, "reconnect", "1", 0);
 ffmpeg.av_dict_set(&options, "max_delay", "0", 0);
 ffmpeg.av_dict_set(&options, "reorder_queue_size", "0", 0);
 ffmpeg.av_dict_set(&options, "skip_frame", "8", 0);
 ffmpeg.av_dict_set(&options, "skip_loop_filter", "48", 0);
 ffmpeg.av_dict_set(&options, "rtbufsize", "1500M", 0);

 AVFormatContext* pInputFmtCtx = ffmpeg.avformat_alloc_context();

 AVInputFormat* inputFormat = null;

 if (!string.IsNullOrEmpty(_format))
 {
 inputFormat = ffmpeg.av_find_input_format(_format);

 if (inputFormat == null)
 {
 }
 }

 int ret = ffmpeg.avformat_open_input(&pInputFmtCtx, _streamUrl, inputFormat, &options);

 if (ret != 0)
 {
 }

 return pInputFmtCtx;
 }



Output context


private AVFormatContext* CreateOutputContext()
 {
 AVFormatContext* pOutputFmtCtx = null;

 if (ffmpeg.avformat_alloc_output_context2(&pOutputFmtCtx, null, null, _fileName) != 0)
 {
 }

 return pOutputFmtCtx;
 }



Encoders


private void CreateH264Encoder(AVStream* inputStream, AVStream* outputStream)
 {
 AVRational framerate = ffmpeg.av_guess_frame_rate(_inputContext.InputFormatContext, inputStream, null);

 AVCodec* videoEncoder;
 videoEncoder = ffmpeg.avcodec_find_encoder_by_name("h264_qsv");
 if (videoEncoder == null)
 {
 videoEncoder = ffmpeg.avcodec_find_encoder_by_name("libx264");
 PixelFormat = AVPixelFormat.AV_PIX_FMT_YUV420P;
 }

 if (videoEncoder == null)
 {
 }

 VideoEncodeContext = ffmpeg.avcodec_alloc_context3(videoEncoder);

 if (VideoEncodeContext == null)
 {
 }

 VideoEncodeContext->width = _inputContext.VideoDecodeContext->width;
 VideoEncodeContext->height = _inputContext.VideoDecodeContext->height;
 VideoEncodeContext->pix_fmt = PixelFormat;
 VideoEncodeContext->bit_rate = H264_ENCODER_BIT_RATE; // 2 * 1000 * 1000
 VideoEncodeContext->rc_buffer_size = H264_ENCODER_BUFFER_SIZE; // 4 * 1000 * 1000
 VideoEncodeContext->rc_max_rate = H264_ENCODER_MAX_RATE; // 2 * 1000 * 1000
 VideoEncodeContext->rc_min_rate = H264_ENCODER_MIN_RATE; // 3 * 1000 * 1000
 VideoEncodeContext->framerate = framerate;
 VideoEncodeContext->max_b_frames = 0;
 VideoEncodeContext->time_base = ffmpeg.av_inv_q(framerate);
 VideoEncodeContext->flags |= ffmpeg.AV_CODEC_FLAG_GLOBAL_HEADER;

 ffmpeg.av_opt_set(VideoEncodeContext->priv_data, "preset", "slow", 0);
 ffmpeg.av_opt_set(VideoEncodeContext->priv_data, "vprofile", "baseline", 0);

 if (ffmpeg.avcodec_open2(VideoEncodeContext, videoEncoder, null) < 0)
 {
 }

 ffmpeg.avcodec_parameters_from_context(outputStream->codecpar, VideoEncodeContext);
 }

 private void CreateAacEncoder(AVStream* outStream)
 {
 AVCodec* audioEncoder = ffmpeg.avcodec_find_encoder(AVCodecID.AV_CODEC_ID_AAC);

 if (audioEncoder == null)

 AudioEncodeContext = ffmpeg.avcodec_alloc_context3(audioEncoder);

 if (AudioEncodeContext == null)

 AudioEncodeContext->bit_rate = 96000;
 AudioEncodeContext->sample_fmt = audioEncoder->sample_fmts[0];
 AudioEncodeContext->sample_rate = _inputContext.AudioDecodeContext->sample_rate;
 AudioEncodeContext->channel_layout = (ulong)ffmpeg.av_get_default_channel_layout(2);
 AudioEncodeContext->channels = 2;

 outStream->time_base.den = _inputContext.AudioDecodeContext->sample_rate;
 outStream->time_base.num = 1;

 AudioEncodeContext->flags |= ffmpeg.AV_CODEC_FLAG_GLOBAL_HEADER;

 if (ffmpeg.avcodec_open2(AudioEncodeContext, audioEncoder, null) < 0)

 ffmpeg.avcodec_parameters_from_context(outStream->codecpar, AudioEncodeContext);
 }



I would really appreciate any help.