
Recherche avancée
Médias (91)
-
Spitfire Parade - Crisis
15 mai 2011, par
Mis à jour : Septembre 2011
Langue : English
Type : Audio
-
Wired NextMusic
14 mai 2011, par
Mis à jour : Février 2012
Langue : English
Type : Video
-
Video d’abeille en portrait
14 mai 2011, par
Mis à jour : Février 2012
Langue : français
Type : Video
-
Sintel MP4 Surround 5.1 Full
13 mai 2011, par
Mis à jour : Février 2012
Langue : English
Type : Video
-
Carte de Schillerkiez
13 mai 2011, par
Mis à jour : Septembre 2011
Langue : English
Type : Texte
-
Publier une image simplement
13 avril 2011, par ,
Mis à jour : Février 2012
Langue : français
Type : Video
Autres articles (52)
-
MediaSPIP Core : La Configuration
9 novembre 2010, parMediaSPIP Core fournit par défaut trois pages différentes de configuration (ces pages utilisent le plugin de configuration CFG pour fonctionner) : une page spécifique à la configuration générale du squelettes ; une page spécifique à la configuration de la page d’accueil du site ; une page spécifique à la configuration des secteurs ;
Il fournit également une page supplémentaire qui n’apparait que lorsque certains plugins sont activés permettant de contrôler l’affichage et les fonctionnalités spécifiques (...) -
Les formats acceptés
28 janvier 2010, parLes commandes suivantes permettent d’avoir des informations sur les formats et codecs gérés par l’installation local de ffmpeg :
ffmpeg -codecs ffmpeg -formats
Les format videos acceptés en entrée
Cette liste est non exhaustive, elle met en exergue les principaux formats utilisés : h264 : H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10 m4v : raw MPEG-4 video format flv : Flash Video (FLV) / Sorenson Spark / Sorenson H.263 Theora wmv :
Les formats vidéos de sortie possibles
Dans un premier temps on (...) -
Ajouter notes et légendes aux images
7 février 2011, parPour pouvoir ajouter notes et légendes aux images, la première étape est d’installer le plugin "Légendes".
Une fois le plugin activé, vous pouvez le configurer dans l’espace de configuration afin de modifier les droits de création / modification et de suppression des notes. Par défaut seuls les administrateurs du site peuvent ajouter des notes aux images.
Modification lors de l’ajout d’un média
Lors de l’ajout d’un média de type "image" un nouveau bouton apparait au dessus de la prévisualisation (...)
Sur d’autres sites (8815)
-
ffmpeg "Time code of first frame" not making sense [closed]
23 janvier, par Kevin VaskoI can't seem to make sense of where ffmpeg is coming up with the "Time code of first frame" value.


My original file that I am using.


This video has the general timestamps of the original encoding date (aka the start time of the video the way I understanding it) and a duration of 8 min and 52s


$ mediainfo GL0100002_output.mp4 
General
Complete name : GL0100002_output.mp4
Format : MPEG-4
Format profile : Base Media
Codec ID : isom (isom/iso2/avc1/mp41)
File size : 93.7 MiB
Duration : 8 min 52 s
Overall bit rate : 1 476 kb/s
Encoded date : UTC 2022-02-23 15:18:42
Tagged date : UTC 2022-02-23 15:18:42
Writing application : Lavf58.29.100

Video
ID : 1
Format : AVC
Format/Info : Advanced Video Codec
Format profile : High@L3
Format settings : CABAC / 4 Ref Frames
Format settings, CABAC : Yes
Format settings, Reference frames : 4 frames
Codec ID : avc1
Codec ID/Info : Advanced Video Coding
Duration : 8 min 52 s
Bit rate : 1 342 kb/s
Width : 848 pixels
Height : 480 pixels
Display aspect ratio : 16:9
Frame rate mode : Constant
Frame rate : 23.976 (24000/1001) FPS
Color space : YUV
Chroma subsampling : 4:2:0
Bit depth : 8 bits
Scan type : Progressive
Bits/(Pixel*Frame) : 0.138
Stream size : 85.2 MiB (91%)
Title : GoPro AVC 
Writing library : x264 core 155 r2917 0a84d98
Encoding settings : cabac=1 / ref=3 / deblock=1:0:0 / analyse=0x3:0x113 / me=hex / subme=7 / psy=1 / psy_rd=1.00:0.00 / mixed_ref=1 / me_range=16 / chroma_me=1 / trellis=1 / 8x8dct=1 / cqm=0 / deadzone=21,11 / fast_pskip=1 / chroma_qp_offset=-2 / threads=12 / lookahead_threads=2 / sliced_threads=0 / nr=0 / decimate=1 / interlaced=0 / bluray_compat=0 / constrained_intra=0 / bframes=3 / b_pyramid=2 / b_adapt=1 / b_bias=0 / direct=1 / weightb=1 / open_gop=0 / weightp=2 / keyint=250 / keyint_min=23 / scenecut=40 / intra_refresh=0 / rc_lookahead=40 / rc=crf / mbtree=1 / crf=23.0 / qcomp=0.60 / qpmin=0 / qpmax=69 / qpstep=4 / ip_ratio=1.40 / aq=1:1.00
Language : English
Encoded date : UTC 2022-02-23 15:18:42
Tagged date : UTC 2022-02-23 15:18:42
Color range : Full
Codec configuration box : avcC

