Recherche avancée

Médias (0)

Mot : - Tags -/formulaire

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

Autres articles (78)

  • List of compatible distributions

    26 avril 2011, par

    The table below is the list of Linux distributions compatible with the automated installation script of MediaSPIP. Distribution nameVersion nameVersion number Debian Squeeze 6.x.x Debian Weezy 7.x.x Debian Jessie 8.x.x Ubuntu The Precise Pangolin 12.04 LTS Ubuntu The Trusty Tahr 14.04
    If you want to help us improve this list, you can provide us access to a machine whose distribution is not mentioned above or send the necessary fixes to add (...)

  • Le profil des utilisateurs

    12 avril 2011, par

    Chaque utilisateur dispose d’une page de profil lui permettant de modifier ses informations personnelle. Dans le menu de haut de page par défaut, un élément de menu est automatiquement créé à l’initialisation de MediaSPIP, visible uniquement si le visiteur est identifié sur le site.
    L’utilisateur a accès à la modification de profil depuis sa page auteur, un lien dans la navigation "Modifier votre profil" est (...)

  • Gestion des droits de création et d’édition des objets

    8 février 2011, par

    Par défaut, beaucoup de fonctionnalités sont limitées aux administrateurs mais restent configurables indépendamment pour modifier leur statut minimal d’utilisation notamment : la rédaction de contenus sur le site modifiables dans la gestion des templates de formulaires ; l’ajout de notes aux articles ; l’ajout de légendes et d’annotations sur les images ;

Sur d’autres sites (8672)

  • Running command Subprocess python failed but the same exact command runs well in Terminal

    15 juillet 2023, par will

    As the title says : weird problem. I've been struggling to make this work for a whole day but to no avail. Any help would be deeply appreciated.

    


    # I've tried every one of the below path but still errors: Fontconfig error: Cannot load default config file: No such file: (null)

FONT_LOC = r'C\\:/Users/acer/AppData/Local/Microsoft/Windows/Fonts/jf-openhuninn-1.1.ttf'
FONT_LOC = 'C:/Users/acer/AppData/Local/Microsoft/Windows/Fonts/jf-openhuninn-1.1.ttf'
FONT_LOC = 'C://Users/acer/AppData/Local/Microsoft/Windows/Fonts/jf-openhuninn-1.1.ttf'


duration = '30
subtitle='abc'
comd = [
            "ffmpeg",
            "-f", "lavfi",
            "-i", "color=c=black:s=1280x720:d={duration}".format(duration=duration),
            "-vf", f'''drawtext=fontfile="{FONT_LOC}":text='{subtitle}':fontcolor=white:fontsize=24:x=(w-text_w)/2:y=(h-text_h)/2''',
            "-c:v", "libx264",
            "-t", duration,
            "-pix_fmt", "yuv420p",
            output_file+'.mp4'
            ]
print(' '.join(comd))
subprocess.run(comd, check=True, capture_output=True, text=True) # Failed


