
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 (91)
-
MediaSPIP v0.2
21 juin 2013, parMediaSPIP 0.2 est la première version de MediaSPIP stable.
Sa date de sortie officielle est le 21 juin 2013 et est annoncée ici.
Le fichier zip ici présent contient uniquement les sources de MediaSPIP en version standalone.
Comme pour la version précédente, il est nécessaire d’installer manuellement l’ensemble des dépendances logicielles sur le serveur.
Si vous souhaitez utiliser cette archive pour une installation en mode ferme, il vous faudra également procéder à d’autres modifications (...) -
Mise à disposition des fichiers
14 avril 2011, parPar défaut, lors de son initialisation, MediaSPIP ne permet pas aux visiteurs de télécharger les fichiers qu’ils soient originaux ou le résultat de leur transformation ou encodage. Il permet uniquement de les visualiser.
Cependant, il est possible et facile d’autoriser les visiteurs à avoir accès à ces documents et ce sous différentes formes.
Tout cela se passe dans la page de configuration du squelette. Il vous faut aller dans l’espace d’administration du canal, et choisir dans la navigation (...) -
MediaSPIP version 0.1 Beta
16 avril 2011, parMediaSPIP 0.1 beta est la première version de MediaSPIP décrétée comme "utilisable".
Le fichier zip ici présent contient uniquement les sources de MediaSPIP en version standalone.
Pour avoir une installation fonctionnelle, il est nécessaire d’installer manuellement l’ensemble des dépendances logicielles sur le serveur.
Si vous souhaitez utiliser cette archive pour une installation en mode ferme, il vous faudra également procéder à d’autres modifications (...)
Sur d’autres sites (9707)
-
FFmpeg Autogen and Unity C# to generate video from screenshots (FFmpeg.Autogen)
1er juin 2022, par cameron gibbsI've taken the
FFmpegHelper
,VideoFrameConverter
,H264VideoStreamEncoder
classes straight from the FFmpeg.AutoGen.Example, rolled my ownFFmpegBinariesHelper class
andSize struct
and mangled theEncodeImagesToH264
from Program.cs to look like the below code. I capture a bunch of frames into textures and feed them intoEncoder.EncodeImagesToH264
. It produces a file I'm callingoutputFileName.h264
just fine, no errors. I've changedH264VideoStreamEncoder
a little based on ffmpeg's own c++ examples because they had a few things it seemed the C# example was missing but that hasn't made any difference.

The video is weird :


- 

- it only plays in VLC, is there another
AVPixelFormat
I should be using for thedestinationPixelFormat
so that anything can play ? - VLC is unable to detect the video length or show current time
- it plays back weird as if the first few seconds are all the same frame then starts playing what appears to be some of the frames I'd expect








