Recherche avancée

Médias (1)

Mot : - Tags -/copyleft

Autres articles (106)

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

  • Participer à sa traduction

    10 avril 2011

    Vous pouvez nous aider à améliorer les locutions utilisées dans le logiciel ou à traduire celui-ci dans n’importe qu’elle nouvelle langue permettant sa diffusion à de nouvelles communautés linguistiques.
    Pour ce faire, on utilise l’interface de traduction de SPIP où l’ensemble des modules de langue de MediaSPIP sont à disposition. ll vous suffit de vous inscrire sur la liste de discussion des traducteurs pour demander plus d’informations.
    Actuellement MediaSPIP n’est disponible qu’en français et (...)

  • Supporting all media types

    13 avril 2011, par

    Unlike most software and media-sharing platforms, MediaSPIP aims to manage as many different media types as possible. The following are just a few examples from an ever-expanding list of supported formats : images : png, gif, jpg, bmp and more audio : MP3, Ogg, Wav and more video : AVI, MP4, OGV, mpg, mov, wmv and more text, code and other data : OpenOffice, Microsoft Office (Word, PowerPoint, Excel), web (html, CSS), LaTeX, Google Earth and (...)

Sur d’autres sites (8006)

  • Unmapping memory-mapped images that are created during processing

    23 avril 2013, par user2309283

    I have a pretty big issue, although I only have the symptoms, and a theory on the cause.

    I have a C++ application under Windows 7x64 that uses system calls to FFMPEG 0.7.13 to extract frames from videos. When running, the parent application maintains a nice, predicable memory footprint in memory profilers (task manager, RAMMap) of about 2MB. I can see the individual calls to FFMPEG also come and go without incident. The trouble is, after about 100 calls to FFMPEG, and 70,000+ PNGs created (no one directory has more than 1500 pngs), the Windows memory page size raises gradually from about 2.5GB to over 7.0GB, and the system is brought to its knees. The sum of the processes for all users is no where near the reported Memory Page amount.

    I thought it might be Windows Search indexing related, so I turned off the indexing for the output directories in question using SetFileAttributes() and FILE_ATTRIBUTE_NOT_CONTENT_INDEXED, and while it seems to be working as advertised, it does not seem to combat the issue at hand. My current running theory is that all of these extracted PNGs are either fully or partially memory mapped, by FFMPEG or something else. I can also see the output PNGs under the RAMMap Physical Pages tab as standby mapped files.

    Question :
    - Is there enough information here to possibly diagnose the exact problem ?
    - Do I have a way to combat this issue ?

    Thanks in advance...

  • Translating Return To Ringworld

    17 août 2016, par Multimedia Mike — Game Hacking

    As indicated in my previous post, the Translator has expressed interest in applying his hobby towards another DOS adventure game from the mid 1990s : Return to Ringworld (henceforth R2RW) by Tsunami Media. This represents significantly more work than the previous outing, Phantasmagoria.


    Return to Ringworld Title Screen
    Return to Ringworld Title Screen

    I have been largely successful thus far in crafting translation tools. I have pushed the fruits of these labors to a Github repository named improved-spoon (named using Github’s random name generator because I wanted something more interesting than ‘game-hacking-tools’).

    Further, I have recorded everything I have learned about the game’s resource format (named RLB) at the XentaxWiki.

    New Challenges
    The previous project mostly involved scribbling subtitle text on an endless series of video files by leveraging a separate software library which took care of rendering fonts. In contrast, R2RW has at least 30k words of English text contained in various blocks which require translation. Further, the game encodes its own fonts (9 of them) which stubbornly refuse to be useful for rendering text in nearly any other language.

    Thus, the immediate 2 challenges are :

    1. Translating volumes of text to Spanish
    2. Expanding the fonts to represent Spanish characters

    Normally, “figuring out the file format data structures involved” is on the list as well. Thankfully, understanding the formats is not a huge challenge since the folks at the ScummVM project already did all the heavy lifting of reverse engineering the file formats.

    The Pitch
    Here was the plan :

    • Create a tool that can dump out the interesting data from the game’s master resource file.
    • Create a tool that can perform the elaborate file copy described in the previous post. The new file should be bit for bit compatible with the original file.
    • Modify the rewriting tool to repack some modified strings into the new resource file.
    • Unpack the fonts and figure out a way to add new characters.
    • Repack the new fonts into the resource file.
    • Repack message strings with Spanish characters.

    Showing The Work : Modifying Strings
    First, I created the tool to unpack blocks of message string resources. I elected to dump the strings to disk as JSON data since it’s easy to write and read JSON using Python, and it’s quick to check if any mistakes have crept in.

    The next step is to find a string to focus on. So I started the game and looked for the first string I could trigger :


    Return to Ringworld: Original text

    This shows up in the JSON string dump as :

      
        "Spanish" : " !0205Your quarters on the Lance of Truth are spartan, in accord with your mercenary lifestyle.",
        "English" : " !0205Your quarters on the Lance of Truth are spartan, in accord with your mercenary lifestyle."
      ,
    

    As you can see, many of the strings are encoded with an ID key as part of the string which should probably be left unmodified. I changed the Spanish string :

      
        "Spanish" : " !0205Hey, is this thing on ?",
        "English" : " !0205Your quarters on the Lance of Truth are spartan, in accord with your mercenary lifestyle."
      ,
    

    And then I wrote the repacking tool to substitute this message block for the original one. Look ! The engine liked it !


    Return to Ringworld: Modified text

    Little steps, little steps.

    Showing The Work : Modifying Fonts
    The next little step is to find a place to put the new characters. First, a problem definition : The immediate goal is to translate the game into Spanish. The current fonts encoded in the game resource only support 128 characters, corresponding to 7-bit ASCII. In order to properly express Spanish, 16 new characters are required : á, é, í, ó, ú, ü, ñ (each in upper and lower case for a total of 14 characters) as well as the inverted punctuation symbols : ¿, ¡.

    Again, ScummVM already documents (via code) the font coding format. So I quickly determined that each of the 9 fonts is comprised of 128 individual bitmaps with either 1 or 2 bits per pixel. I wrote a tool to unpack each character into an individual portable grey map (PGM) image. These can be edited with graphics editors or with text editors since they are just text files.

    Where to put the 16 new Spanish characters ? ASCII characters 1-31 are non-printable, so my first theory was that these characters would be empty and could be repurposed. However, after dumping and inspecting, I learned that they represent the same set of characters as seen in DOS Code Page 437. So that’s a no-go (so I assumed ; I didn’t check if any existing strings leveraged those characters).

    My next plan was hope that I could extend the font beyond index 127 and use positions 128-143. This worked superbly. This is the new example string :

      
        "Spanish" : " !0205¿Ves esto ? ¡La puntuacion se hace girar !",
        "English" : " !0205Your quarters on the Lance of Truth are spartan, in accord with your mercenary lifestyle."
      ,
    

    Fortunately, JSON understands UTF-8 and after mapping the 16 necessary characters down to the numeric range of 128-143, I repacked the new fonts and the new string :


    Return to Ringworld: Espanol
    Translation : “See this ? The punctuation is rotated !”

    Another victory. Notice that there are no diacritics in this string. None are required for this translation (according to Google Translate). But adding the diacritics to the 14 characters isn’t my department. My tool does help by prepopulating [aeiounAEIOUN] into the right positions to make editing easier for the Translator. But the tool does make the effort to rotate the punctuation since that is easy to automate.

    Next Steps and Residual Weirdness
    There is another method for storing ASCII text inside the R2RW resource called strip resources. These store conversation scripts. There are plenty of fields in the data structures that I don’t fully understand. So, following the lessons I learned from my previous translation outing, I was determined to modify as little as possible. This means copying over most of the original data structures intact, but changing the field representing the relative offset that points to the corresponding string. This works well since the strings are invariably stored NULL-terminated in a concatenated manner.

    I wanted to document for the record that the format that R2RW uses has some weirdness in they way it handles residual bytes in a resource. The variant of the resource format that R2RW uses requires every block to be aligned on a 16-byte boundary. If there is space between the logical end of the resource and the start of the next resource, there are random bytes in that space. This leads me to believe that these bytes were originally recorded from stale/uninitialized memory. This frustrates me because when I write the initial file copy tool which unpacks and repacks each block, I want the new file to be identical to the original. However, these apparent nonsense bytes at the end thwart that effort.

    But leaving those bytes as 0 produces an acceptable resource file.

    Text On Static Images
    There is one last resource type we are working on translating. There are various bits of text that are rendered as images. For example, from the intro :


    Return to Ringworld: Static text

    It’s possible to locate and extract the exact image that is overlaid on this scene, though without the colors :


    Original static text

    The palettes are stored in a separate resource type. So it seems the challenge is to figure out the palette in use for these frames and render a transparent image that uses the same palette, then repack the new text-image into the new resource file.

    The post Translating Return To Ringworld first appeared on Breaking Eggs And Making Omelettes.

  • Trying to convert code to be compatible with macOS by not using the .exe version of FFmpeg and FFmprobe. Cant open the .mp4 file when i go to run code

    9 juillet 2024, par Bruno Hawkins

    I am attempting to edit some code in python for extracting frames from a video (using parallel processing to make it faster) a friend created that works on windows, so that it can be used on macOS. However, i am running into some issues and i am not sure what the problem is.

    


    Essentially, when i go to run the frame extractor and try to select a video in the formats specified, it wont let me select it.

    


    i have commented my code best i can. i am an amateur programmer so apologies if it is straightforward.

    


    import os
