Recherche avancée

Médias (1)

Mot : - Tags -/biomaping

Autres articles (65)

  • Le profil des utilisateurs

    12 avril 2011, par

    Chaque utilisateur dispose d’une page de profil lui permettant de modifier ses informations personnelle. Dans le menu de haut de page par défaut, un élément de menu est automatiquement créé à l’initialisation de MediaSPIP, visible uniquement si le visiteur est identifié sur le site.
    L’utilisateur a accès à la modification de profil depuis sa page auteur, un lien dans la navigation "Modifier votre profil" est (...)

  • Configurer la prise en compte des langues

    15 novembre 2010, par

    Accéder à la configuration et ajouter des langues prises en compte
    Afin de configurer la prise en compte de nouvelles langues, il est nécessaire de se rendre dans la partie "Administrer" du site.
    De là, dans le menu de navigation, vous pouvez accéder à une partie "Gestion des langues" permettant d’activer la prise en compte de nouvelles langues.
    Chaque nouvelle langue ajoutée reste désactivable tant qu’aucun objet n’est créé dans cette langue. Dans ce cas, elle devient grisée dans la configuration et (...)

  • La sauvegarde automatique de canaux SPIP

    1er avril 2010, par

    Dans le cadre de la mise en place d’une plateforme ouverte, il est important pour les hébergeurs de pouvoir disposer de sauvegardes assez régulières pour parer à tout problème éventuel.
    Pour réaliser cette tâche on se base sur deux plugins SPIP : Saveauto qui permet une sauvegarde régulière de la base de donnée sous la forme d’un dump mysql (utilisable dans phpmyadmin) mes_fichiers_2 qui permet de réaliser une archive au format zip des données importantes du site (les documents, les éléments (...)

Sur d’autres sites (6803)

  • Problems with video playback using the ffplay

    7 octobre 2023, par Anzor Gergov

    everyone. I have problems with video playback using the ffplay. Used the following command

    



    ffplay -i input.avi


    



    But the following error occurred.

    



    ffplay version N-87353-g183fd30 Copyright (c) 2003-2017 the FFmpeg developers
  built with gcc 7.2.0 (GCC)
  configuration: --disable-static --enable-shared --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-libxml2 --enable-libzimg --enable-lzma --enable-zlib
  libavutil      55. 76.100 / 55. 76.100
  libavcodec     57.106.101 / 57.106.101
  libavformat    57. 82.101 / 57. 82.101
  libavdevice    57.  8.101 / 57.  8.101
  libavfilter     6.105.100 /  6.105.100
  libswscale      4.  7.103 /  4.  7.103
  libswresample   2.  8.100 /  2.  8.100
  libpostproc    54.  6.100 / 54.  6.100
[avi @ 00000000024bd9e0] Could not find codec parameters for stream 0 (Video: none (HEVC / 0x43564548), none, 1920x1080, 1697 kb/s): unknown codec
Consider increasing the value for the 'analyzeduration' and 'probesize' options
Input #0, avi, from 'c:\problem.avi':
  Duration: 00:00:25.00, start: 0.000000, bitrate: 1701 kb/s
    Stream #0:0: Video: none (HEVC / 0x43564548), none, 1920x1080, 1697 kb/s, 30.92 fps, 30.92 tbr, 30.92 tbn, 30.92 tbc
No codec could be found with id 0
Failed to open file 'c:\problem.avi' or configure filtergraph


    



    This video is playable without any problems via the VLC, Media Player Classic. 
After trying to find out more information about the video file, I used ffprobe command

    



    ffprobe -v 0  c:\problem.avi -print_format json -show_format -show_streams

{
    "streams": [
        {
            "index": 0,
            "codec_type": "video",
            "codec_tag_string": "HEVC",
            "codec_tag": "0x43564548",
            "width": 1920,
            "height": 1080,
            "has_b_frames": 0,
            "sample_aspect_ratio": "0:1",
            "display_aspect_ratio": "0:1",
            "level": -99,
            "r_frame_rate": "773/25",
            "avg_frame_rate": "773/25",
            "time_base": "25/773",
            "start_pts": 0,
            "start_time": "0.000000",
            "duration_ts": 773,
            "duration": "25.000000",
            "bit_rate": "1697304",
            "nb_frames": "773",
            "disposition": {
                "default": 0,
                "dub": 0,
                "original": 0,
                "comment": 0,
                "lyrics": 0,
                "karaoke": 0,
                "forced": 0,
                "hearing_impaired": 0,
                "visual_impaired": 0,
                "clean_effects": 0,
                "attached_pic": 0,
                "timed_thumbnails": 0
            }
        }
    ],
    "format": {
        "filename": "c:\\bin\\Virtual\\problem\\problem.avi",
        "nb_streams": 1,
        "nb_programs": 0,
        "format_name": "avi",
        "format_long_name": "AVI (Audio Video Interleaved)",
        "start_time": "0.000000",
        "duration": "25.000000",
        "size": "5318210",
        "bit_rate": "1701827",
        "probe_score": 100
    }
}


    



    What could be the problem with this videofile ?

    


  • Why is image loading from ffmpeg using stdout slow ?

    23 octobre 2017, par Jirka Šáda

    I was just experimenting with FFMPEG, and wrote this testing piece of code, that is reading frames from FFMPEG and displaying them :

    public partial class MainWindow : Window
    {
       private WriteableBitmap wbm = new WriteableBitmap(1920, 1080, 96, 96, PixelFormats.Rgb24, null);
       private IntPtr backBuffer;
       private int totalFrames = 0;
       private bool drawing = false;

       public MainWindow()
       {
           InitializeComponent();

           backBuffer = wbm.BackBuffer;

           Thread t = new Thread(new ThreadStart(RunFFMPEG));
           t.Start();

           Thread measurer = new Thread(new ThreadStart(Measure));
           measurer.Start();
       }

       private void Measure()
       {
           while(true)
           {
               Thread.Sleep(1000);
               Console.Title = "FPS: " + totalFrames;
               totalFrames = 0;
           }
       }

       private void UpdateBitmap()
       {
           drawing = true;

           wbm.Lock();
           wbm.AddDirtyRect(new Int32Rect(0, 0, 1920, 1080));
           wbm.Unlock();

           mainImage.Source = wbm;

           drawing = false;
       }

       private void RunFFMPEG()
       {
           totalFrames = 0;

           int length = 1920 * 1080 * 3;

           // start FFMPEG process and pipe standart output
           ProcessStartInfo info = new ProcessStartInfo("ffmpeg.exe", "-f dshow -vcodec mjpeg -video_size 1920x1080 -framerate 30 -i video=\"A4 TECH HD PC Camera\" -y -pix_fmt rgb24 -f rawvideo -framerate 30 pipe:1");
           info.WindowStyle = ProcessWindowStyle.Hidden;
           info.UseShellExecute = false;
           info.CreateNoWindow = true;
           info.RedirectStandardOutput = true;

           Process p = new Process();
           p.StartInfo = info;
           p.Start();

           while (true) // read frames from standart output
           {

               byte[] data = new byte[length];

               for (int i = 0; i < length; i++) // read byte by byte, if we call normal Read(), the returned array is always mostly empty
                   data[i] = (byte)p.StandardOutput.BaseStream.ReadByte();

               if (!drawing)
               {
                   Marshal.Copy(data, 0, backBuffer, length);
                   Dispatcher.Invoke(() => UpdateBitmap()); // we are not in UI thread
               }

               totalFrames++;
           }
       }  
    }

    The problem is, although I get around 17-20 FPS reported, the Image is redrawing very very slowly (once or twice per a second) and even though the mainImage.Source =... line takes always similar amount of time, the speed at which the Image visually updates itself is getting progressively slower. What could be the cause ?? Thanks for any tips

    PS : I know the code is ugly and not following MVVM pattern, but it’s just and only for testing, please don’t hate me :-)

    Edit : The problem is not speed at which I’m reading from stdout, that’s fine (20 FPS), the problem is, that WPF Image is visually updating very slowly

  • Assigning of dts values to encoded packets

    24 mars, par Alex

    I have a dump of H264-encoded data, which I need to put in mp4 container. I verified the validity of the encoded data by using mp4box utility against it. The mp4 file created by mp4box contained a proper 17 seconds long video. It is interesting that if I try ffmpeg to achieve the same, the resulting video is 34 seconds long and rather crappy (probably ffmpeg tries to decode video and then encode it, which results in the loss of video quality ?) Anyway, for my project I can't use command line approach and need to come up wit a programmatic way to embed the data in the mp4 container.

    



    Below is the code I use (I removed error checking for brevity. During execution all the calls succeed) :

    



    AVFormatContext* pInputFormatContext = avformat_alloc_context();