public static class Encoder
 {
 public static unsafe void EncodeImagesToH264(Texture2D[] images, int fps, string outputFileName)
 {
 FFmpegBinariesHelper.RegisterFFmpegBinaries();

 var fistFrameImage = images[0];
 outputFileName = Path.ChangeExtension(outputFileName, ".h264");
 var sourceSize = new Size(fistFrameImage.width, fistFrameImage.height);
 var sourcePixelFormat = AVPixelFormat.AV_PIX_FMT_RGB24;
 var destinationSize = sourceSize;
 var destinationPixelFormat = AVPixelFormat.AV_PIX_FMT_YUV420P;

 try
 {
 using (var vfc = new VideoFrameConverter(
 sourceSize,
 sourcePixelFormat,
 destinationSize,
 destinationPixelFormat))
 {
 using var fs = File.Open(outputFileName, FileMode.Create);
 using var vse = new H264VideoStreamEncoder(fs, fps, destinationSize);
 var frameNumber = 0;
 foreach (var frameFile in images)
 {
 var bitmapData = GetBitmapData(frameFile);

 //var pBitmapData = (byte*)NativeArrayUnsafeUtility
 // .GetUnsafeBufferPointerWithoutChecks(bitmapData);

 fixed (byte* pBitmapData = bitmapData)
 {
 var data = new byte_ptrArray8 { [0] = pBitmapData };
 var linesize = new int_array8 { [0] = bitmapData.Length / sourceSize.Height };
 var frame = new AVFrame
 {
 data = data,
 linesize = linesize,
 height = sourceSize.Height
 };

 var convertedFrame = vfc.Convert(frame);
 convertedFrame.pts = frameNumber;

 vse.Encode(convertedFrame);

 Debug.Log($"frame: {frameNumber}");
 frameNumber++;
 }
 }
 byte[] endcode = { 0, 0, 1, 0xb7 };
 fs.Write(endcode, 0, endcode.Length);
 }
 Debug.Log(outputFileName);
 }
 catch (Exception ex)
 {
 Debug.LogException(ex);
 }
 }

 private static byte[] GetBitmapData(Texture2D frameBitmap)
 {
 return frameBitmap.GetRawTextureData();
 }
 }

 public sealed unsafe class H264VideoStreamEncoder : IDisposable
 {
 private readonly Size _frameSize;
 private readonly int _linesizeU;
 private readonly int _linesizeV;
 private readonly int _linesizeY;
 private readonly AVCodec* _pCodec;
 private readonly AVCodecContext* _pCodecContext;
 private readonly Stream _stream;
 private readonly int _uSize;
 private readonly int _ySize;

 public H264VideoStreamEncoder(Stream stream, int fps, Size frameSize)
 {
 _stream = stream;
 _frameSize = frameSize;

 var codecId = AVCodecID.AV_CODEC_ID_H264;
 _pCodec = ffmpeg.avcodec_find_encoder(codecId);
 if (_pCodec == null)
 throw new InvalidOperationException("Codec not found.");

 _pCodecContext = ffmpeg.avcodec_alloc_context3(_pCodec);
 _pCodecContext->bit_rate = 400000;
 _pCodecContext->width = frameSize.Width;
 _pCodecContext->height = frameSize.Height;
 _pCodecContext->time_base = new AVRational { num = 1, den = fps };
 _pCodecContext->gop_size = 10;
 _pCodecContext->max_b_frames = 1;
 _pCodecContext->pix_fmt = AVPixelFormat.AV_PIX_FMT_YUV420P;

 if (codecId == AVCodecID.AV_CODEC_ID_H264)
 ffmpeg.av_opt_set(_pCodecContext->priv_data, "preset", "veryslow", 0);

 ffmpeg.avcodec_open2(_pCodecContext, _pCodec, null).ThrowExceptionIfError();

 _linesizeY = frameSize.Width;
 _linesizeU = frameSize.Width / 2;
 _linesizeV = frameSize.Width / 2;

 _ySize = _linesizeY * frameSize.Height;
 _uSize = _linesizeU * frameSize.Height / 2;
 }

 public void Dispose()
 {
 ffmpeg.avcodec_close(_pCodecContext);
 ffmpeg.av_free(_pCodecContext);
 }

 public void Encode(AVFrame frame)
 {
 if (frame.format != (int)_pCodecContext->pix_fmt)
 throw new ArgumentException("Invalid pixel format.", nameof(frame));
 if (frame.width != _frameSize.Width)
 throw new ArgumentException("Invalid width.", nameof(frame));
 if (frame.height != _frameSize.Height)
 throw new ArgumentException("Invalid height.", nameof(frame));
 if (frame.linesize[0] < _linesizeY)
 throw new ArgumentException("Invalid Y linesize.", nameof(frame));
 if (frame.linesize[1] < _linesizeU)
 throw new ArgumentException("Invalid U linesize.", nameof(frame));
 if (frame.linesize[2] < _linesizeV)
 throw new ArgumentException("Invalid V linesize.", nameof(frame));
 if (frame.data[1] - frame.data[0] < _ySize)
 throw new ArgumentException("Invalid Y data size.", nameof(frame));
 if (frame.data[2] - frame.data[1] < _uSize)
 throw new ArgumentException("Invalid U data size.", nameof(frame));

 var pPacket = ffmpeg.av_packet_alloc();
 try
 {
 int error;
 do
 {
 ffmpeg.avcodec_send_frame(_pCodecContext, &frame).ThrowExceptionIfError();
 ffmpeg.av_packet_unref(pPacket);
 error = ffmpeg.avcodec_receive_packet(_pCodecContext, pPacket);
 } while (error == ffmpeg.AVERROR(ffmpeg.EAGAIN));

 error.ThrowExceptionIfError();

 using var packetStream = new UnmanagedMemoryStream(pPacket->data, pPacket->size);
 packetStream.CopyTo(_stream);
 }
 finally
 {
 ffmpeg.av_packet_free(&pPacket);
 }
 }
 }



