Recherche avancée

Médias (91)

Autres articles (15)

  • Personnaliser les catégories

    21 juin 2013, par

    Formulaire de création d’une catégorie
    Pour ceux qui connaissent bien SPIP, une catégorie peut être assimilée à une rubrique.
    Dans le cas d’un document de type catégorie, les champs proposés par défaut sont : Texte
    On peut modifier ce formulaire dans la partie :
    Administration > Configuration des masques de formulaire.
    Dans le cas d’un document de type média, les champs non affichés par défaut sont : Descriptif rapide
    Par ailleurs, c’est dans cette partie configuration qu’on peut indiquer le (...)

  • Le plugin : Podcasts.

    14 juillet 2010, par

    Le problème du podcasting est à nouveau un problème révélateur de la normalisation des transports de données sur Internet.
    Deux formats intéressants existent : Celui développé par Apple, très axé sur l’utilisation d’iTunes dont la SPEC est ici ; Le format "Media RSS Module" qui est plus "libre" notamment soutenu par Yahoo et le logiciel Miro ;
    Types de fichiers supportés dans les flux
    Le format d’Apple n’autorise que les formats suivants dans ses flux : .mp3 audio/mpeg .m4a audio/x-m4a .mp4 (...)

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

  • Excuting ffmpeg commands using Python to locate *.png failed

    18 mai 2023, par Leo

    The following command works well if I run it in the Bash terminal.

    


    ffmpeg -framerate 25 -pattern_type glob -i 'data/*.png' -i data/download_youtube/_-91nXXjrVo_cut.wav -c:v libx264 -pix_fmt yuv420p data/download_youtube/_-91nXXjrVo_out.mp4


    


    However, If i run it using os.system() using Python.

    


    os.system(r"ffmpeg -framerate 25 -pattern_type glob -i '/data/share/VFHQ/data/extracted_cropped_face_results/_-91nXXjrVo/Clip+_-91nXXjrVo+P0+C0+F1537-1825/*.png' -i /data/share/VFHQ/data/download_youtube/_-91nXXjrVo_cut.wav -c:v libx264 -pix_fmt yuv420p /data/share/VFHQ/data/download_youtube/out.mp4")


    


    I get Unknown encoder 'libx264'

    


    If I remove the quotation mark inside the commands

    


    os.system(r"ffmpeg -framerate 25 -pattern_type glob -i /data/share/VFHQ/data/extracted_cropped_face_results/_-91nXXjrVo/Clip+_-91nXXjrVo+P0+C0+F1537-1825/*.png -i /data/share/VFHQ/data/download_youtube/_-91nXXjrVo_cut.wav -c:v libx264 -pix_fmt yuv420p /data/share/VFHQ/data/download_youtube/out.mp4")


    


    I get Option pattern_type not found.

    


    So I tried subprocess.run(command,shell=True) , I get same results as shown above.

    


    Running 'subprocess.run()' without Shell will result in the following"

    


    subprocess.run(['ffmpeg', '-framerate', '25','-pattern_type', 'glob', '-i','/data/share/VFHQ/data/extracted_cropped_face_results/_-91nXXjrVo/Clip+_-91nXXjrVo+P0+C0+F1537-1825/*.png',
                '-i','/data/share/VFHQ/data/download_youtube/_-91nXXjrVo_cut.wav','-c:v','libx264','-pix_fmt','yuv420p','/data/share/VFHQ/data/download_youtube/_-91nXXjrVo_out.mp4'])



    


    [image2 @ 0x56001a8fee00] Could find no file with path '/data/share/VFHQ/data/extracted_cropped_face_results/_-91nXXjrVo/Clip+_-91nXXjrVo+P0+C0+F1537-1825/*.png' and index in the range 0-4