Audio
ID : 2
Format : AAC LC
Format/Info : Advanced Audio Codec Low Complexity
Codec ID : mp4a-40-2
Duration : 8 min 52 s
Bit rate mode : Constant
Bit rate : 129 kb/s
Channel(s) : 2 channels
Channel layout : L R
Sampling rate : 48.0 kHz
Frame rate : 46.875 FPS (1024 SPF)
Compression mode : Lossy
Stream size : 8.16 MiB (9%)
Title : GoPro AAC 
Language : English
Default : Yes
Alternate group : 1
Encoded date : UTC 2022-02-23 15:18:42
Tagged date : UTC 2022-02-23 15:18:42

Other
ID : 3
Type : Time code
Format : QuickTime TC
Duration : 8 min 52 s
Frame rate : 23.976 (24000/1001) FPS
Time code of first frame : 15:57:41:15
Time code, striped : Yes
Title : GoPro AVC 
Language : English
Default : No
Encoded date : UTC 2022-02-23 15:18:42
Tagged date : UTC 2022-02-23 15:18:42



Now if I run


ffmpeg -y -nostdin -v error -ss 00:00:00.042 -i GL0100002_output.mp4 -t 00:00:25.192 -map 0 -map -0:d -c:v libx264 -preset fast -crf 21 -c:a aac -sn GL0100002_test.DSME_0001.mp4


I get the following mediainfo


$ mediainfo GL0100002_test.DSME_0001.mp4 
General
Complete name : GL0100002_test.DSME_0001.mp4
Format : MPEG-4
Format profile : Base Media
Codec ID : isom (isom/iso2/avc1/mp41)
File size : 4.54 MiB
Duration : 25 s 234 ms
Overall bit rate : 1 510 kb/s
Writing application : Lavf58.29.100

Video
ID : 1
Format : AVC
Format/Info : Advanced Video Codec
Format profile : High@L3
Format settings : CABAC / 4 Ref Frames
Format settings, CABAC : Yes
Format settings, Reference frames : 4 frames
Codec ID : avc1
Codec ID/Info : Advanced Video Coding
Duration : 25 s 234 ms
Bit rate : 1 376 kb/s
Width : 848 pixels
Height : 480 pixels
Display aspect ratio : 16:9
Frame rate mode : Constant
Frame rate : 23.976 (24000/1001) FPS
Color space : YUV
Chroma subsampling : 4:2:0
Bit depth : 8 bits
Scan type : Progressive
Bits/(Pixel*Frame) : 0.141
Stream size : 4.14 MiB (91%)
Title : GoPro AVC 
Writing library : x264 core 155 r2917 0a84d98
Encoding settings : cabac=1 / ref=2 / deblock=1:0:0 / analyse=0x3:0x113 / me=hex / subme=6 / psy=1 / psy_rd=1.00:0.00 / mixed_ref=1 / me_range=16 / chroma_me=1 / trellis=1 / 8x8dct=1 / cqm=0 / deadzone=21,11 / fast_pskip=1 / chroma_qp_offset=-2 / threads=12 / lookahead_threads=2 / sliced_threads=0 / nr=0 / decimate=1 / interlaced=0 / bluray_compat=0 / constrained_intra=0 / bframes=3 / b_pyramid=2 / b_adapt=1 / b_bias=0 / direct=1 / weightb=1 / open_gop=0 / weightp=1 / keyint=250 / keyint_min=23 / scenecut=40 / intra_refresh=0 / rc_lookahead=30 / rc=crf / mbtree=1 / crf=21.0 / qcomp=0.60 / qpmin=0 / qpmax=69 / qpstep=4 / ip_ratio=1.40 / aq=1:1.00
Language : English
Color range : Full
Codec configuration box : avcC

