Recherche avancée

Médias (91)

Autres articles (54)

  • Menus personnalisés

    14 novembre 2010, par

    MediaSPIP utilise le plugin Menus pour gérer plusieurs menus configurables pour la navigation.
    Cela permet de laisser aux administrateurs de canaux la possibilité de configurer finement ces menus.
    Menus créés à l’initialisation du site
    Par défaut trois menus sont créés automatiquement à l’initialisation du site : Le menu principal ; Identifiant : barrenav ; Ce menu s’insère en général en haut de la page après le bloc d’entête, son identifiant le rend compatible avec les squelettes basés sur Zpip ; (...)

  • Les vidéos

    21 avril 2011, par

    Comme les documents de type "audio", Mediaspip affiche dans la mesure du possible les vidéos grâce à la balise html5 .
    Un des inconvénients de cette balise est qu’elle n’est pas reconnue correctement par certains navigateurs (Internet Explorer pour ne pas le nommer) et que chaque navigateur ne gère en natif que certains formats de vidéos.
    Son avantage principal quant à lui est de bénéficier de la prise en charge native de vidéos dans les navigateur et donc de se passer de l’utilisation de Flash et (...)

  • (Dés)Activation de fonctionnalités (plugins)

    18 février 2011, par

    Pour gérer l’ajout et la suppression de fonctionnalités supplémentaires (ou plugins), MediaSPIP utilise à partir de la version 0.2 SVP.
    SVP permet l’activation facile de plugins depuis l’espace de configuration de MediaSPIP.
    Pour y accéder, il suffit de se rendre dans l’espace de configuration puis de se rendre sur la page "Gestion des plugins".
    MediaSPIP est fourni par défaut avec l’ensemble des plugins dits "compatibles", ils ont été testés et intégrés afin de fonctionner parfaitement avec chaque (...)

Sur d’autres sites (9208)

  • Using ffmpeg dll's from a windows 32 bit app

    8 avril 2020, par Derek

    I am trying to use ffmpeg via dll calls from a win32 app (compiled in clarion)

    



    I transcoded the example file encode_video.c and that worked 100% however I was left with a .h264 file instead of a .mp4 file.

    



    I then transcoded the example muxing.c however it crashes and I am at a loss for options.

    



    Any help would be most appreciated.

    



    Encode_mp4 ROUTINE
! avformat_alloc_output_context2 *******************************************************************************************
file_name = 'myvideo.mp4'
! Try guess format from filename
if CHECK_STACK then ds_SaveStack .
Result = avformat_alloc_output_context2(ThisPtrPtr, 0, NullCString, file_name);
if CHECK_STACK then ds_TestStack .
if Result < 0
    ds_OutputDebugString('avformat_alloc_output_context2 Try guess format failed, try mpeg', TRUE)
    CString1 = 'mpeg'
    if CHECK_STACK then ds_SaveStack .
    Result = avformat_alloc_output_context2(ThisPtrPtr, 0, CString1, file_name);
    if CHECK_STACK then ds_TestStack .
    if Result < 0
        ds_OutputDebugString('avformat_alloc_output_context2 failed', TRUE)
        stop('Could not allocate output format context')
        exit
    end
end
formater_ctxt &= (ThisPtrPtr)
!ds_OutputDebugString('formater_ctxt=' & address(formater_ctxt), TRUE)
assert(not(formater_ctxt &= NULL), 'Check AVFormatContext formater_ctxt')
do VerifyFormatContext
assert(formater_ctxt.oformat > 0, 'Check AVFormatContext formater_ctxt.oformat')
formater &= (formater_ctxt.oformat)
do VerifyFormat
ds_OutputDebugString('avformat_alloc_output_context2 OK', TRUE)

! avcodec_find_encoder *******************************************************************************************
if CHECK_STACK then ds_SaveStack .
encoder &= avcodec_find_encoder(formater.video_codec)
if CHECK_STACK then ds_TestStack .
if encoder &= NULL
    ds_OutputDebugString('avcodec_find_encoder failed', TRUE)
    stop('Could not find encoder')
    exit
end
do VerifyEncoder
ds_OutputDebugString('avcodec_find_encoder OK', TRUE)

! avformat_new_stream *******************************************************************************************
if CHECK_STACK then ds_SaveStack .
stream &= avformat_new_stream(formater_ctxt, encoder)
if CHECK_STACK then ds_TestStack .
if stream &= NULL 
    ds_OutputDebugString('avformat_new_stream failed', TRUE)
    stop('Could not create new stream')
    exit
end
do VerifyStream
stream.id = formater_ctxt.nb_streams-1
ds_OutputDebugString('avformat_new_stream OK', TRUE)

! avcodec_alloc_context3 *******************************************************************************************
if CHECK_STACK then ds_SaveStack .
encoder_ctxt &= avcodec_alloc_context3(encoder)
if CHECK_STACK then ds_TestStack .
if encoder_ctxt &= NULL 
    ds_OutputDebugString('avcodec_alloc_context3 failed', TRUE)
    stop('Could not allocate video codec context')
    exit