# The below command runs successfully in the terminal.
# ffmpeg -f lavfi -i color=c=black:s=1280x720:d=2.352000 -vf drawtext=fontfile="C\\://Users/acer/AppData/Local/Microsoft/Windows/Fonts/jf-openhuninn-1.1.ttf":text='abc':fontcolor=white:fontsize=24:x=(w-text_w)/2:y=(h-text_h)/2 -c:v libx264 -t 2.352000 -pix_fmt yuv420p output_Test-0004.mp3.mp4



    


    I expect the subprocess.run() would produce the same result. I've tried all versions of paths (different kind of escaping) but none of the aforementioned one worked.

    


  • How to install ffmpeg for generating thumbnail images ? I got no package ffmpeg available while run on Linux(centos) terminal

    16 mai 2015, par Intrepid Uliyar

    How to install ffmpeg for generating thumbnail images ? I got "no package ffmpeg available" while run on Linux(centos) terminal by using "yum ffmpeg install" command.

    I need to install ffmpeg for generating thumbnail images, it’s working fine in localhost(Windows), but doesn’t work in Linux (I don’t know server platform). I have refer some website. In that they put like exe are not execute in linux server, we need to install ffmpeg programmatically. Can anyone give me suggestion. I have refer some website, but that wasn’t useful.

    My code :

    $video = "../../".$down_path;
       $rand=mt_rand(111111,999999);
       //where to save the image
       $image1 = "../../completed_project/thumb/".$rand.'ss.jpg';
       $image2 = "../../completed_project/thumb/".$rand.'uu.jpg';
       $image3 = "../../completed_project/thumb/".$rand.'rr.jpg';

       $thumb_image1 = "completed_project/thumb/".$rand.'ss.jpg';
       $thumb_image2 = "completed_project/thumb/".$rand.'uu.jpg';
       $thumb_image3 = "completed_project/thumb/".$rand.'rr.jpg';

       //time to take screenshot at
       $interval1 = 2;
       $interval2 = 4;
       $interval3 = 5;
       //screenshot size
       $size = '320x240';

       //ffmpeg command
       $cmd1 = "$ffmpeg -i $video -deinterlace -an -ss $interval1 -f mjpeg -t 1 -r 1 -y -s $size $image1 2>&1";
       $cmd2 = "$ffmpeg -i $video -deinterlace -an -ss $interval2 -f mjpeg -t 1 -r 1 -y -s $size $image2 2>&1";  
       $cmd3 = "$ffmpeg -i $video -deinterlace -an -ss $interval3 -f mjpeg -t 1 -r 1 -y -s $size $image3 2>&1";  
       $return = `$cmd1`.`$cmd2`.`$cmd3`;
       print_r($cmd1);

    I’ve got this output :

    ffmpeg.exe -i ../../completed_project/606560114793SK_PROMO-45s.mp4 -deinterlace -an -ss 2 -f mjpeg -t 1 -r 1 -y -s 320x240 ../../completed_project/thumb/362796ss.jpg 2>&1
  • How do terminal pipes in Python differ from those in Rust ?

    5 octobre 2022, par rust_convert

    To work on learning Rust (in a Tauri project) I am converting a Python 2 program that uses ffmpeg to create a custom video format from a GUI. The video portion converts successfully, but I am unable to get the audio to work. With the debugging I have done for the past few days, it looks like I am not able to read in the audio data in Rust correctly from the terminal pipe - what is working to read in the video data is not working for the audio. I have tried reading in the audio data as a string and then converting it to bytes but then the byte array appears empty. I have been researching the 'Pipe'-ing of data from the rust documentation and python documentation and am unsure how the Rust pipe could be empty or incorrect if it's working for the video.

    


    From this python article and this rust stack overflow exchange, it looks like the python stdout pipe is equivalent to the rust stdin pipe ?

    


    The python code snippet for video and audio conversion :

    


    output=open(self.outputFile, 'wb')
devnull = open(os.devnull, 'wb')

vidcommand = [ FFMPEG_BIN,
            '-i', self.inputFile,
            '-f', 'image2pipe',
            '-r', '%d' % (self.outputFrameRate),
            '-vf', scaleCommand,
            '-vcodec', 'rawvideo',
            '-pix_fmt', 'bgr565be',
            '-f', 'rawvideo', '-']
        
vidPipe = '';
if os.name=='nt' :
    startupinfo = sp.STARTUPINFO()
    startupinfo.dwFlags |= sp.STARTF_USESHOWWINDOW
    vidPipe=sp.Popen(vidcommand, stdin = sp.PIPE, stdout = sp.PIPE, stderr = devnull, bufsize=self.inputVidFrameBytes*10, startupinfo=startupinfo)
else:
    vidPipe=sp.Popen(vidcommand, stdin = sp.PIPE, stdout = sp.PIPE, stderr = devnull, bufsize=self.inputVidFrameBytes*10)

vidFrame = vidPipe.stdout.read(self.inputVidFrameBytes)

audioCommand = [ FFMPEG_BIN,
    '-i', self.inputFile,
    '-f', 's16le',
    '-acodec', 'pcm_s16le',
    '-ar', '%d' % (self.outputAudioSampleRate),
    '-ac', '1',
    '-']

audioPipe=''
if (self.audioEnable.get() == 1):
    if os.name=='nt' :
        startupinfo = sp.STARTUPINFO()
        startupinfo.dwFlags |= sp.STARTF_USESHOWWINDOW
        audioPipe = sp.Popen(audioCommand, stdin = sp.PIPE, stdout=sp.PIPE, stderr = devnull, bufsize=self.audioFrameBytes*10, startupinfo=startupinfo)
    else:
        audioPipe = sp.Popen(audioCommand, stdin = sp.PIPE, stdout=sp.PIPE, stderr = devnull, bufsize=self.audioFrameBytes*10)

    audioFrame = audioPipe.stdout.read(self.audioFrameBytes) 

currentFrame=0;