Audio
ID : 2
Format : AAC LC
Format/Info : Advanced Audio Codec Low Complexity
Codec ID : mp4a-40-2
Duration : 25 s 214 ms
Duration_LastFrame : -3 ms
Bit rate mode : Constant
Bit rate : 129 kb/s
Channel(s) : 2 channels
Channel layout : L R
Sampling rate : 48.0 kHz
Frame rate : 46.875 FPS (1024 SPF)
Compression mode : Lossy
Stream size : 398 KiB (9%)
Title : GoPro AAC 
Language : English
Default : Yes
Alternate group : 1

Other
ID : 3
Type : Time code
Format : QuickTime TC
Duration : 25 s 234 ms
Frame rate : 23.976 (24000/1001) FPS
Time code of first frame : 15:57:41:15
Time code, striped : Yes
Title : GoPro AVC 
Language : English
Default : No



But what I don't understand is where
Time code of first frame
is coming from. I would expect it would be00:00:00.042
or evenUTC 2022-02-23 15:18:42
+ .042 but appear to be.

Time code of first frame : 15:57:41:15



Is this potentially clobbering together something to get this time that isn't obvious ?


-
Using Accord.Video.FFMPEG, I get "parameter is not valid exception". How can I solve it ?
31 mai 2023, par Sheron BlumentalI want to extract all the frames from an MP4 video file and display them on a PictureBox.


The original code comes from this Q&A : How can I time the presentation and extraction of frames from a video file ?


The exception happens after clicking the start button on the line :


var frame = videoReader.ReadVideoFrame();



The message


System.ArgumentException
 HResult=0x80070057
 Message=Parameter is not valid.
 Source=System.Drawing
 StackTrace:
 at System.Drawing.Bitmap..ctor(Int32 width, Int32 height, PixelFormat format)
 at Accord.Video.FFMPEG.VideoFileReader.DecodeVideoFrame(BitmapData bitmapData)
 at Accord.Video.FFMPEG.VideoFileReader.readVideoFrame(Int32 frameIndex, BitmapData output)
 at Accord.Video.FFMPEG.VideoFileReader.ReadVideoFrame()
 at Extract_Frames.Form1.<getvideoframesasync>d__15.MoveNext() in D:\Csharp Projects\Extract Frames\Form1.cs:line 114
 at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
 at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
 at System.Runtime.CompilerServices.TaskAwaiter.GetResult()
 at Extract_Frames.Form1.d__17.MoveNext() in D:\Csharp Projects\Extract Frames\Form1.cs:line 151
</getvideoframesasync>


The full code