end
do VerifyEncoderContext
ds_OutputDebugString('avcodec_alloc_context3 OK', TRUE)

! Video settings *******************************************************************************************
do InitVideoSettings

assert(AV_CODEC_FLAG_GLOBAL_HEADER = bshift(1, 22), 'Check AV_CODEC_FLAG_GLOBAL_HEADER')
if band(formater.flags, AVFMT_GLOBALHEADER)
   encoder_ctxt.flags = bor(encoder_ctxt.flags, AV_CODEC_FLAG_GLOBAL_HEADER) !avctx->flags |= AV_CODEC_FLAG_GLOBAL_HEADER;
end

! avcodec_open2 *******************************************************************************************
if CHECK_STACK then ds_SaveStack .
Result = avcodec_open2(encoder_ctxt, encoder, 0)
if CHECK_STACK then ds_TestStack .
if Result < 0
    ds_OutputDebugString('avcodec_open2 failed.  Result=' & Result, TRUE)
    stop('Could not open codec')
    exit
end
ds_OutputDebugString('avcodec_open2 OK', TRUE)

! av_frame_alloc *******************************************************************************************
if CHECK_STACK then ds_SaveStack .
frame &= av_frame_alloc();
if CHECK_STACK then ds_TestStack .
if frame &= NULL
    ds_OutputDebugString('av_frame_alloc failed', TRUE)
    stop('Could not allocate video frame')
    exit
end
do VerifyFrame
frame.format = encoder_ctxt.pix_fmt
frame.width = encoder_ctxt.width
frame.height = encoder_ctxt.height
ds_OutputDebugString('av_frame_alloc OK', TRUE)

! av_frame_get_buffer *******************************************************************************************
if CHECK_STACK then ds_SaveStack .
Result = av_frame_get_buffer(frame, 32)
if CHECK_STACK then ds_TestStack .
if Result < 0
    ds_OutputDebugString('av_frame_get_buffer failed', TRUE)
    stop('Could not allocate video frame buffer Error = ' & Result)
    exit
end
do VerifyFrameBuffer
ds_OutputDebugString('av_frame_get_buffer OK', TRUE)

!frame->data offset=0  Array[8] of *int8_t
UseData0 &= (frame.data[1])
UseData1 &= (frame.data[2])
UseData2 &= (frame.data[3])

if CHECK_STACK then ds_SaveStack .
Result = avcodec_parameters_from_context(stream.codecpar, encoder_ctxt);
if CHECK_STACK then ds_TestStack .
if Result < 0
    ds_OutputDebugString('avcodec_parameters_from_context failed', TRUE)
    stop('Could not initialize stream parameters')
    exit
end
ds_OutputDebugString('avcodec_parameters_from_context OK', TRUE)

! av_dump_format *******************************************************************************************
ds_OutputDebugString('before call to av_dump_format  file_name=' & file_name, TRUE)
av_dump_format(formater_ctxt, 0, file_name, 1)


    



    I get a crash at last line - call to av_dump_format()

    



    If I comment this code then I get a crash on the very next lib call :

    



        ! avio_open *******************************************************************************************
if not(band(formater.flags, AVFMT_NOFILE)) 
    ds_OutputDebugString('before call to avio_open  file_name=' & file_name, TRUE)
    ThisInt &= address(formater_ctxt.pb)
    Result = avio_open(ThisInt, file_name, AVIO_FLAG_WRITE)


    



    Strangely if I comment the setup call to av_log_set_callback(my_log_callback) then the crash moves down to the next lib call : avformat_write_header

    


  • OpenCV VideoWriter produces "can't find starting number" error

    5 avril 2020, par user3325139

    I am trying to write 16-bit grayscale video using the FFV1 codec and opencv.ImageWriter on Windows 10

    



    Here is my code :

    



    import numpy as np
import cv2, pdb

print(cv2.getBuildInformation())

def to8(img):
    return (img/256).astype('uint8')

cap = cv2.VideoCapture(0+cv2.CAP_DSHOW)
cap.set(cv2.CAP_PROP_FOURCC, cv2.VideoWriter_fourcc('Y','1','6',' '))
cap.set(cv2.CAP_PROP_CONVERT_RGB, False)

out = cv2.VideoWriter('out.avi', cv2.VideoWriter_fourcc('F','F','V','1'), cap.get(cv2.CAP_PROP_FPS), (int(cap.get(cv2.CAP_PROP_FRAME_WIDTH)),int(cap.get(cv2.CAP_PROP_FRAME_HEIGHT))))

while True:
    ret, frame = cap.read()
    frame = cv2.normalize(frame,None,0,65535,cv2.NORM_MINMAX)

    cv2.imshow('Video',to8(frame))
    out.write(frame)

    if cv2.waitKey(1) & 0xFF == ord('q'):
        break
cap.release()
out.release()
cv2.destroyAllWindows()


    



    And here is my error :

    



    [ERROR:0] global C:\projects\opencv-python\opencv\modules\videoio\src\cap.cpp (415) cv::VideoWriter::open VIDEOIO(CV_IMAGES): raised OpenCV exception:

OpenCV(4.2.0) C:\projects\opencv-python\opencv\modules\videoio\src\cap_images.cpp:253: error: (-5:Bad argument) CAP_IMAGES: can't find starting number (in the name of file): out.avi in function 'cv::icvExtractPattern'


    



    I am running this script from a command window with admin privileges. I've tried both making sure the output file does and does not exist before running.

    



    My OpenCV build information is here : https://pastebin.com/whtF6ixG

    



    Thanks !

    



    EDIT :
Based on Rotem's suggestion, instead of using VideoWriter I piped directly to FFMPEG using ffmpeg-python :

    



    import numpy as np
import cv2, pdb
import ffmpeg

def to8(img):
    return (img/256).astype('uint8')

cap = cv2.VideoCapture(0+cv2.CAP_DSHOW)
cap.set(cv2.CAP_PROP_FOURCC, cv2.VideoWriter_fourcc('Y','1','6',' '))
cap.set(cv2.CAP_PROP_CONVERT_RGB, False)

ff_proc = (
    ffmpeg
    .input('pipe:',format='rawvideo',pix_fmt='gray16le',s='%sx%s'%(int(cap.get(cv2.CAP_PROP_FRAME_WIDTH)),int(cap.get(cv2.CAP_PROP_FRAME_HEIGHT))),r='60')
    .output('out3.avi',vcodec='ffv1',an=None)
    .run_async(pipe_stdin=True)
)

while True:
    ret, frame = cap.read()

    cv2.imshow('Video',to8(frame))
    ff_proc.stdin.write(frame)

    if cv2.waitKey(1) & 0xFF == ord('q'):
        break

out.terminate()
cap.release()
cv2.destroyAllWindows()


    


  • Why won't this encrypted HLS video play on iOS (but works on Windows Chrome via hls.js library) ?

    8 mai 2023, par Ryan

    I am trying to play an MP4 test video.

    


    My /home/vagrant/Code/example/public/hls_hls.keyInfo is :

    


    https://example.com/hls.key
/home/vagrant/Code/example/public/hls_hls.key
467216aae8a26fb699080812628031955e304a66e9e4480f9b70d31d8fe94e9a


    


    My /home/vagrant/Code/example/public/hls_hls.key was generated using PHP : hex2bin('467216aae8a26fb699080812628031955e304a66e9e4480f9b70d31d8fe94e9a')

    


    The ffmpeg command for encrypting the video as HLS playlist with "ts" files :

    


    '/usr/bin/ffmpeg' '-y' '-i' 'storage/app/sample_media2/2020-02-27/Sample_Videos_5.mp4' 
'-c:v' 'libx264' '-s:v' '1920x1080' '-crf' '20' '-sc_threshold' '0' '-g' '48' 
'-keyint_min' '48' '-hls_list_size' '0' 
'-hls_time' '10' '-hls_allow_cache' '0' '-b:v' '4889k' '-maxrate' '5866k' 
'-hls_segment_type' 'mpegts' '-hls_fmp4_init_filename' 'output_init.mp4' 
'-hls_segment_filename' 'storage/app/public/test/output_1080p_%04d.ts' 
'-hls_key_info_file' '/home/vagrant/Code/example/public/hls_hls.keyInfo' 
'-strict' '-2' '-threads' '12' 'storage/app/public/test/output_1080p.m3u8'


    


    Then, I know from https://caniuse.com/#search=hls that Windows Chrome won't be able to play the HLS video without a library, so I use https://github.com/video-dev/hls.js/, and Windows Chrome successfully plays the encrypted video !

    


    However, iOS Safari is unable to play it (with or without the hls.js library).

    


    On iOS Safari, when I try to play the video, I see just a quick glimpse (less than a second) where the screen shows 0:15, so it must be reading and decrypting enough to know the correct duration of the video.

    


    So, to debug, I log events :

    


    const nativeHlsEvents = ['play', 'playing', 'abort', 'error', 'canplaythrough', 'waiting', 'loadeddata', 'loadstart', 'progress', 'timeupdate', 'volumechange'];
$.each(nativeHlsEvents, function (i, eventType) {
    video.addEventListener(eventType, (event) => {//https://developer.mozilla.org/en-US/docs/Web/API/HTMLMediaElement
        console.log(eventType, event);
        if (eventType === 'error') {
            console.error(video.error);//https://developer.mozilla.org/en-US/docs/Web/API/HTMLMediaElement/error
        }
    });
});


    


    I see in the console log :

    


    loadstart, {"isTrusted":true}
progress, {"isTrusted":true}
play, {"isTrusted":true}
waiting, {"isTrusted":true}
error, {"isTrusted":true}
video.error, {}


    


    I don't know how to find more details about the error.

    


    Note that even though Windows Chrome successfully plays the video, it too shows warnings in the console log :

    


    {"type":"mediaError","details":"fragParsingError","fatal":false,"reason":"TS packet did not start with 0x47","frag":{"...
{"type":"mediaError","details":"fragParsingError","fatal":false,"reason":"no audio/video samples found","frag":{...


    


    Where is my problem ?