while len(vidFrame)==self.inputVidFrameBytes:
    currentFrame+=1
    if(currentFrame%30==0):
        self.progressBarVar.set(100.0*(currentFrame*1.0)/self.totalFrames)
    if (self.videoBitDepth.get() == 16):
        output.write(vidFrame)
    else:
        b16VidFrame=bytearray(vidFrame)
        b8VidFrame=[]
        for p in range(self.outputVidFrameBytes):
            b8VidFrame.append(((b16VidFrame[(p*2)+0]>>0)&0xE0)|((b16VidFrame[(p*2)+0]<<2)&0x1C)|((b16VidFrame[(p*2)+1]>>3)&0x03))
        output.write(bytearray(b8VidFrame))

    vidFrame = vidPipe.stdout.read(self.inputVidFrameBytes) # Read where vidframe is to match up with audio frame and output?
    if (self.audioEnable.get() == 1):


        if len(audioFrame)==self.audioFrameBytes:
            audioData=bytearray(audioFrame) 

            for j in range(int(round(self.audioFrameBytes/2))):
                sample = ((audioData[(j*2)+1]<<8) | audioData[j*2]) + 0x8000
                sample = (sample>>(16-self.outputAudioSampleBitDepth)) & (0x0000FFFF>>(16-self.outputAudioSampleBitDepth))

                audioData[j*2] = sample & 0xFF
                audioData[(j*2)+1] = sample>>8

            output.write(audioData)
            audioFrame = audioPipe.stdout.read(self.audioFrameBytes)

        else:
            emptySamples=[]
            for samples in range(int(round(self.audioFrameBytes/2))):
                emptySamples.append(0x00)
                emptySamples.append(0x00)
            output.write(bytearray(emptySamples))

self.progressBarVar.set(100.0)

vidPipe.terminate()
vidPipe.stdout.close()
vidPipe.wait()

if (self.audioEnable.get() == 1):
    audioPipe.terminate()
    audioPipe.stdout.close()
    audioPipe.wait()

output.close()


    


    The Rust snippet that should accomplish the same goals :

    


    let output_file = OpenOptions::new()
    .create(true)
    .truncate(true)
    .write(true)
    .open(&output_path)
    .unwrap();
let mut writer = BufWriter::with_capacity(
    options.video_frame_bytes.max(options.audio_frame_bytes),
    output_file,
);
let ffmpeg_path = sidecar_path("ffmpeg");
#[cfg(debug_assertions)]
let timer = Instant::now();

let mut video_cmd = Command::new(&ffmpeg_path);
#[rustfmt::skip]
video_cmd.args([
    "-i", options.path,
    "-f", "image2pipe",
    "-r", options.frame_rate,
    "-vf", options.scale,
    "-vcodec", "rawvideo",
    "-pix_fmt", "bgr565be",
    "-f", "rawvideo",
    "-",
])
.stdin(Stdio::null())
.stdout(Stdio::piped())
.stderr(Stdio::null());

// windows creation flag CREATE_NO_WINDOW: stops the process from creating a CMD window
// https://docs.microsoft.com/en-us/windows/win32/procthread/process-creation-flags
#[cfg(windows)]
video_cmd.creation_flags(0x08000000);

let mut video_child = video_cmd.spawn().unwrap();
let mut video_stdout = video_child.stdout.take().unwrap();
let mut video_frame = vec![0; options.video_frame_bytes];

let mut audio_cmd = Command::new(&ffmpeg_path);
#[rustfmt::skip]
audio_cmd.args([
    "-i", options.path,
    "-f", "s16le",
    "-acodec", "pcm_s16le",
    "-ar", options.sample_rate,
    "-ac", "1",
    "-",
])
.stdin(Stdio::null())
.stdout(Stdio::piped())
.stderr(Stdio::null());

#[cfg(windows)]
audio_cmd.creation_flags(0x08000000);

let mut audio_child = audio_cmd.spawn().unwrap();
let mut audio_stdout = audio_child.stdout.take().unwrap();
let mut audio_frame = vec![0; options.audio_frame_bytes];

while video_stdout.read_exact(&mut video_frame).is_ok() {
    writer.write_all(&video_frame).unwrap();

    if audio_stdout.read_to_end(&mut audio_frame).is_ok() {
        if audio_frame.len() == options.audio_frame_bytes {
            for i in 0..options.audio_frame_bytes / 2 {
                let temp_sample = ((u32::from(audio_frame[(i * 2) + 1]) << 8)
                    | u32::from(audio_frame[i * 2]))
                    + 0x8000;
                let sample = (temp_sample >> (16 - 10)) & (0x0000FFFF >> (16 - 10));

                audio_frame[i * 2] = (sample & 0xFF) as u8;
                audio_frame[(i * 2) + 1] = (sample >> 8) as u8;
            }
        } else {
            audio_frame.fill(0x00);
        }
    }
    writer.write_all(&audio_frame).unwrap();
}


video_child.wait().unwrap();
audio_child.wait().unwrap();

#[cfg(debug_assertions)]
{
    let elapsed = timer.elapsed();
    dbg!(elapsed);
}

writer.flush().unwrap();


    


    I have looked at the hex data of the files using HxD - regardless of how I alter the Rust program, I am unable to get data different from what is previewed in the attached image - so the audio pipe is incorrectly interfaced. I included a screenshot of the hex data from the working python program that converts the video and audio correctly.

    


    HxD Python program hex output :

    


    HxD Python program hex output

    


    HxD Rust program hex output :

    


    HxD Rust program hex output