using Accord.IO;
using Accord.Video;
using Accord.Video.FFMPEG;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Reflection.Emit;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace Extract_Frames
{
 public partial class Form1 : Form
 {
 Bitmap frame = null;
 Graphics frameGraphics = null;
 bool isVideoRunning = false;
 IProgress<bitmap> videoProgress = null;
 private CancellationTokenSource cts = null;
 private readonly object syncRoot = new object();
 private static long pause = 0;
 private int frameRate = 0;
 private List<bitmap> frames = new List<bitmap>();
 string fileName;

 public Form1()
 {
 InitializeComponent();

 }

 private void Form1_Load(object sender, EventArgs e)
 {

 }

 private void StopPlayback(bool cancel)
 {
 lock (syncRoot)
 {
 if (cancel) cts?.Cancel();
 cts?.Dispose();
 cts = null;
 }
 }

 int counter =1;
 private void Updater(Bitmap videoFrame)
 {
 frames.Add(videoFrame);

 label1.Text = "Current Frame Number : " + counter;
 trackBar1.Value = counter;
 counter++;

 //Size size = new Size(videoFrame.Width, videoFrame.Height);
 //pictureBox1.ClientSize = size;
 using (videoFrame) frameGraphics.DrawImage(videoFrame, Point.Empty);

 pictureBox1.Invalidate();
 }

 private async Task GetVideoFramesAsync(IProgress<bitmap> updater, string fileName, int intervalMs, CancellationToken token = default)
 {
 using (var videoReader = new VideoFileReader())
 {
 if (token.IsCancellationRequested) return;
 videoReader.Open(fileName);

 videoReader.ReadVideoFrame(1);
 trackBar1.Value = 1;

 label1.Text = "Current Frame Number : " + counter.ToString();

 while (true)
 {
 if (Interlocked.Read(ref pause) == 0)
 {
 var frame = videoReader.ReadVideoFrame();

 if (token.IsCancellationRequested || frame is null) break;
 updater.Report(frame);
 }
 await Task.Delay(frameRate).ConfigureAwait(false);
 }
 }
 }

 private void trackBar2_Scroll(object sender, EventArgs e)
 {
 frameRate = trackBar2.Value / 25;
 }

 private async void buttonStart_Click(object sender, EventArgs e)
 {
 string fileName = textBox1.Text;

 if (isVideoRunning) return;
 isVideoRunning = true;

 using (var videoReader = new VideoFileReader())
 {
 videoReader.Open(fileName);
 frame = new Bitmap(videoReader.Width + 2, videoReader.Height + 2);
 trackBar1.Maximum = (int)videoReader.FrameCount;
 }

 videoProgress = new Progress<bitmap>((bitmap) => Updater(bitmap));
 cts = new CancellationTokenSource();
 pictureBox1.Image = frame;
 try
 {
 frameGraphics = Graphics.FromImage(frame);
 // Set the fame rate to 25 frames per second
 //int frameRate = 1000 / 25;
 await GetVideoFramesAsync(videoProgress, fileName, frameRate, cts.Token);
 }
 finally
 {
 frameGraphics?.Dispose();
 StopPlayback(false);
 isVideoRunning = false;
 }
 }

 private void buttonPause_Click(object sender, EventArgs e)
 {
 if (pause == 0)
 {
 buttonPause.Text = "Resume";
 Interlocked.Increment(ref pause);
 }
 else
 {
 Interlocked.Decrement(ref pause);
 buttonPause.Text = "Pause";
 }
 }

 private void buttonStop_Click(object sender, EventArgs e)
 {
 StopPlayback(true);
 }

 protected override void OnFormClosing(FormClosingEventArgs e)
 {
 if (isVideoRunning) StopPlayback(true);
 pictureBox1.Image?.Dispose();
 base.OnFormClosing(e);
 }

 private void pictureBox1_Paint(object sender, PaintEventArgs e)
 {
 ControlPaint.DrawBorder(e.Graphics, pictureBox1.ClientRectangle, Color.Red, ButtonBorderStyle.Solid);
 }

 private void trackBar1_Scroll(object sender, EventArgs e)
 {
 pictureBox1.Image = frames[trackBar1.Value];
 }

 private void button1_Click(object sender, EventArgs e)
 {
 using (OpenFileDialog openFileDialog = new OpenFileDialog())
 {
 openFileDialog.InitialDirectory = "c:\\";
 openFileDialog.Filter = "video files (*.mp4)|*.mp4|All files (*.*)|*.*";
 openFileDialog.FilterIndex = 2;
 openFileDialog.RestoreDirectory = true;

 if (openFileDialog.ShowDialog() == DialogResult.OK)
 {
 // Get the path of specified file
 textBox1.Text = openFileDialog.FileName;
 }
 }
 }
 }
}
</bitmap></bitmap></bitmap></bitmap></bitmap>