- it only plays in VLC, is there another
-
Mac Terminal (Bash) batch program to get multimedia file info using ffmpeg
7 décembre 2013, par julesverneI have a Mac computer. Usually all my batch programming is done on my PC. So I tried to create what I assumed would be a simple equivalent using a Mac shell. Obviously as you all know that was foolish of me to think that. After 2 days of scowering the web I found the closest thing I could to what I was looking for. But no, this doesn't work either.
All I'd like to do is throw a multimedia file onto the script, and have the terminal give me the ffmpeg info output. In my searching I did find this
"$@"
which as far as I can tell is the windows bat equivalent of%*
. Meaning you can throw files on the script and the script refers to those files as variables which can be processed. So I believe what I want to do is possible.Again the code at the bottom is just to look through the current directory of all .mov files and run ffmpeg. It doesn't work. But.. if no one can help me figure out the actual thing I'd like to do then I'd settle with something like below that does actually work.
#!/bin/bash
FFMPEG=/Applications/ffmpeg
FIND=/usr/bin/find
FILES=$(${FIND} . -type f -iname "*.mov")
if [ "$FILES" == "" ]
then
echo "There are no *.mov file in $(pwd) directory"
exit 1
fi
for f in *.mov
do
$FFMPEG -i "$f"
doneIf someone can please help me figure this out I'd really appreciate it. Thank you in advance ! Jules
I just found this solution from the "similar questions" sidebar, which is similar to the script above, so again, not completely what I wanted but.. didn't matter, didn't work for me. How to batch convert mp4 files to ogg with ffmpeg using a bash command or Ruby
-
iOS FFmpeg : Requested output format 'flv' is not a suitable output format
14 novembre 2013, par user2992563I just upgraded my iOS compiled FFmpeg library to 1.2.1 and now I'm getting the following error message :
Requested output format 'flv' is not a suitable output format.I tried changing format to 'avi' and 'mov' aswell, but it seems that no matter the format_name I pass I get the same error message.
This is how I set up the format_name :
avformat_alloc_output_context2(&file, NULL, "flv", cname)
And this is how I write the stream packets :
// Appends a data packet to the rtmp stream
-(bool) writePacket: (Demuxer *) source
{
int code = 0;
AVCodecContext
*videoCodec = [source videoCodec],
*audioCodec = [source audioCodec];
// Write headers
if(useHeaders)
{
AVStream
*video = av_new_stream(file, VIDEO_STREAM),
*audio = av_new_stream(file, AUDIO_STREAM);
if (!video || !audio)
@throw [NSException exceptionWithName: @"StreamingError" reason: @"Could not allocate streams" userInfo: nil];
// Clone input codecs and extra data
memcpy(video->codec, videoCodec, sizeof(AVCodecContext));
memcpy(audio->codec, audioCodec, sizeof(AVCodecContext));
video->codec->extradata = av_malloc(video->codec->extradata_size);
audio->codec->extradata = av_malloc(audio->codec->extradata_size);
memcpy(video->codec->extradata, videoCodec->extradata, video->codec->extradata_size);
memcpy(audio->codec->extradata, audioCodec->extradata, audio->codec->extradata_size);
// Use FLV codec tags
video->codec->codec_tag = FLV_TAG_TYPE_VIDEO;
audio->codec->codec_tag = FLV_TAG_TYPE_AUDIO;
video->codec->flags |= CODEC_FLAG_GLOBAL_HEADER;
video->codec->flags |= CODEC_FLAG_GLOBAL_HEADER;
audio->codec->sample_rate = INPUT_AUDIO_SAMPLING_RATE;
// Update time base
video->codec->time_base.num = 1;
audio->codec->time_base.den = video->codec->time_base.den = FLV_TIMEBASE;
// Signal bitwise stream copying
//video->stream_copy = audio->stream_copy = 1;
if((code = avformat_write_header(file, NULL)))
@throw [NSException exceptionWithName: @"StreamingError" reason: @"Could not write stream headers" userInfo: nil];
useHeaders = NO;
}
bool isVideo;
AVPacket *packet = [source readPacket: &isVideo];
if(!packet)
return NO;
if(isVideo)
{
packet->stream_index = VIDEO_STREAM;
packet->dts = packet->pts = videoPosition;
videoPosition += packet->duration = FLV_TIMEBASE * packet->duration * videoCodec->ticks_per_frame * videoCodec->time_base.num / videoCodec->time_base.den;
}
else
{
packet->stream_index = AUDIO_STREAM;
packet->dts = packet->pts = audioPosition;
audioPosition += packet->duration = FLV_TIMEBASE * packet->duration / INPUT_AUDIO_SAMPLING_RATE;
}
packet->pos = -1;
packet->convergence_duration = AV_NOPTS_VALUE;
// This sometimes fails without being a critical error, so no exception is raised
if((code = av_interleaved_write_frame(file, packet)))
NSLog(@"Streamer::Couldn't write frame");
av_free_packet(packet);
return YES;
}In the code above I had to comment out this line as stream_copy has been removed from the newest version of FFmpeg :
video->stream_copy = audio->stream_copy = 1;
Any help would be greatly appreciated !