avformat_open_input(&pInputFormatContext, "Data.264", NULL, NULL);
avformat_find_stream_info(pInputFormatContext, NULL);
AVRational* pTime_base = &pInputFormatContext->streams[0]->time_base;

int nFrameRate = pInputFormatContext->streams[0]->r_frame_rate.num / pFormatCtx->streams[0]->r_frame_rate.den;
int nWidth = pInputFormatContext->streams[0]->codecpar->width;
int nHeight = pInputFormatContext->streams[0]->codecpar->height;
// nWidth = 1920, nHeight = 1080, nFrameRate = 25

// Create output objects
AVFormatContext* pOutputFormatContext = NULL;
avformat_alloc_output_context2(&pOutputFormatContext, NULL, NULL, "Destination.mp4");

AVCodec* pVideoCodec = avcodec_find_encoder(pOutputFormatContext->oformat->video_codec/*AV_CODEC_ID_264*/);
AVStream* pOutputStream = avformat_new_stream(pOutputFormatContext, NULL);
pOutputStream->id = pOutputFormatContext->nb_streams - 1;
AVCodecContext* pCodecContext = avcodec_alloc_context3(pVideoCodec);

switch (pVideoCodec->type) {
case AVMEDIA_TYPE_VIDEO:
  pCodecContext->codec_id = codec_id;
  pCodecContext->bit_rate = 400000;
  /* Resolution must be a multiple of two. */
  pCodecContext->width = nFrameWidth;
  pCodecContext->height = nFrameHeight;
  /* timebase: This is the fundamental unit of time (in seconds) in terms
  * of which frame timestamps are represented. For fixed-fps content,
  * timebase should be 1/framerate and timestamp increments should be
  * identical to 1. */
  pOutputStream->time_base.num = 1;
  pOutputStream->time_base.den = nFrameRate;
  pCodecContext->time_base = pOutputStream->time_base;
  pCodecContext->gop_size = 12; /* emit one intra frame every twelve frames at most */
  pCodecContext->pix_fmt = STREAM_PIX_FMT;
  break;
default:
  break;
}