/data/share/VFHQ/data/extracted_cropped_face_results/_-91nXXjrVo/Clip+_-91nXXjrVo+P0+C0+F1537-1825/*.png: No such file or directory


    



    


    With out the quotation marks on the picture directory :

    


    CompletedProcess(args=['ffmpeg', '-framerate', '25', '-pattern_type', 'glob', '-i', '/data/share/VFHQ/data/extracted_cropped_face_results/_-91nXXjrVo/Clip+_-91nXXjrVo+P0+C0+F1537-1825/*.png', '-i', '/data/share/VFHQ/data/download_youtube/_-91nXXjrVo_cut.wav', '-c:v', 'libx264', '-pix_fmt', 'yuv420p', '/data/share/VFHQ/data/download_youtube/_-91nXXjrVo_out.mp4'], returncode=1)


    


    Unknown encoder 'libx264'

    


    with quotation marks around the picture directory (also the correct way to run in the terminal) :

    


    subprocess.run(['ffmpeg', '-framerate', '25','-pattern_type', 'glob', '-i',"'/data/share/VFHQ/data/extracted_cropped_face_results/_-91nXXjrVo/Clip+_-91nXXjrVo+P0+C0+F1537-1825/*.png'",
                '-i','/data/share/VFHQ/data/download_youtube/_-91nXXjrVo_cut.wav','-c:v','libx264','-pix_fmt','yuv420p','/data/share/VFHQ/data/download_youtube/_-91nXXjrVo_out.mp4'])


    


    '/data/share/VFHQ/data/extracted_cropped_face_results/_-91nXXjrVo/Clip+_-91nXXjrVo+P0+C0+F1537-1825/*.png': No such file or directory

    



    


    It was later found out that I have 2versions of ffmpeg. One is 4.3 the other is 4.4.2
The thing is running a subprocess with quotation marks (I know it is incorrect as it has been explained) will call v4.4.2. Running it without quotation marks will call the v4.3 ffmpeg.

    


    Also from V4.3 log, it suggests Reading option '-c:v' ... matched as option 'c' (codec name) with argument 'libx264'. but in the end

    


    [wav @ 0x55eaef48b240] After avformat_find_stream_info() pos: 204878 bytes read:294990 seeks:1 frames:50
Guessed Channel Layout for Input Stream #1.0 : stereo
Input #1, wav, from '/data/share/VFHQ/data/download_youtube/_-91nXXjrVo_cut.wav':
  Metadata:
    encoder         : Lavf58.45.100
  Duration: 00:00:11.44, bitrate: 1536 kb/s
    Stream #1:0, 50, 1/48000: Audio: pcm_s16le ([1][0][0][0] / 0x0001), 48000 Hz, stereo, s16, 1536 kb/s
Successfully opened the file.
Parsing a group of options: output url /data/share/VFHQ/data/download_youtube/_-91nXXjrVo_out.mp4.
Applying option c:v (codec name) with argument libx264.
Applying option pix_fmt (set pixel format) with argument yuv420p.
Successfully parsed a group of options.
Opening an output file: /data/share/VFHQ/data/download_youtube/_-91nXXjrVo_out.mp4.
Unknown encoder 'libx264'
[AVIOContext @ 0x55eaef487fc0] Statistics: 294990 bytes read, 1 seeks


    


  • How to get frame-by-frame audio from the video in python

    7 juin 2023, par Usman Arshad

    So,first of all the description of my program is that I am viewing a video using opencv and whenever I press "p" the video paused for 5 seconds.At last I am saving that updated video in the same directory.I want to add audio to this video and whenever "p" pressed the audio must also be stopped for 5 second until next frame.

    


    import cv2

def save_frames(frames, output_filename, fps):
    # Get video information from the first frame
    height, width, _ = frames[0].shape

    # Create a VideoWriter object to save the frames
    fourcc = cv2.VideoWriter_fourcc(*'mp4v')
    output = cv2.VideoWriter(output_filename, fourcc, fps, (width, height))

    # Write each frame to the video file
    for frame in frames:
        output.write(frame)

    # Release the VideoWriter
    output.release()
    
def main():
    # Load the video
    video_path = 'input_video.mp4'
    cap = cv2.VideoCapture(video_path)


    frames = []
    fps = cap.get(cv2.CAP_PROP_FPS)

    while cap.isOpened():
        # Read the current frame
        ret, frame = cap.read()

        if not ret:
            break

        # Display the frame
        cv2.imshow('Video', frame)

        # Append the frame to the list
        frames.append(frame)
        # Wait for key press
        key = cv2.waitKey(int(1000 / fps))

        if key == ord('p'):
            # Pause the video for 5 seconds
            paused = True
            for _ in range(int(fps * 5)):
                frames.append(frame)
                cv2.waitKey(int(1000 / fps))
            paused = False

    # Release the VideoCapture
    cap.release()

    # Save the frames to a video file
    output_filename = 'output.mp4'
    save_frames(frames, output_filename, fps)

if __name__ == '__main__':
    main()


    


  • can't pipe in opencv frames to ffmpeg subprocess in python

    19 juin 2023, par Kevin

    I'm trying to capture webcam video stream using opencv and pipe raw frames into ffmpeg subprocess, apply 3d .cube lut, bring back those lut applied frames into opencv and display it using cv2.imshow.

    


    This is my code :

    


    import cv2
import subprocess as sp
import numpy as np

lut_cmd = [
            'ffmpeg', '-f', 'rawvideo', '-pixel_format', 'bgr24', '-s', '1280x720', '-framerate', '30', '-i', '-', '-an', '-vf',
            'lut3d=file=lut/luts/lut.cube', '-f', 'rawvideo', 'pipe:1'
        ]

lut_process = sp.Popen(lut_cmd, stdin=sp.PIPE, stdout=sp.PIPE)

width = 1280
height = 720

video_capture = cv2.VideoCapture(0)

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

    if not ret:
        break
 
    # Write raw video frame to input stream of ffmpeg sub-process.
    lut_process.stdin.write(frame.tobytes())
    lut_process.stdin.flush()
    print("flushed")

    # Read the processed frame from the ffmpeg subprocess
    raw_frame = lut_process.stdout.read(width * height * 3)
    print("read")
    frame = np.frombuffer(raw_frame, dtype=np.uint8).reshape(height, width, 3)

    cv2.imshow('Video', frame)

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

lut_process.terminate()
video_capture.release()

cv2.destroyAllWindows()



    


    code gets stuck at reading from ffmpeg part :
raw_frame = lut_process.stdout.read(width * height * 3)

    


    this is what i get when i run the code :

    


    flushed
Input #0, rawvideo, from 'fd:':
  Duration: N/A, start: 0.000000, bitrate: 663552 kb/s
  Stream #0:0: Video: rawvideo (BGR[24] / 0x18524742), bgr24, 1280x720, 663552 kb/s, 30 tbr, 30 tbn
Stream mapping:
  Stream #0:0 -> #0:0 (rawvideo (native) -> rawvideo (native))
Output #0, rawvideo, to 'pipe:1':
  Metadata:
    encoder         : Lavf60.3.100
  Stream #0:0: Video: rawvideo (BGR[24] / 0x18524742), bgr24(progressive), 1280x720, q=2-31, 663552 kb/s, 30 fps, 30 tbn
    Metadata:
      encoder         : Lavc60.3.100 rawvideo
frame=    0 fps=0.0 q=0.0 size=       0kB time=-577014:32:22.77 bitrate=  -0.0kbits/s speed=N/A  


    


    "read" never gets printed. ffmpeg is stuck at 0fps. cv2.imshow doesn't show up.

    


    I tried changing lut_process.stdin.write(frame.tobytes()) 
to lut_process.stdin.write(frame.tostring()), but result was same.

    


    I tried adding 3 seconds pause before first write to ffmpeg begin, thinking maybe ffmpeg was not ready to process frames, but result was same.

    


    I'm sure that my webcam is working, and I know it's video stream is 1280x720 30fps.

    


    I was successful at
Displaying webcam stream just using opencv,
set FFmpeg input directly to my webcam and get output result using stdout.read, displaying it using opencv.

    


    have no idea what should I try next.

    


    I am using macOS 12.6, openCV 4.7.0, ffmpeg 6.0, python 3.10.11, and visual studio code.

    


    Any help would be greatly appreciated.