Recherche avancée

Médias (91)

Autres articles (51)

  • HTML5 audio and video support

    13 avril 2011, par

    MediaSPIP uses HTML5 video and audio tags to play multimedia files, taking advantage of the latest W3C innovations supported by modern browsers.
    The MediaSPIP player used has been created specifically for MediaSPIP and can be easily adapted to fit in with a specific theme.
    For older browsers the Flowplayer flash fallback is used.
    MediaSPIP allows for media playback on major mobile platforms with the above (...)

  • Support audio et vidéo HTML5

    10 avril 2011

    MediaSPIP utilise les balises HTML5 video et audio pour la lecture de documents multimedia en profitant des dernières innovations du W3C supportées par les navigateurs modernes.
    Pour les navigateurs plus anciens, le lecteur flash Flowplayer est utilisé.
    Le lecteur HTML5 utilisé a été spécifiquement créé pour MediaSPIP : il est complètement modifiable graphiquement pour correspondre à un thème choisi.
    Ces technologies permettent de distribuer vidéo et son à la fois sur des ordinateurs conventionnels (...)

  • De l’upload à la vidéo finale [version standalone]

    31 janvier 2010, par

    Le chemin d’un document audio ou vidéo dans SPIPMotion est divisé en trois étapes distinctes.
    Upload et récupération d’informations de la vidéo source
    Dans un premier temps, il est nécessaire de créer un article SPIP et de lui joindre le document vidéo "source".
    Au moment où ce document est joint à l’article, deux actions supplémentaires au comportement normal sont exécutées : La récupération des informations techniques des flux audio et video du fichier ; La génération d’une vignette : extraction d’une (...)