-
Why there is no AVFrame->data[2] data when decode h264 by ffmpeg use "h264_cuvid"
27 juillet 2017, par Wu NLenv : ubuntu 16.04 64 bit ; ffmpeg 3.3.2 build whih cuda cuvid libnpp...
use ffmpeg cmd :ffmpeg -vsync 0 -c:v h264_cuvid -i test.264 -f rawvideo test.yuv
works fine, the generated yuv file is ok.
BUT When I decode this 264 file by my code use ’h264_cuvid’ decoder, something problem happens, this is my code :#include
#define __STDC_CONSTANT_MACROS
#ifdef _WIN32
//Windows
extern "C"
{
#include "libavcodec/avcodec.h"
};
#else
//Linux...
#ifdef __cplusplus
extern "C"
{
#endif
#include <libavcodec></libavcodec>avcodec.h>
#ifdef __cplusplus
};
#endif
#endif
//test different codec
#define TEST_H264 1
#define TEST_HEVC 0
int main(int argc, char* argv[])
{
AVCodec *pCodec;
AVCodecContext *pCodecCtx= NULL;
AVCodecParserContext *pCodecParserCtx=NULL;
FILE *fp_in;
FILE *fp_out;
AVFrame *pFrame;
const int in_buffer_size=4096;
unsigned char in_buffer[in_buffer_size + FF_INPUT_BUFFER_PADDING_SIZE]= {0};
unsigned char *cur_ptr;
int cur_size;
AVPacket packet;
int ret, got_picture;
#if TEST_HEVC
enum AVCodecID codec_id=AV_CODEC_ID_HEVC;
char filepath_in[]="bigbuckbunny_480x272.hevc";
#elif TEST_H264
AVCodecID codec_id=AV_CODEC_ID_H264;
char filepath_in[]="2_60_265to264.264";
#else
AVCodecID codec_id=AV_CODEC_ID_MPEG2VIDEO;
char filepath_in[]="bigbuckbunny_480x272.m2v";
#endif
char filepath_out[]="mainSend.yuv";
int first_time=1;
//av_log_set_level(AV_LOG_DEBUG);
avcodec_register_all();
// pCodec = avcodec_find_decoder(codec_id);
pCodec = avcodec_find_decoder_by_name("h264_cuvid");
if (!pCodec)
{
printf("Codec not found\n");
return -1;
}
pCodecCtx = avcodec_alloc_context3(pCodec);
if (!pCodecCtx)
{
printf("Could not allocate video codec context\n");
return -1;
}
pCodecParserCtx=av_parser_init(pCodec->id);
if (!pCodecParserCtx)
{
printf("Could not allocate video parser context\n");
return -1;
}
if (avcodec_open2(pCodecCtx, pCodec, NULL) < 0)
{
printf("Could not open codec\n");
return -1;
}
//Input File
fp_in = fopen(filepath_in, "rb");
if (!fp_in)
{
printf("Could not open input stream\n");
return -1;
}
//Output File
fp_out = fopen(filepath_out, "wb");
if (!fp_out)
{
printf("Could not open output YUV file\n");
return -1;
}
pFrame = av_frame_alloc();
av_init_packet(&packet);
while (1)
{
cur_size = fread(in_buffer, 1, in_buffer_size, fp_in);
if (cur_size == 0)
break;
cur_ptr=in_buffer;
while (cur_size>0)
{
int len = av_parser_parse2(
pCodecParserCtx, pCodecCtx,
&packet.data, &packet.size,
cur_ptr, cur_size,
AV_NOPTS_VALUE, AV_NOPTS_VALUE, AV_NOPTS_VALUE);
cur_ptr += len;
cur_size -= len;
if(packet.size==0)
continue;
//Some Info from AVCodecParserContext
printf("[Packet]Size:%6d\t",packet.size);
switch(pCodecParserCtx->pict_type)
{
case AV_PICTURE_TYPE_I:
printf("Type:I\tNumber:%4d\n",pCodecParserCtx->output_picture_number);
break;
case AV_PICTURE_TYPE_P:
printf("Type:P\t");
break;
case AV_PICTURE_TYPE_B:
printf("Type:B\t");
break;
default:
printf("Type:Other\t");
break;
}
printf("Number:%4d\n",pCodecParserCtx->output_picture_number);
AVFrame* myFrame = av_frame_alloc();
ret = avcodec_decode_video2(pCodecCtx, myFrame, &got_picture, &packet);
if (ret < 0)
{
printf("Decode Error.\n");
return ret;
}
if (got_picture)
{
if(first_time)
{
printf("\nCodec Full Name:%s\n",pCodecCtx->codec->long_name);
printf("width:%d\nheight:%d\n\n",pCodecCtx->width,pCodecCtx->height);
first_time=0;
}
//Y, U, V
for(int i=0; iheight; i++)
{
fwrite(myFrame->data[0]+myFrag-g>linesize[0]*i,1,myFrame->width,fp_out);
}
for(int i=0; iheight/2; i++)
{
fwrite(myFrame->data[1]+myFrag-g>linesize[1]*i,1,myFrame->width/2,fp_out);
}
for(int i=0; iheight/2; i++)
{
fwrite(myFrame->data[2]+myFrag-g>linesize[2]*i,1,myFrame->width/2,fp_out);
}
// printf("pframe's width height %d %d\t key frame %d\n",myFrame->width,myFrame->height,myFrame->key_frame);
printf("Succeed to decode 1 frame!\n");
av_frame_free(&myFrame);
}
}
}
fclose(fp_in);
fclose(fp_out);
av_parser_close(pCodecParserCtx);
av_frame_free(&pFrame);
avcodec_close(pCodecCtx);
av_free(pCodecCtx);
return 0;
}In this demo code, I call h264_cuvid by
vcodec_find_decoder_by_name("h264_cuvid");
BUT the code crash atfwrite(myFrame->data[2]+myFrag-g>linesize[2]*i,1,myFrame->width/2,fp_out);
So after debug with codeblocks, I found that there is no data in myFrame->data[2] codeblocks watching windowAny suggestion ? thanks !