Recherche avancée

Médias (0)

Mot : - Tags -/masques

Aucun média correspondant à vos critères n’est disponible sur le site.

Autres articles (7)

  • Contribute to translation

    13 avril 2011

    You can help us to improve the language used in the software interface to make MediaSPIP more accessible and user-friendly. You can also translate the interface into any language that allows it to spread to new linguistic communities.
    To do this, we use the translation interface of SPIP where the all the language modules of MediaSPIP are available. Just subscribe to the mailing list and request further informantion on translation.
    MediaSPIP is currently available in French and English (...)

  • Other interesting software

    13 avril 2011, par

    We don’t claim to be the only ones doing what we do ... and especially not to assert claims to be the best either ... What we do, we just try to do it well and getting better ...
    The following list represents softwares that tend to be more or less as MediaSPIP or that MediaSPIP tries more or less to do the same, whatever ...
    We don’t know them, we didn’t try them, but you can take a peek.
    Videopress
    Website : http://videopress.com/
    License : GNU/GPL v2
    Source code : (...)

  • Selection of projects using MediaSPIP

    2 mai 2011, par

    The examples below are representative elements of MediaSPIP specific uses for specific projects.
    MediaSPIP farm @ Infini
    The non profit organizationInfini develops hospitality activities, internet access point, training, realizing innovative projects in the field of information and communication technologies and Communication, and hosting of websites. It plays a unique and prominent role in the Brest (France) area, at the national level, among the half-dozen such association. Its members (...)

