Recherche avancée

Médias (1)

Mot : - Tags -/portrait

Autres articles (62)

  • Publier sur MédiaSpip

    13 juin 2013

    Puis-je poster des contenus à partir d’une tablette Ipad ?
    Oui, si votre Médiaspip installé est à la version 0.2 ou supérieure. Contacter au besoin l’administrateur de votre MédiaSpip pour le savoir

  • Submit bugs and patches

    13 avril 2011

    Unfortunately a software is never perfect.
    If you think you have found a bug, report it using our ticket system. Please to help us to fix it by providing the following information : the browser you are using, including the exact version as precise an explanation as possible of the problem if possible, the steps taken resulting in the problem a link to the site / page in question
    If you think you have solved the bug, fill in a ticket and attach to it a corrective patch.
    You may also (...)

  • Les images

    15 mai 2013

Sur d’autres sites (12125)

  • Render an IDirect3DSurface9 from DXVA2 ?

    18 janvier 2019, par TTGroup

    I got a IDirect3DSurface9 from DXVA2 video decoder using hardware acceleration.

    I’m try to Render this hardware IDirect3DSurface9 on My Window via its handle. The following is my summary code.

    The first, I call dxva2_init(AVCodecContext *s, HWND hwnd) ; with hwnd is window’s handle

    int dxva2_init(AVCodecContext *s, HWND hwnd)
    {
       InputStream *ist = (InputStream *)s->opaque;
       int loglevel = (ist->hwaccel_id == HWACCEL_AUTO) ? AV_LOG_VERBOSE : AV_LOG_ERROR;
       DXVA2Context *ctx;
       int ret;

       if (!ist->hwaccel_ctx) {
           ret = dxva2_alloc(s);
           if (ret < 0)
               return ret;
       }
       ctx = (DXVA2Context *)ist->hwaccel_ctx;
       ctx->deviceHandle = hwnd;
       if (s->codec_id == AV_CODEC_ID_H264 &&
           (s->profile & ~FF_PROFILE_H264_CONSTRAINED) > FF_PROFILE_H264_HIGH) {
           av_log(NULL, loglevel, "Unsupported H.264 profile for DXVA2 HWAccel: %d\n", s->profile);
           return AVERROR(EINVAL);
       }

       if (ctx->decoder)
           dxva2_destroy_decoder(s);

       ret = dxva2_create_decoder(s);
       if (ret < 0) {
           av_log(NULL, loglevel, "Error creating the DXVA2 decoder\n");
           return ret;
       }

       return 0;
    }

    After Decoding successful, I got got a IDirect3DSurface9, and I Render it by following function.

    int dxva2_render(AVCodecContext *s, AVFrame *frame)
    {
       LPDIRECT3DSURFACE9 surface = (LPDIRECT3DSURFACE9)frame->data[3];
       InputStream        *ist = (InputStream *)s->opaque;
       DXVA2Context       *ctx = (DXVA2Context *)ist->hwaccel_ctx;

       try
       {
           lockRenderCS.Enter();
           HRESULT hr = ctx->d3d9device->Clear(0, NULL, D3DCLEAR_TARGET, D3DCOLOR_XRGB(255, 0, 0), 1.0f, 0);
           if (hr != D3D_OK)
               return 0;

           hr = ctx->d3d9device->BeginScene();
           if (hr != D3D_OK)
               return 0;

           hr = ctx->d3d9device->GetBackBuffer(0, 0, D3DBACKBUFFER_TYPE_MONO, &pBackBuffer);
           if (hr != D3D_OK)
               return 0;

           hr = ctx->d3d9device->StretchRect(surface, NULL, pBackBuffer, NULL, D3DTEXF_LINEAR);
           if (hr != D3D_OK)
               return 0;

           hr = ctx->d3d9device->EndScene();
           if (hr != D3D_OK)
               return 0;

           hr = ctx->d3d9device->Present(NULL, NULL, NULL, NULL);
           if (hr != D3D_OK)
               return 0;
       }
       finally
       {
           lockRenderCS.Leave();
       }
       return 0;
    }

    Note : All D3D function above : Clear(), BeginScene(), GetBackBuffer(), StretchRect(), EndScene(), Present() were return Successful. But the frame was not display on My Window.

    I Guess that, I miss some code for integrated My Window Handle with DXVA2Context. In this code I only assign : ctx->deviceHandle = hwnd; in function dxva2_init().

    I search many times, but so far I still cannot find the solution, Anyone can help me ?

    Many Thanks !

  • Dividing, processing and merging files with ffmpeg

    9 novembre 2015, par João Carlos Santos

    I am trying to build an application that will divide an input video file (usually mp4) into chunks so that I can apply some processing to them concurrently and then merge them back into a single file.

    To do this, I have outlined 4 steps :

    1. Forcing keyframes at specific intervals so to make sure that each
      chunk can be played on its own. For this I am using the following
      command :

      ffmpeg -i input.mp4 -force_key_frames
      "expr:gte(t,n_forced*chunk_length)" keyframed.mp4

      where chunk_length is the duration of each chunk.

    2. Dividing keyframed.mp4 into multiple chunks.
      Here is where I have my problem. I am using the following command :

      `ffmpeg -i keyframed.mp4 -ss 00:00:00 -t chunk_length -vcodec copy -acodec copy test1.mp4`

      to get the first chunk from my keyframed file but it isn’t capturing
      the output correctly, since it appears to miss the first keyframe.

      On other chunks, the duration of the output is also sometimes
      slightly less than chunk_length, even though I am always using the
      same -t chunk_length option

    3. Processing each chunk For this task, I am using the following
      commands :

      ffmpeg -y -i INPUT_FILE -threads 1 -pass 1 -s 1280x720 -preset
      medium -vprofile baseline -c:v libx264 -level 3.0 -vf
      "format=yuv420p" -b:v 2000k -maxrate:v 2688k -bufsize:v 2688k -r 25
      -g 25 -keyint_min 50 -x264opts "keyint=50:min-keyint=50:no-scenecut" -an -f mp4 -movflags faststart /dev/null
      ffmpeg -y -i INPUT_FILE -threads 1 -pass 2 -s 1280x720 -preset
      medium -vprofile baseline -c:v libx264 -level 3.0 -vf
      "format=yuv420p" -b:v 2000k -maxrate:v 2688k -bufsize:v 2688k -r 25
      -g 25 -keyint_min 50 -x264opts "keyint=50:min-keyint=50:no-scenecut" -acodec libfaac -ac 2 -ar 48000 -ab 128k -f mp4 -movflags faststart OUTPUT_FILE.mp4

      This commands are not allowed to be modified, since my goal here is
      to parallelize this process.

    4. Finally, to merge the files I am using concat and a list of the
      outputs of the 2nd step, as follows :

      ffmpeg -f concat -i mylist.txt -c copy final.mp4

    In conclusion, I am trying to find out a way to solve the problem with step 2 and also get some opinions if there is a better way to do this.

  • Unable to access user selected file via NSOpenPanel in FFMPEG process in macOS app

    12 décembre 2019, par Raptor

    I am new to macOS development via SwiftUI. I’m trying to run a FFMPEG process after I selected a MP4 file via NSOpenPanel. However, the FFMPEG responded with :

    file :///Users/MyUsername/Documents/Video.mp4 : No such file or directory

    Here is my simple codes :

    import SwiftUI

    struct ContentView: View {

       @State var selectedURL: URL?

       var body: some View {
           VStack {
               if selectedURL != nil {
                   Text("Selected: \(selectedURL!.absoluteString)")
               } else {
                   Text("Nothing selected")
               }
               Button(action: {
                   let panel = NSOpenPanel()
                   panel.allowedFileTypes = ["mp4"]
                   panel.canChooseDirectories = false
                   panel.canCreateDirectories = false
                   panel.allowsMultipleSelection = false
                   let result = panel.runModal()
                   if result == .OK {
                       self.selectedURL = panel.url

                       let savePath = self.getDownloadDirectory().appendingPathComponent("video.webm")

                       self.convertVideo(inputFilePath: self.selectedURL!.absoluteString, outputFilePath: savePath.absoluteString, callback: {(s) in
                           // omit the callback at this moment
                       })
                   }
               }) {
                   Text("Select File")
               }
           }
           .frame(width: 640, height: 480)
       }

       func getDownloadDirectory() -> URL {
           let paths = FileManager.default.urls(for: .downloadsDirectory, in: .userDomainMask)
           return paths[0]
       }

       func convertVideo(inputFilePath: String, outputFilePath: String,
                        callback: @escaping (Bool) -> Void) -> (Process, DispatchWorkItem)? {
           guard let launchPath = Bundle.main.path(forResource: "ffmpeg", ofType: "") else {
               return nil
           }
           let process = Process()
           let task = DispatchWorkItem {
               process.launchPath = launchPath
               process.arguments = [
                   "-y",
                   "-i", inputFilePath,
                   "-vcodec", "vp8",
                   "-acodec", "libvorbis",
                   "-pix_fmt", "yuva420p",
                   "-metadata:s:v:0",
                   "alpha_mode=\"1\"",
                   "-auto-alt-ref", "0",
                   outputFilePath
               ]
               process.standardInput = FileHandle.nullDevice
               process.launch()
               process.terminationHandler = { process in
                   callback(process.terminationStatus == 0)
               }
           }
           DispatchQueue.global(qos: .userInitiated).async(execute: task)

           return (process, task)
       }
    }

    What did I miss to allow FFMPEG process to access my selected file ? Thanks !