import subprocess
import multiprocessing
import tkinter as tk
from tkinter import ttk, filedialog, messagebox

def extract_frames(video_path, output_folder, fps, start_time, duration, process_number):
    video_name = os.path.splitext(os.path.basename(video_path))[0]
    part_output_folder = os.path.join(output_folder, f"part_{process_number}")
    if not os.path.exists(part_output_folder):
        os.makedirs(part_output_folder)

    # Using 'ffmpeg' instead of 'ffmpeg.exe' for macOS compatibility
    ffmpeg_command = [
        'ffmpeg', '-ss', str(start_time), '-t', str(duration), '-i', video_path, '-vf', f'fps={fps}',
        os.path.join(part_output_folder, f'{video_name}_frame_%07d.png')
    ]

    print(f"Running FFmpeg command: {' '.join(ffmpeg_command)}")

    try:
        process = subprocess.run(ffmpeg_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
        if process.returncode != 0:
            print(f"Cannot process the file {video_path}: {process.stderr.decode('utf-8')}")
            return part_output_folder, 0
    except Exception as e:
        print(f"Failed to run FFmpeg command: {str(e)}")
        return part_output_folder, 0

    frame_count = len([f for f in os.listdir(part_output_folder) if f.endswith('.png')])
    return part_output_folder, frame_count

def worker_function(queue, video_path, output_folder, fps, start_time, duration, process_number):
    result = extract_frames(video_path, output_folder, fps, start_time, duration, process_number)
    queue.put(result)

def parallel_frame_extraction(video_path, output_folder, fps, num_processes):
    # Use 'ffprobe' instead of 'ffprobe.exe' for macOS compatibility
    ffprobe_command = [
        'ffprobe', '-v', 'error', '-select_streams', 'v:0', '-show_entries', 'format=duration', '-of',
        'default=noprint_wrappers=1:nokey=1', video_path
    ]

    try:
        result = subprocess.run(ffprobe_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
        duration = float(result.stdout.strip())
    except Exception as e:
        messagebox.showerror("Error", f"Failed to get video duration: {str(e)}")
        return

    chunk_duration = duration / num_processes
    processes = []
    manager = multiprocessing.Manager()
    queue = manager.Queue()

    if not os.path.exists(output_folder):
        os.makedirs(output_folder)

    for i in range(num_processes):
        start_time = i * chunk_duration
        p = multiprocessing.Process(target=worker_function,
                                    args=(queue, video_path, output_folder, fps, start_time, chunk_duration, i))
        p.start()
        processes.append(p)

    for p in processes:
        p.join()

    global_frame_offset = 0
    while not queue.empty():
        part_output_folder, frame_count = queue.get()
        frame_files = sorted([f for f in os.listdir(part_output_folder) if f.endswith('.png')])
        for i, frame_file in enumerate(frame_files):
            new_name = os.path.join(output_folder,
                                    f'{os.path.basename(video_path)}_frame_{global_frame_offset + i:07d}.png')
            os.rename(os.path.join(part_output_folder, frame_file), new_name)
        global_frame_offset += frame_count
        os.rmdir(part_output_folder)

    messagebox.showinfo("Complete",
                        f"Frame extraction completed for {video_path}. Total frames extracted: {global_frame_offset}")

def start_frame_extraction():
    video_path = filedialog.askopenfilename(filetypes=[("Video files", "*.mp4;*.avi;*.mkv")])
    if not video_path:
        return

    output_folder = output_folder_var.get()
    if not output_folder:
        return

    fps = int(fps_var.get())
    num_processes = int(num_processes_var.get())

    parallel_frame_extraction(video_path, output_folder, fps, num_processes)

if __name__ == "__main__":
    root = tk.Tk()
    root.title("Frame Extraction")

    output_folder_var = tk.StringVar()
    fps_var = tk.StringVar(value="1")
    num_processes_var = tk.StringVar(value="4")

    def browse_output_folder():
        folder_selected = filedialog.askdirectory()
        output_folder_var.set(folder_selected)

    tk.Label(root, text="Output Folder:").grid(row=0, column=0, padx=10, pady=10)
    tk.Entry(root, textvariable=output_folder_var, width=50).grid(row=0, column=1, padx=10, pady=10)
    tk.Button(root, text="Browse", command=browse_output_folder).grid(row=0, column=2, padx=10, pady=10)

    tk.Label(root, text="FPS:").grid(row=1, column=0, padx=10, pady=10)
    tk.Entry(root, textvariable=fps_var, width=10).grid(row=1, column=1, padx=10, pady=10)

    tk.Label(root, text="Number of Processes:").grid(row=2, column=0, padx=10, pady=10)
    tk.Entry(root, textvariable=num_processes_var, width=10).grid(row=2, column=1, padx=10, pady=10)

    tk.Button(root, text="Start Frame Extraction", command=start_frame_extraction).grid(row=3, column=0, columnspan=3,
                                                                                        padx=10, pady=20)

    root.mainloop()


    


    I tried changing the FFmpeg and FFmprobe path formats from

    


    ffmpeg_path = os.path.join(os.path.dirname(__file__), 'ffmpeg-7.0.1-essentials_build', 'bin', 'ffmpeg.exe')
ffprobe_path = os.path.join(os.path.dirname(__file__), 'ffmpeg-7.0.1-essentials_build', 'bin', 'ffprobe.exe')



    


    to

    


    ffmpeg_command = [
    'ffmpeg', '-ss', str(start_time), '-t', str(duration), '-i', video_path, '-vf', f'fps={fps}',
    os.path.join(part_output_folder, f'{video_name}_frame_%07d.png')
]

ffprobe_command = [
    'ffprobe', '-v', 'error', '-select_streams', 'v:0', '-show_entries', 'format=duration', '-of',
    'default=noprint_wrappers=1:nokey=1', video_path
]



    


    I found this online so im not sure if it is the correct thing to do.

    


    Thanks for any help.