Sur d’autres sites (3971)

  • How to update a byte array in a method, without running it again ?

    18 février 2016, par AR792

    I have a class(an AsyncTask) which does image processing and generates yuv bytes continously, at around 200ms interval.

    Now I send these yuv bytes to another method where the they are recorded using FFmpeg frame recorder :

    public void recordYuvData() {

           byte[] yuv = getNV21();
           System.out.println(yuv.length + "  returned yuv bytes  ");
           if (audioRecord == null || audioRecord.getRecordingState() != AudioRecord.RECORDSTATE_RECORDING) {
               startTime = System.currentTimeMillis();
               return;
           }
           if (RECORD_LENGTH > 0) {
               int i = imagesIndex++ % images.length;
               yuvimage = images[i];
               timestamps[i] = 1000 * (System.currentTimeMillis() - startTime);
           }
           /* get video data */
           if (yuvimage != null && recording) {
               ((ByteBuffer) yuvimage.image[0].position(0)).put(yuv);

               if (RECORD_LENGTH <= 0) {
                   try {
                       long t = 1000 * (System.currentTimeMillis() - startTime);
                       if (t > recorder.getTimestamp()) {
                           recorder.setTimestamp(t);
                       }
                       recorder.record(yuvimage);
                   } catch (FFmpegFrameRecorder.Exception e) {

                       e.printStackTrace();
                   }
               }
           }
       }

    This method ; recordYuvData() is initiated on button click.

    1. If I initiate it only once , then only the initial image gets recorded, rest are not.

    2. If I initiate this each time after the end of the image processing it records but leads to ’weird’ fps count of the video ; and finally this leads to application crash after sometime.

      For above what I feel is, at the end of image processing a new instance of recordYuvData() is created without ending the previous one, accumulating many instances of recordYuvData(). [correct me if I am wrong]

    So, how do I update ’ONLY’ yuv bytes in the method without running it again ?

    Thanks....!

    Edit :

    On Click :

       record.setOnClickListener(new View.OnClickListener() {
           @Override
           public void onClick(View v) {
               recordYuvdata();
               startRecording();

    getNV21()

    byte[] getNV21(Bitmap bitmap) {

       int inputWidth = 1024;
       int inputHeight = 640;
       int[] argb = new int[inputWidth * inputHeight];

       bitmap.getPixels(argb, 0, inputWidth, 0, 0, inputWidth, inputHeight);
       System.out.println(argb.length + "@getpixels ");


       byte[] yuv = new byte[inputWidth * inputHeight * 3 / 2];
       encodeYUV420SP(yuv, argb, inputWidth, inputHeight);

       return yuv;

    }

    void encodeYUV420SP(byte[] yuv420sp, int[] argb, int width, int height) {
       final int frameSize = width * height;

       int yIndex = 0;
       int uvIndex = frameSize;
       System.out.println(yuv420sp.length + " @encoding " + frameSize);

       int a, R, G, B, Y, U, V;
       int index = 0;
       for (int j = 0; j < height; j++) {
           for (int i = 0; i < width; i++) {

               a = (argb[index] & 0xff000000) >> 24; // a is not used obviously
               R = (argb[index] & 0xff0000) >> 16;
               G = (argb[index] & 0xff00) >> 8;
               B = (argb[index] & 0xff) >> 0;

               // well known RGB to YUV algorithm

               Y = ((66 * R + 129 * G + 25 * B + 128) >> 8) + 16;
               U = ((-38 * R - 74 * G + 112 * B + 128) >> 8) + 128;
               V = ((112 * R - 94 * G - 18 * B + 128) >> 8) + 128;

               // NV21 has a plane of Y and interleaved planes of VU each sampled by a factor of 2
               //    meaning for every 4 Y pixels there are 1 V and 1 U.  Note the sampling is every other
               //    pixel AND every other scanline.
               yuv420sp[yIndex++] = (byte) ((Y < 0) ? 0 : ((Y > 255) ? 255 : Y));
               if (j % 2 == 0 && index % 2 == 0) {
                   yuv420sp[uvIndex++] = (byte) ((V < 0) ? 0 : ((V > 255) ? 255 : V));
                   yuv420sp[uvIndex++] = (byte) ((U < 0) ? 0 : ((U > 255) ? 255 : U));
               }

               index++;
           }
       }
    }
  • Extract audio from video using autogen ffmpeg C# in Unity

    5 décembre 2024, par Johan Sophie

    Hi I'm using ffmpeg autogen to extract audio from video in Unity, but when I following this code, the file write cannot write, it's 0Kb, so what's issue of this or someone have any examples for extract audio using this library, apologize for my English. This is github of library : 
https://github.com/Ruslan-B/FFmpeg.AutoGen

    



    unsafe void TestExtractAudio()
{

    string inFile = Application.streamingAssetsPath + "/" + strFileName;
    string outFile = Application.streamingAssetsPath + "/" + strFileNameAudio;

    AVOutputFormat* outFormat = null;
    AVFormatContext* inFormatContext = null;
    AVFormatContext* outFormatContext = null;
    AVPacket packet;

    ffmpeg.av_register_all();

    inFormatContext = ffmpeg.avformat_alloc_context();
    outFormatContext = ffmpeg.avformat_alloc_context();

    if (ffmpeg.avformat_open_input(&inFormatContext, inFile, null, null) < 0)
    {
        throw new ApplicationException("Could not open input file.");
    }

    if (ffmpeg.avformat_find_stream_info(inFormatContext, null) < 0)
    {
        throw new ApplicationException("Failed to retrieve input stream info.");
    }

    ffmpeg.avformat_alloc_output_context2(&outFormatContext, null, null, outFile);
    if (outFormatContext == null)
    {
        throw new ApplicationException("Could not create output context");
    }

    outFormat = outFormatContext->oformat;

    AVStream* inStream = inFormatContext->streams[1];
    AVStream* outStream = ffmpeg.avformat_new_stream(outFormatContext, inStream->codec->codec);
    if (outStream == null)
    {
        throw new ApplicationException("Failed to allocate output stream.");
    }

    if (ffmpeg.avcodec_copy_context(outStream->codec, inStream->codec) < 0)
    {
        throw new ApplicationException("Couldn't copy input stream codec context to output stream codec context");
    }

    outFormatContext->audio_codec_id = AVCodecID.AV_CODEC_ID_MP3;

    int retcode = ffmpeg.avio_open(&outFormatContext->pb, outFile, ffmpeg.AVIO_FLAG_WRITE);
    if (retcode < 0)
    {
        throw new ApplicationException("Couldn't open output file");
    }

    int returnCode = ffmpeg.avformat_write_header(outFormatContext, null);

    if (returnCode < 0)
    {
        throw new ApplicationException("Error occurred opening output file.");
    }

    while (true)
    {
        if (ffmpeg.av_read_frame(inFormatContext, &packet) < 0)
        {
            break;
        }

        if (packet.stream_index == 1)
        {

            inStream = inFormatContext->streams[1];
            outStream = outFormatContext->streams[0];

            // TODO: Replicate log packet functionality to print out what's inside the packet.

            packet.pts = ffmpeg.av_rescale_q_rnd(packet.pts, inStream->time_base, outStream->time_base,
                AVRounding.AV_ROUND_NEAR_INF | AVRounding.AV_ROUND_PASS_MINMAX);
            packet.dts = ffmpeg.av_rescale_q_rnd(packet.dts, inStream->time_base, outStream->time_base,
                AVRounding.AV_ROUND_NEAR_INF | AVRounding.AV_ROUND_PASS_MINMAX);

            packet.duration = ffmpeg.av_rescale_q(packet.duration, inStream->time_base, outStream->time_base);

            int returncode = ffmpeg.av_interleaved_write_frame(outFormatContext, &packet);

        }

        ffmpeg.av_packet_unref(&packet);
    }

    ffmpeg.av_write_trailer(outFormatContext);


    ffmpeg.avformat_close_input(&inFormatContext);

    ffmpeg.avformat_free_context(outFormatContext);

    Console.WriteLine("Press any key to continue...");

    Console.ReadKey();
}


    



    the value returnCode return less than 0, so someone can fix this, thanks so much for that

    


  • ios video after trimming then play on non ios device audio/video out of sync

    31 août 2015, par gavinHe

    trimming video,then I send the video trimmed to android device and play,I find audio/video out of sync, the audio is several seconds behind the video. but the video can play normal on iOS device.
    1.I trim video with codes like this :

    - (IBAction)showTrimmedVideo:(UIButton *)sender
    {
    [self deleteTmpFile];

    NSURL *videoFileUrl = [NSURL fileURLWithPath:self.originalVideoPath];

    AVAsset *anAsset = [[AVURLAsset alloc] initWithURL:videoFileUrl options:nil];
    NSArray *compatiblePresets = [AVAssetExportSession exportPresetsCompatibleWithAsset:anAsset];
    if ([compatiblePresets containsObject:AVAssetExportPresetMediumQuality]) {

       self.exportSession = [[AVAssetExportSession alloc]
                             initWithAsset:anAsset presetName:AVAssetExportPresetHighestQuality];
       // Implementation continues.

       NSURL *furl = [NSURL fileURLWithPath:self.tmpVideoPath];

       self.exportSession.outputURL = furl;
       self.exportSession.outputFileType = AVFileTypeMPEG4;

       CMTime start = CMTimeMakeWithSeconds(self.startTime, anAsset.duration.timescale);
       CMTime duration = CMTimeMakeWithSeconds(self.stopTime-self.startTime, anAsset.duration.timescale);
       CMTimeRange range = CMTimeRangeMake(start, duration);
       self.exportSession.timeRange = range;

       self.trimBtn.hidden = YES;
       self.myActivityIndicator.hidden = NO;
       [self.myActivityIndicator startAnimating];
       [self.exportSession exportAsynchronouslyWithCompletionHandler:^{

           switch ([self.exportSession status]) {
               case AVAssetExportSessionStatusFailed:
                   NSLog(@"Export failed: %@", [[self.exportSession error] localizedDescription]);
                   break;
               case AVAssetExportSessionStatusCancelled:
                   NSLog(@"Export canceled");
                   break;
               default:
                   NSLog(@"NONE");
                   dispatch_async(dispatch_get_main_queue(), ^{
                       [self.myActivityIndicator stopAnimating];
                       self.myActivityIndicator.hidden = YES;
                       self.trimBtn.hidden = NO;
                       [self playMovie:self.tmpVideoPath];
                   });
                   break;
           }
       }];
    }
    }

    2.I send the video trimmed to server,then android device get video from server,but they find audio/video out of sync,at first I consider of server do something wrong,so I just send video to android device with USB,the error still exist.

    3.so I analyze the trimmed video by ffmpeg tools :
    ffmpeg -i trimVideo.mp4
    then I find trimVideo.mp4 start is a negative number.
    here is what ffmpeg print :

    Metadata :
    major_brand : qt
    minor_version : 0
    compatible_brands : qt
    creation_time : 2015-08-29 12:22:13
    encoder : Lavf56.15.102
    Duration : 00:02:21.77, start : -4.692568, bitrate : 359 kb/s
    Stream #0:0(und) : Audio : aac (LC) (mp4a / 0x6134706D), 24000 Hz, stereo, fltp, 69 kb/s (default)
    Metadata :
    creation_time : 2015-08-29 12:22:13
    handler_name : Core Media Data Handler
    Stream #0:1(und) : Video : h264 (High) (avc1 / 0x31637661), yuv420p, 512x288 [SAR 1:1 DAR 16:9], 277 kb/s, 15.16 fps, 15.17 tbr, 12136 tbn, 30.34 tbc (default)
    Metadata :
    creation_time : 2015-08-29 12:22:13
    handler_name : Core Media Data Handler
    encoder : ’avc1’

    I have been puzzled by this bug for several days, I am sorry of my bad english and I really need your help,thanks.