Recherche avancée

Médias (10)

Mot : - Tags -/wav

Autres articles (60)

  • Contribute to documentation

    13 avril 2011

    Documentation is vital to the development of improved technical capabilities.
    MediaSPIP welcomes documentation by users as well as developers - including : critique of existing features and functions articles contributed by developers, administrators, content producers and editors screenshots to illustrate the above translations of existing documentation into other languages
    To contribute, register to the project users’ mailing (...)

  • 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 (...)

  • MediaSPIP 0.1 Beta version

    25 avril 2011, par

    MediaSPIP 0.1 beta is the first version of MediaSPIP proclaimed as "usable".
    The zip file provided here only contains the sources of MediaSPIP in its standalone version.
    To get a working installation, you must manually install all-software dependencies on the server.
    If you want to use this archive for an installation in "farm mode", you will also need to proceed to other manual (...)

Sur d’autres sites (4643)

  • Unity : Converting Texture2D to YUV420P and sending with UDP using FFmpeg

    22 juin 2018, par potu1304

    In my Unity game each frame is rendered into a texture and then put together into a video using FFmpeg. Now my questions is if I am doing this right because avcodec_send_frame throws every time an exception.
    I am pretty sure that I am doing something wrong or in the wrong order or simply missing something.

    Here is the code for capturing the texture :

    void Update() {
           //StartCoroutine(CaptureFrame());

           if (rt == null)
           {
               rect = new Rect(0, 0, captureWidth, captureHeight);
               rt = new RenderTexture(captureWidth, captureHeight, 24);
               frame = new Texture2D(captureWidth, captureHeight, TextureFormat.RGB24, false);
           }

           Camera camera = this.GetComponent<camera>(); // NOTE: added because there was no reference to camera in original script; must add this script to Camera
           camera.targetTexture = rt;
           camera.Render();

           RenderTexture.active = rt;
           frame.ReadPixels(rect, 0, 0);
           frame.Apply();

           camera.targetTexture = null;
           RenderTexture.active = null;

           byte[] fileData = null;
           fileData = frame.GetRawTextureData();
           encoding(fileData, fileData.Length);

       }
    </camera>

    And here is the code for encoding and sending the byte data :

    private unsafe void encoding(byte[] bytes, int size)
       {
           Debug.Log("Encoding...");
           AVCodec* codec;
           codec = ffmpeg.avcodec_find_encoder(AVCodecID.AV_CODEC_ID_H264);
           int ret, got_output = 0;

           AVCodecContext* codecContext = null;
           codecContext = ffmpeg.avcodec_alloc_context3(codec);
           codecContext->bit_rate = 400000;
           codecContext->width = captureWidth;
           codecContext->height = captureHeight;
           //codecContext->time_base.den = 25;
           //codecContext->time_base.num = 1;

           AVRational timeBase = new AVRational();
           timeBase.num = 1;
           timeBase.den = 25;
           codecContext->time_base = timeBase;
           //AVStream* videoAVStream = null;
           //videoAVStream->time_base = timeBase;



           AVRational frameRate = new AVRational();
           frameRate.num = 25;
           frameRate.den = 1;
           codecContext->framerate = frameRate;

           codecContext->gop_size = 10;
           codecContext->max_b_frames = 1;
           codecContext->pix_fmt = AVPixelFormat.AV_PIX_FMT_YUV420P;

           AVFrame* inputFrame;
           inputFrame = ffmpeg.av_frame_alloc();
           inputFrame->format = (int)codecContext->pix_fmt;
           inputFrame->width = captureWidth;
           inputFrame->height = captureHeight;
           inputFrame->linesize[0] = inputFrame->width;

           AVPixelFormat dst_pix_fmt = AVPixelFormat.AV_PIX_FMT_YUV420P, src_pix_fmt = AVPixelFormat.AV_PIX_FMT_RGBA;
           int src_w = 1920, src_h = 1080, dst_w = 1920, dst_h = 1080;
           SwsContext* sws_ctx;

           GCHandle pinned = GCHandle.Alloc(bytes, GCHandleType.Pinned);
           IntPtr address = pinned.AddrOfPinnedObject();

           sbyte** inputData = (sbyte**)address;
           sws_ctx = ffmpeg.sws_getContext(src_w, src_h, src_pix_fmt,
                                dst_w, dst_h, dst_pix_fmt,
                                0, null, null, null);

           fixed (int* lineSize = new int[1])
           {
               lineSize[0] = 4 * captureHeight;
               // Convert RGBA to YUV420P
               ffmpeg.sws_scale(sws_ctx, inputData, lineSize, 0, codecContext->width, inputFrame->extended_data, inputFrame->linesize);
           }

           inputFrame->pts = counter++;

           if (ffmpeg.avcodec_send_frame(codecContext, inputFrame) &lt; 0)
               throw new ApplicationException("Error sending a frame for encoding!");

           AVPacket pkt;
           pkt = new AVPacket();
           //pkt.data = inData;
           AVPacket* packet = &amp;pkt;
           ffmpeg.av_init_packet(packet);

           Debug.Log("pkt.size " + pkt.size);
           pinned.Free();
           AVDictionary* options = null;
           ffmpeg.av_dict_set(&amp;options, "pkt_size", "1300", 0);
           ffmpeg.av_dict_set(&amp;options, "buffer_size", "65535", 0);
           AVIOContext* server = null;
           ffmpeg.avio_open2(&amp;server, "udp://192.168.0.1:1111", ffmpeg.AVIO_FLAG_WRITE, null, &amp;options);
           Debug.Log("encoded");
           ret = ffmpeg.avcodec_encode_video2(codecContext, &amp;pkt, inputFrame, &amp;got_output);
           ffmpeg.avio_write(server, pkt.data, pkt.size);
           ffmpeg.av_free_packet(&amp;pkt);
           pkt.data = null;
           pkt.size = 0;
       }

    And every time I start the game

     if (ffmpeg.avcodec_send_frame(codecContext, inputFrame) &lt; 0)
               throw new ApplicationException("Error sending a frame for encoding!");

    throws the exception.
    Any help in fixing the issue would be greatly appreciated :)

  • ffmpeg demux into audio and video resets PTS

    30 juillet 2018, par Mukund Manikarnike

    Demuxing

    I am demuxing TS segments into audio and video as follows.

    ffmpeg -y -i input.ts -vcodec copy -an output_video.ts
    ffmpeg -y -i input.ts -acodec copy -vn output_audio.aac

    Inspecting Input

    The start_pts and start_time on input.ts are as shown below. I was able to inspect these values using ffprobe -show_streams -print_format json input.ts

    "start_pts": 8306558438,
    "start_time": "92295.093756",

    Inspecting output video

    The output .ts has some default start_pts and start_time values as shown below. These were also obtained using the same ffprobe command as indicated above.

    "start_pts": 126000,
    "start_time": "1.400000",

    Inspecting output audio

    The same ffprobe command on output_audio.aac shows that the output aac has invalid codec_tag and codec_tag_string as shown below. The start_pts and start_time are not present in the output_audio.aac.

    "codec_tag_string": "[0][0][0][0]", (should have been [15][0][0][0])
    "codec_tag": "0x0000", (should have been 0xf000)

    Questions

    1. Wondering if this difference in the start_pts, start_time, codec_tag is expected ?
    2. If it is expected, what can I do to ensure that the all of these parameters get retained on the output ?
    3. If it is not expected, is there some more information I can share to track this down ?

    Note

    There were other outputs that I found inconsistent in the ffprobe command for the output_audio.aac like duration etc.. I shared what I thought are most valuable at this point. If required I can share complete outputs from all of the above executions.

    [EDIT 07/30/2018 - 08:00 MST]
    logs for ffmpeg -y -i input.ts -vcodec copy -an output_video.ts -acodec copy -vn output_audio.aacare as shown below.

    ffmpeg version 4.0.2 Copyright (c) 2000-2018 the FFmpeg developers
     built with Apple LLVM version 9.0.0 (clang-900.0.39.2)
     configuration: --prefix=/usr/local/Cellar/ffmpeg/4.0.2 --enable-shared --enable-pthreads --enable-version3 --enable-hardcoded-tables --enable-avresample --cc=clang --host-cflags= --host-ldflags= --enable-gpl --enable-ffplay --enable-frei0r --enable-libass --enable-libfdk-aac --enable-libfreetype --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopus --enable-librtmp --enable-libspeex --enable-libtheora --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libxvid --enable-opencl --enable-videotoolbox --disable-lzma --enable-libopenjpeg --disable-decoder=jpeg2000 --extra-cflags=-I/usr/local/Cellar/openjpeg/2.3.0/include/openjpeg-2.3 --enable-nonfree
     libavutil      56. 14.100 / 56. 14.100
     libavcodec     58. 18.100 / 58. 18.100
     libavformat    58. 12.100 / 58. 12.100
     libavdevice    58.  3.100 / 58.  3.100
     libavfilter     7. 16.100 /  7. 16.100
     libavresample   4.  0.  0 /  4.  0.  0
     libswscale      5.  1.100 /  5.  1.100
     libswresample   3.  1.100 /  3.  1.100
     libpostproc    55.  1.100 / 55.  1.100
    [mpegts @ 0x7f88ed803000] start time for stream 0 is not set in estimate_timings_from_pts
    Input #0, mpegts, from 'i7h9456s_media_46185.ts':
     Duration: 00:00:06.05, start: 86216.852667, bitrate: 2898 kb/s
     Program 1
       Stream #0:0[0x102]: Data: timed_id3 (ID3  / 0x20334449)
       Stream #0:1[0x100]: Video: h264 (Constrained Baseline) ([27][0][0][0] / 0x001B), yuv420p(tv, smpte170m, progressive), 640x360 [SAR 1:1 DAR 16:9], 29.97 fps, 29.97 tbr, 90k tbn, 59.94 tbc
       Stream #0:2[0x101]: Audio: aac (LC) ([15][0][0][0] / 0x000F), 44100 Hz, stereo, fltp, 190 kb/s
    Output #0, mpegts, to '../output_video.ts':
     Metadata:
       encoder         : Lavf58.12.100
       Stream #0:0: Video: h264 (Constrained Baseline) ([27][0][0][0] / 0x001B), yuv420p(tv, smpte170m, progressive), 640x360 [SAR 1:1 DAR 16:9], q=2-31, 29.97 fps, 29.97 tbr, 90k tbn, 90k tbc
    Output #1, adts, to '../output_audio.aac':
     Metadata:
       encoder         : Lavf58.12.100
       Stream #1:0: Audio: aac (LC) ([15][0][0][0] / 0x000F), 44100 Hz, stereo, fltp, 190 kb/s
    Stream mapping:
     Stream #0:1 -> #0:0 (copy)
     Stream #0:2 -> #1:0 (copy)
    Press [q] to stop, [?] for help
    frame=  180 fps=0.0 q=-1.0 Lsize=    2088kB time=00:00:06.03 bitrate=2833.8kbits/s speed= 904x    
    video:1918kB audio:142kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 1.349750%
  • Modify video frames but keep their timestamp in python (maybe with ffmpeg ?)

    3 août 2018, par bendaf

    I have .ts videos with variable frame rate and I would like to modify the frames of the videos and keep the timestamps belonging to the frames. I am using python and experiencing with ffmpeg, but I am open to any solution.

    The output of

    $ffmpeg -i myvideo.ts -hide_banner

    Input #0, mpegts, from 'myvideo.ts':
     Duration: 00:02:37.84, start: 1.400000, bitrate: 13799 kb/s
     Program 1
       Metadata:
         service_name    : Service01
         service_provider: FFmpeg
       Stream #0:0[0x100]: Video: h264 (High) ([27][0][0][0] / 0x001B), yuv420p, 3840x1080, 25 fps, 25 tbr, 90k tbn, 50 tbc

    What I have tried so far is :

    import skvideo.io

    outpudict = {"-map": "0",
                "-vcodec": "libx264",
                "-pix_fmt": "yuv420p",
                "-f": "mpegts"
                }

    videogen = skvideo.io.vreader(args.input_video)
    writer = skvideo.io.FFmpegWriter(filename + file_extension, outputdict=outpudict)
    for i, frame in enumerate(videogen):
       # modify the frame
       writer.writeFrame(frame)

    writer.close()

    But so far I am not able to keep the pts and dts parameters of the frames only the format and encoding.

    Note : I have tried to use skvideo.io.FFmpegReader or pass the outputdict parameter also to vreader but the script crashed because of this bug.

    Note2 : I am checking the pts of the frames with

    $ffprobe -hide_banner -show_entries packet=pts,dts myvideo.ts

    Thank you for reading through my question, any idea would be appreciated !