Recherche avancée

Médias (0)

Mot : - Tags -/tags

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

Autres articles (35)

  • Support de tous types de médias

    10 avril 2011

    Contrairement à beaucoup de logiciels et autres plate-formes modernes de partage de documents, MediaSPIP a l’ambition de gérer un maximum de formats de documents différents qu’ils soient de type : images (png, gif, jpg, bmp et autres...) ; audio (MP3, Ogg, Wav et autres...) ; vidéo (Avi, MP4, Ogv, mpg, mov, wmv et autres...) ; contenu textuel, code ou autres (open office, microsoft office (tableur, présentation), web (html, css), LaTeX, Google Earth) (...)

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

  • Keeping control of your media in your hands

    13 avril 2011, par

    The vocabulary used on this site and around MediaSPIP in general, aims to avoid reference to Web 2.0 and the companies that profit from media-sharing.
    While using MediaSPIP, you are invited to avoid using words like "Brand", "Cloud" and "Market".
    MediaSPIP is designed to facilitate the sharing of creative media online, while allowing authors to retain complete control of their work.
    MediaSPIP aims to be accessible to as many people as possible and development is based on expanding the (...)

Sur d’autres sites (8037)

  • Losing quality when encoding with ffmpeg

    22 mai 2016, par lupod

    I am using the c libraries of ffmpeg to read frames from a video and create an output file that is supposed to be identical to the input.
    However, somewhere during this process some quality gets lost and the result is "less sharp". My guess is that the problem is the encoding and that the frames are too compressed (also because the size of the file decreases quite significantly). Is there some parameter in the encoder that allows me to control the quality of the result ? I found that AVCodecContext has a compression_level member, but changing it that does not seem to have any effect.

    I post here part of my code in case it could help. I would say that something must be changed in the init function of OutputVideoBuilder when I set the codec. The AVCodecContext that is passed to the method is the same of InputVideoHandler.
    Here are the two main classes that I created to wrap the ffmpeg functionalities :

    // This class opens the video files and sets the decoder
    class InputVideoHandler {
    public:
     InputVideoHandler(char* name);
     ~InputVideoHandler();
     AVCodecContext* getCodecContext();
     bool readFrame(AVFrame* frame, int* success);

    private:
     InputVideoHandler();
     void init(char* name);
     AVFormatContext* formatCtx;
     AVCodec* codec;
     AVCodecContext* codecCtx;
     AVPacket packet;
     int streamIndex;
    };

    void InputVideoHandler::init(char* name) {
     streamIndex = -1;
     int numStreams;

     if (avformat_open_input(&formatCtx, name, NULL, NULL) != 0)
       throw std::exception("Invalid input file name.");

     if (avformat_find_stream_info(formatCtx, NULL)<0)
       throw std::exception("Could not find stream information.");

     numStreams = formatCtx->nb_streams;

     if (numStreams < 0)
       throw std::exception("No streams in input video file.");

     for (int i = 0; i < numStreams; i++) {
       if (formatCtx->streams[i]->codec->codec_type == AVMEDIA_TYPE_VIDEO) {
         streamIndex = i;
         break;
       }
     }

     if (streamIndex < 0)
       throw std::exception("No video stream in input video file.");

     // find decoder using id
     codec = avcodec_find_decoder(formatCtx->streams[streamIndex]->codec->codec_id);
     if (codec == nullptr)
       throw std::exception("Could not find suitable decoder for input file.");

     // copy context from input stream
     codecCtx = avcodec_alloc_context3(codec);
     if (avcodec_copy_context(codecCtx, formatCtx->streams[streamIndex]->codec) != 0)
       throw std::exception("Could not copy codec context from input stream.");

     if (avcodec_open2(codecCtx, codec, NULL) < 0)
       throw std::exception("Could not open decoder.");
    }

    // frame must be initialized with av_frame_alloc() before!
    // Returns true if there are other frames, false if not.
    // success == 1 if frame is valid, 0 if not.
    bool InputVideoHandler::readFrame(AVFrame* frame, int* success) {
     *success = 0;
     if (av_read_frame(formatCtx, &packet) < 0)
       return false;
     if (packet.stream_index == streamIndex) {
       avcodec_decode_video2(codecCtx, frame, success, &packet);
     }
     av_free_packet(&packet);
     return true;
    }

    // This class opens the output and write frames to it
    class OutputVideoBuilder{
    public:
     OutputVideoBuilder(char* name, AVCodecContext* inputCtx);
     ~OutputVideoBuilder();
     void writeFrame(AVFrame* frame);
     void writeVideo();

    private:
     OutputVideoBuilder();
     void init(char* name, AVCodecContext* inputCtx);
     void logMsg(AVPacket* packet, AVRational* tb);
     AVFormatContext* formatCtx;
     AVCodec* codec;
     AVCodecContext* codecCtx;
     AVStream* stream;
    };

    void OutputVideoBuilder::init(char* name, AVCodecContext* inputCtx) {
     if (avformat_alloc_output_context2(&formatCtx, NULL, NULL, name) < 0)
       throw std::exception("Could not determine file extension from provided name.");

     codec = avcodec_find_encoder(inputCtx->codec_id);
     if (codec == nullptr) {
       throw std::exception("Could not find suitable encoder.");
     }

     codecCtx = avcodec_alloc_context3(codec);
     if (avcodec_copy_context(codecCtx, inputCtx) < 0)
       throw std::exception("Could not copy output codec context from input");

     codecCtx->time_base = inputCtx->time_base;
     codecCtx->compression_level = 0;

     if (avcodec_open2(codecCtx, codec, NULL) < 0)
       throw std::exception("Could not open encoder.");

     stream = avformat_new_stream(formatCtx, codec);
     if (stream == nullptr) {
       throw std::exception("Could not allocate stream.");
     }

     stream->id = formatCtx->nb_streams - 1;
     stream->codec = codecCtx;
     stream->time_base = codecCtx->time_base;



     av_dump_format(formatCtx, 0, name, 1);
     if (!(formatCtx->oformat->flags & AVFMT_NOFILE)) {
       if (avio_open(&formatCtx->pb, name, AVIO_FLAG_WRITE) < 0) {
         throw std::exception("Could not open output file.");
       }
     }

     if (avformat_write_header(formatCtx, NULL) < 0) {
       throw std::exception("Error occurred when opening output file.");
     }

    }

    void OutputVideoBuilder::writeFrame(AVFrame* frame) {
     AVPacket packet = { 0 };
     int success;
     av_init_packet(&packet);

     if (avcodec_encode_video2(codecCtx, &packet, frame, &success))
       throw std::exception("Error encoding frames");

     if (success) {
       av_packet_rescale_ts(&packet, codecCtx->time_base, stream->time_base);
       packet.stream_index = stream->index;
       logMsg(&packet,&stream->time_base);
       av_interleaved_write_frame(formatCtx, &packet);
     }
     av_free_packet(&packet);
    }

    This is the part of the main function that reads and write frames :

    while (inputHandler->readFrame(frame,&gotFrame)) {

       if (gotFrame) {
         try {
           outputBuilder->writeFrame(frame);
         }
         catch (std::exception e) {
           std::cout << e.what() << std::endl;
           return -1;
         }
       }
     }
  • Executing an exe and reading the OutputStream

    30 septembre 2014, par vlatkozelka

    I have a program called FFprobe which probes media (files/live streams ... ) and outputs result in different formats , for example :

    ffprobe.exe -i test.ts -print_format xml -show_programs

    gives this output :

       <?xml version="1.0" encoding="UTF-8"?>
    <ffprobe>
       <programs>
           <program>
               <tag key="service_name" value="Arabica TV"></tag>
               <tag key="service_provider" value="Nilesat"></tag>
               <streams>
                   <stream index="10" profile="Main" width="720" height="576" level="8" timecode="08:28:54:09">
                       <disposition default="0" dub="0" original="0" comment="0" lyrics="0" karaoke="0" forced="0"></disposition>
                   </stream>
                   <stream index="4" channels="2">
                       <disposition default="0" dub="0" original="0" comment="0" lyrics="0" karaoke="0" forced="0"></disposition>
                   </stream>
               </streams>
           </program>
    ... more programs
    </programs></ffprobe>

    to retrieve this info in java i used ProcessBuilder and a scanner , and then id write to a file once the result is ok ... but it wasnt :

    Process proc = new ProcessBuilder("ffprobe.exe","-i", ... same arguments );
    Scanner sc = new Scanner (proc.getInputStream()) // im 100% sure its not errorStream
    while(sc.hasNext()){
      System.out.println(sc.nextLine());
    }

    the app just hangs with no output , i know its hanging cuz the process is still running and scanner has next , but , i don’t know why it would do that ?If i execute the same in cmd i would get good result and ofc i can write to file with ">"

    Ive tried it w/o the -print_format option , which gives the info in a plain text on the errorstream(i know its error cuz i was able to write with 2> not >> ) , and i was able to read the error stream in java , but its not meant for parsing cuz very very un-organized .

      Input #0, mpegts, from 'PBR_REC_20140426094852_486.ts':
     Duration: 00:13:34.30, start: 7791.344722, bitrate: 42154 kb/s
     Program 1201
       Metadata:
         service_name    : Arabica TV
         service_provider: Nilesat
       Stream #0:19[0x7db]: Video: mpeg2video (Main) ([2][0][0][0] / 0x0002), yuv420p(tv), 720x576 [SAR 16:15 DAR 4:3], max. 2348 kb/s, 25 fps, 25 tbr, 90k tbn, 50 tbc
       Stream #0:3[0xbcf]: Audio: mp2, 48000 Hz, stereo, s16p, 384 kb/s
     Program 1202
       Metadata:
         service_name    : NBN
         service_provider: NILESAT
       Stream #0:10[0x7d1]: Video: mpeg2video (Main) ([2][0][0][0] / 0x0002), yuv420p(tv), 720x576 [SAR 16:15 DAR 4:3], max. 2600 kb/s, 25 fps, 25 tbr, 90k tbn, 50 tbc
       Stream #0:11[0xbba](eng): Audio: mp2 ([3][0][0][0] / 0x0003), 48000 Hz, stereo, s16p, 125 kb/s
     Program 1203
       Metadata:
         service_name    : Heya TV
         service_provider: NILESAT
       Stream #0:5[0x7d2]: Video: mpeg2video (Main) ([2][0][0][0] / 0x0002), yuv420p(tv), 720x576 [SAR 16:15 DAR 4:3], max. 2600 kb/s, 25 fps, 25 tbr, 90k tbn, 50 tbc
       Stream #0:6[0xbbc](eng): Audio: mp2 ([3][0][0][0] / 0x0003), 48000 Hz, mono, s16p, 125 kb/s
     Program 1204  ... more programs

    now it might seem organized and "parse-able" and i actually made a parser that worked to some point , but sometimes it doesnt stick to this structure and ruins the whole parsing, its why i need a xml/json ...

    The -print_format im sure outputs to outputstream.

    Im not asking for help on how to use FFprobe as thats not this place’s purpose , Im asking why am i not being able to get the output stream from java while it is definitely outputting if i execute in windows .

    I also tried apache commons-exec as i know processbuilder can be a pain ,it did execute perfectly and showed in System.in (black for intput and red for error), but getting the stream with apache is something i couldn’t understand , i tried this example

    The xml parser i already taken care of , simply put i just need to execute that first command from java and read the output , but for some reason its not working .

  • Notes on Linux for Dreamcast

    23 février 2011, par Multimedia Mike — Sega Dreamcast, VP8

    I wanted to write down some notes about compiling Linux on Dreamcast (which I have yet to follow through to success). But before I do, allow me to follow up on my last post where I got Google’s libvpx library decoding VP8 video on the DC. Remember when I said the graphics hardware could only process variations of RGB color formats ? I was mistaken. Reading over some old documentation, I noticed that the DC’s PowerVR hardware can also handle packed YUV textures (UYVY, specifically) :



    The video looks pretty sharp in the small photo. Up close, less so, due to the low resolution and high quantization of the test vector combined with the naive chroma upscaling. For the curious, the grey box surrounding the image highlights the 256-square texture that the video frame gets plotted on. Texture dimensions have to be powers of 2.

    Notes on Linux for Dreamcast
    I’ve occasionally dabbled with Linux on my Dreamcast. There’s an ancient (circa 2001) distro based around a build of kernel 2.4.5 out there. But I wanted to try to get something more current compiled. Thus far, I have figured out how to cross compile kernels pretty handily but have been unsuccessful in making them run.

    Here are notes are the compilation portion :

    • kernel.org provides a very useful set of cross compiling toolchains
    • get the gcc 4.5.1 cross toolchain for SH-4 (the gcc 4.3.3 one won’t work because the binutils is too old ; it will fail to assemble certain instructions as described in this post)
    • working off of Linux kernel 2.6.37, edit the top-level Makefile ; find the ARCH and CROSS_COMPILE variables and set appropriately :
      ARCH ?= sh
      CROSS_COMPILE ?= /path/to/gcc-4.5.1-nolibc/sh4-linux/bin/sh4-linux-
      
    • $ make dreamcast_defconfig
    • $ make menuconfig ... if any changes to the default configuration are desired
    • manually edit arch/sh/Makefile, changing :
      cflags-$(CONFIG_CPU_SH4) := $(call cc-option,-m4,) \
              $(call cc-option,-mno-implicit-fp,-m4-nofpu)
      

      to :

      cflags-$(CONFIG_CPU_SH4) := $(call cc-option,-m4,) \
              $(call cc-option,-mno-implicit-fp)
      

      I.e., remove the '-m4-nofpu' option. According to the gcc man page, this will "Generate code for the SH4 without a floating-point unit." Why this is a default is a mystery since the DC’s SH-4 has an FPU and compilation fails when enabling this option.

    • On that note, I was always under the impression that the DC sported an SH-4 CPU with the model number SH7750. According to this LinuxSH wiki page as well as the Linux kernel help, it actually has an SH7091 variant. This photo of the physical DC hardware corroborates the model number.
    • $ make ... to build a Linux kernel for the Sega Dreamcast

    Running
    So I can compile the kernel but running the kernel (the resulting vmlinux ELF file) gives me trouble. The default kernel ELF file reports an entry point of 0x8c002000. Attempting to upload this through the serial uploading facility I have available to me triggers a system reset almost immediately, probably because that’s the same place that the bootloader calls home. I have attempted to alter the starting address via ’make menuconfig’ -> System type -> Memory management options -> Physical memory start address. This allows the upload to complete but it still does not run. It’s worth noting that the 2.4.5 vmlinux file from the old distribution can be executed when uploaded through the serial loader, and it begins at 0x8c210000.