Sur d’autres sites (9690)

  • How to force specific AVInputFormat in code (FFMPEG) ?

    18 février 2020, par kugipark

    ++Plaease understand that maybe some words or sentences could not be correct English.++

    I’m novice programmer and developing a video player app for Android which can play 5ch .avi video from http. It based on ffplay.c in FFMPEG libarary.

    Currently I have 2 problems for this below. It has occured only in android devices.


    1) Too much time taken for detecting format.

    • opening and finding stream info takes more than a minute when I trying to open 5ch video source whereas normal .mp4 (h264) source open almost immediately.

    2) Demuxing is too slow when it comes to large size video.

    • If the resolution of video getting larger, then displaying frame rate getting slower even though there are enough memory, network and CPU resources physically.

    To resolve my problem, I tried to force the format and decoders but I couldn’t found some information for specifying the input source in code level.
    The official doc site only refers to a sentence about those parameters like "If non-NULL, this parameter forces a specific input format. Otherwise the format is autodetected.". So I don’t have any clues how to set the number of streams, decoders, decoders’ private options, and etc. (And also which parameters should I manage.) If someone knows how to set the options(like AVDictionary), and pass to the av functions, please let me know an exmple. The source contains 2 video streams, 1 audio stream, and 2 more extra streams (for custom data like gps). The stream information of video is below. I printed it manually, and these are auto-detected information.

       ---------- File format information ----------
    flags=2097152
    video_codec_id=0 (NONE)
    audio_codec_id=0 (NONE)
    ctx_flags=0
    data_codec_id=0 (NONE)
    format_whitelist=(null)
    iformat=0xa19d0d2c
    ---------- Stream information ----------
    stream 1 of 5:
    ----- common ----------
    bit_rate: 11383235
    bits_per_coded_sample: 24
    bits_per_raw_sample: 0
    codec_id: 0x1C (H264)
    codec_tag: 875967048
    extradata_size: 0
    level: -99
    profile: -99
    sample_rate: 0
    ----- Video Stream ----------
    chroma_location: 0
    color_primaries: 2
    color_space: 2
    color_trc: 2
    field_order: 0
    format: -1 (NONE)
    height: 1080
    width: 1920
    sample_aspect_ratio.den: 1
    sample_aspect_ratio.num: 0
    video_delay: 0
    ----------------------------------------
    stream 2 of 5:
    ----- common ----------
    bit_rate: 6185438
    bits_per_coded_sample: 24
    bits_per_raw_sample: 0
    codec_id: 0x1C (H264)
    codec_tag: 875967048
    extradata_size: 0
    level: -99
    profile: -99
    sample_rate: 0
    ----- Video Stream ----------
    chroma_location: 0
    color_primaries: 2
    color_space: 2
    color_trc: 2
    field_order: 0
    format: -1 (NONE)
    height: 720
    width: 1280
    sample_aspect_ratio.den: 1
    sample_aspect_ratio.num: 0
    video_delay: 0
    ----------------------------------------
    stream 3 of 5:
    ----- common ----------
    bit_rate: 352800
    bits_per_coded_sample: 16
    bits_per_raw_sample: 0
    codec_id: 0x10000 (PCM_S16LE)
    codec_tag: 1
    extradata_size: 0
    level: -99
    profile: -99
    sample_rate: 22050
    ----- Audio Stream ----------
    block_align: 2
    channels: 1
    channel_layout: 0
    color_range: 0
    frame_size: 0
    initial_padding: 0
    seek_preroll: 0
    trailing_padding: 0
    ----------------------------------------
    stream 4 of 5:
    ----- common ----------
    bit_rate: 15625
    bits_per_coded_sample: 0
    bits_per_raw_sample: 0
    codec_id: 0x0 (NONE)
    codec_tag: 0
    extradata_size: 0
    level: -99
    profile: -99
    sample_rate: 0
    ----- Subtitle Stream ----------
    ----------------------------------------
    stream 5 of 5:
    ----- common ----------
    bit_rate: 33862
    bits_per_coded_sample: 0
    bits_per_raw_sample: 0
    codec_id: 0x0 (NONE)
    codec_tag: 0
    extradata_size: 0
    level: -99
    profile: -99
    sample_rate: 0
    ----- Subtitle Stream ----------
  • ffmpeg concatenating videos of different fps while keeping the total length not changed

    23 novembre 2017, par A_Matar

    I wanna pad an mp4 video stream with another video clip of a static image that I created using :

    def generate_white_vid (duration):
       output_filename = os.path.join(p_path,'white_vid_'+" 0:.2f}".format(duration)+'.mp4')
       ffmpeg_create_vid_from_static_img = 'ffmpeg -loop 1 -i /path/WhiteBackground.jpg -c:v libx264 -t %f -pix_fmt yuv420p -vf scale=1920:1080 %s' % (duration, output_filename)
       p = subprocess.Popen(ffmpeg_create_vid_from_static_img, shell=True)
       p.communicate()
       return output_filename

    I use the following to concatenate :

    def concat_vids(clip_paths):
       filenames_txt = open('clips_to_join.txt','w')
       for clip in clip_paths:
           filenames_txt.write ('file \''+ clip+'\'\n')
       filenames_txt.close()
       output_filename = clip_paths[0].split('.', 2)[0]
       output_file_path = os.path.join(root_path, output_filename+'-padded.mp4')
       # join the clips
       ffmpeg_command = ["ffmpeg", "-f", "concat", "-safe", "0", "-i", "clips_to_join.txt", "-codec", "copy", output_file_path] # output_filename = ch0X-start_time-end_time
       p = subprocess.Popen(ffmpeg_command)
       p.communicate() # wait till the subprocess finishes. You can send commands to process as well.
       return output_file_path

    When I check the length of the resulting video after concatenation, I find that it is not equal to the sum of the two segments that I concatenated, and sometimes it is even less by some seconds !!

    Here is how I get the video length in seconds :

    def ffmpeg_len(vid_path):
       '''
       Returns length in seconds using ffmpeg
       '''
       ffmpeg_get_mediafile_length = ['sh', '-c', 'ffmpeg -i "$1" 2>&1 | grep Duration', '_', vid_path]
       p = subprocess.Popen(ffmpeg_get_mediafile_length, stdout=subprocess.PIPE, stderr=subprocess.PIPE)    
       output, err = p.communicate()
       length_regexp = 'Duration: (\d{2}):(\d{2}):(\d{2})(\.\d+),'
       re_length = re.compile(length_regexp)
       matches = re_length.search(output)
       if matches:
           video_length = int(matches.group(1)) * 3600 + \
                           int(matches.group(2)) * 60 + \
                           int(matches.group(3)) + float(matches.group(4))
           return video_length
       else:
           print("Can't determine video length.")
           print err
           raise SystemExit

    My guess is that maybe the concatenation unifies the fps rate for the all the clips to be joined, if this is the case, how to prevent this from happening ? How can I get a video of the desired length exactly.

    Maybe it worth mentioning that the video to padded is very short 0.42 second, the original video is 210.58 and the resultant video is 210.56 !

    I have verified that ffmpeg does generate the desired padding region and it is of the desired length 0.42 I got a 0.43 segment when I forced 30 fps but it is okay.

  • cv::cudacodec::VideoReader unable to Play rtsp stream

    22 février 2018, par Pawan

    System information

    • OpenCV => 3.3.0
    • Operating System / Platform => Ubuntu 16.04, x86_64
    • Compiler => gcc version 5.4.1 20160904
    • Cuda => 8.0
    • Nvidia card => GTX 1080 Ti
    • ffmpeg details
      • libavutil 55. 74.100 / 55. 74.100
      • libavcodec 57.103.100 / 57.103.100
      • libavformat 57. 77.100 / 57. 77.100
      • libavdevice 57. 7.101 / 57. 7.101
      • libavfilter 6.100.100 / 6.100.100
      • libswscale 4. 7.103 / 4. 7.103
      • libswresample 2. 8.100 / 2. 8.100

    Detailed description

    i am trying to play a rtsp stream using cudacodec::VideoReader

    Rtsp Stream Details ( from vlc )

    stream_details

    this stream plays fine in vlc and cv::VideoCapture but when i try to play it in cudacodec::VideoReader i get a error saying :

    OpenCV Error: Gpu API call (CUDA_ERROR_FILE_NOT_FOUND [Code = 301]) in CuvidVideoSource, file /home/deep/Development/libraries/opencv/opencv/modules/cudacodec/src/cuvid_video_source.cpp, line 66

    OpenCV Error: Assertion failed (init_MediaStream_FFMPEG()) in FFmpegVideoSource, file /home/deep/Development/libraries/opencv/opencv/modules/cudacodec/src/ffmpeg_video_source.cpp, line 101

    Steps to reproduce

    #include <iostream>
    #include "opencv2/opencv_modules.hpp"

    #if defined(HAVE_OPENCV_CUDACODEC)

    #include <opencv2></opencv2>core.hpp>
    #include <opencv2></opencv2>cudacodec.hpp>
    #include <opencv2></opencv2>highgui.hpp>

    int main(int argc, const char* argv[])
    {
       const std::string fname = "rtsp://admin:admin@192.168.1.13/media/video2";

       cv::namedWindow("GPU", cv::WINDOW_NORMAL);

       cv::cuda::GpuMat d_frame;
       cv::Ptr d_reader = cv::cudacodec::createVideoReader(fname);

       for (;;)
       {

           if (!d_reader->nextFrame(d_frame))
               break;

           cv::Mat frame;
           d_frame.download(frame);
           cv::imshow("GPU", frame);

           if (cv::waitKey(3) > 0)
               break;
       }
       return 0;
    }

    #else
    int main()
    {
       std::cout &lt;&lt; "OpenCV was built without CUDA Video decoding support\n" &lt;&lt; std::endl;
       return 0;
    }
    #endif
    </iostream>

    I tried debugging it using GDB and saw that in ffmpeg_video_source.cpp bool init_MediaStream_FFMPEG() directly returns without checking the if condition.

    GDB output

    cv::cudacodec::detail::FFmpegVideoSource::FFmpegVideoSource
    (this=0x402a20 &lt;_start>, fname=...) at /home/deep/Development/libraries/opencv/opencv/modules/cudacodec/src/ffmpeg_video_source.cpp:98
    98      cv::cudacodec::detail::FFmpegVideoSource::FFmpegVideoSource(const String&amp; fname) :
    (gdb) n
    99          stream_(0)
    (gdb) n
    101         CV_Assert( init_MediaStream_FFMPEG() );
    (gdb) s
    (anonymous namespace)::init_MediaStream_FFMPEG () at /home/deep/Development/libraries/opencv/opencv/modules/cudacodec/src/ffmpeg_video_source.cpp:94
    94              return initialized;
    (gdb) display initialized
    4: initialized = false
    (gdb) s
    95          }

    UPDATE :

    I have solved the problem. solution link