/* copy the stream parameters to the muxer */
avcodec_parameters_from_context(pOutputStream->codecpar, pCodecContext);

avio_open(&pOutputFormatContext->pb, "Destination.mp4", AVIO_FLAG_WRITE);

// Start writing
AVDictionary* pDict = NULL;
avformat_write_header(pOutputFormatContext, &pDict);

// Process packets
AVPacket packet;
int64_t nCurrentDts = 0;
int64_t nDuration = 0;
int nReadResult = 0;

while (nReadResult == 0)
{
  nReadResult = av_read_frame(m_pInputFormatContext, &packet);
// At this point, packet.dts == AV_NOPTS_VALUE. 
// The duration field of the packet contains valid data

  packet.flags |= AV_PKT_FLAG_KEY;
  nDuration = packet.duration;
  packet.dts = nCurrentDts;
  packet.dts = av_rescale_q(nCurrentDts, pOutputFormatContext->streams[0]->codec->time_base, pOutputFormatContext->streams[0]->time_base);
  av_interleaved_write_frame(pOutputFormatContext, &packet);
  nCurrentDts += nDuration;
  nDuration += packet.duration;
  av_free_packet(&packet);
}

av_write_trailer(pOutputFormatContext);


    



    The properties for the Destination.mp4 file I receive indicate it is about 1 hour long with frame rate 0. I am sure the culprit is in the way I calculate dts values for each packet and use av_rescale_q(), but I do not have sufficient understanding of the avformat library to figure out the proper way to do it. Any help will be appreciated !