Recherche avancée

Médias (3)

Mot : - Tags -/pdf

Autres articles (73)

  • Ajouter des informations spécifiques aux utilisateurs et autres modifications de comportement liées aux auteurs

    12 avril 2011, par

    La manière la plus simple d’ajouter des informations aux auteurs est d’installer le plugin Inscription3. Il permet également de modifier certains comportements liés aux utilisateurs (référez-vous à sa documentation pour plus d’informations).
    Il est également possible d’ajouter des champs aux auteurs en installant les plugins champs extras 2 et Interface pour champs extras.

  • Les autorisations surchargées par les plugins

    27 avril 2010, par

    Mediaspip core
    autoriser_auteur_modifier() afin que les visiteurs soient capables de modifier leurs informations sur la page d’auteurs

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

Sur d’autres sites (12604)

  • Approaches To Modifying Game Resource Files

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

    I have been assisting The Translator in the translation of another mid-1990s adventure game. This one isn’t quite as multimedia-heavy as the last title, and the challenges are a bit different. I wanted to compose this post in order to describe my thought process and mental model in approaching this problem. Hopefully, this will help some others understand my approach since what I’m doing here often appears as magic to some of my correspondents.

    High Level Model
    At the highest level, it is valuable to understand the code and the data at play. The code is the game’s engine and the data refers to the collection of resources that comprise the game’s graphics, sound, text, and other assets.


    High-level game engine model
    Simplistic high-level game engine model

    Ideally, we want to change the data in such a way that the original game engine adopts it as its own because it has the same format as the original data. It is very undesirable to have to modify the binary engine executable in any way.

    Modifying The Game Data Directly
    How to modify the data ? If we modify the text strings for the sake of language translation, one approach might be to search for strings within the game data files and change them directly. This model assumes that the text strings are stored in a plain, uncompressed format. Some games might store these strings in a text format which can be easily edited with any text editor. Other games will store them as binary data.

    In the latter situation, a game hacker can scan through data files with utilities like Unix ‘strings’ to find the resources with the desired strings. Then, use a hex editor to edit the strings directly. For example, change “Original String”…

    0098F800   00 00 00 00  00 00 00 4F  72 69 67 69  6E 61 6C 20  .......Original 
    0098F810   53 74 72 69  6E 67 00 00  00 00 00 00  00 00 00 00  String..........
    

    …to “Short String” and pad the difference in string lengths using spaces (0x20) :

    0098F800   00 00 00 00  00 00 00 53  68 6F 72 74  20 53 74 72  .......Short Str
    0098F810   69 6E 67 20  20 20 00 00  00 00 00 00  00 00 00 00  ing   ..........
    

    This has some obvious problems. First, translated strings need to be of equal our smaller length compared to the original. What if we want to encode “Much Longer String” ?

    0098F800   00 00 00 00  00 00 00 4D  75 63 68 20  4C 6F 6E 67  .......Much Long
    0098F810   65 72 20 53  74 72 00 00  00 00 00 00  00 00 00 00  er Str..........
    

    It won’t fit. The second problem pertains to character set limitations. If the font in use was only designed for ASCII, it’s going to be inadequate for expressing nearly any other language.

    So a better approach is needed.

    Understanding The Data Structures
    An alternative to the approach outlined above is to understand the game’s resources so they can be modified at a deeper level. Here’s a model to motivate this investigation :


    Model of the game resource archive model
    Model of the game resource archive format

    This is a very common layout for such formats : there is a file header, a sequence of resource blocks, and a trailing index which describes the locations and types of the foregoing blocks.

    What use is understanding the data structures ? In doing so, it becomes possible to write new utilities that disassemble the data into individual pieces, modify the necessary pieces, and then reassemble them into a form that the original game engine likes.

    It’s important to take a careful, experimental approach to this since mistakes can be ruthlessly difficult to debug (unless you relish the thought of debugging the control flow through an opaque DOS executable). Thus, the very first goal in all of this is to create a program that can disassemble and reassemble the resource, thus creating an identical resource file. This diagram illustrates this complex initial process :


    Rewriting the game resource file
    Rewriting the game resource file

    So, yeah, this is one of the most complicated “copy file” operations that I can possibly code. But it forms an important basis, since the next step is to carefully replace one piece at a time.


    Modifying a specific game resource
    Modifying a specific game resource

    This diagram shows a simplistic model of a resource block that contains a series of message strings. The header contains pointers to each of the strings within the block. Instead of copying this particular resource block directly to the new file, a proposed modification utility will intercept it and rewrite the entire thing, writing new strings of arbitrary length and creating an adjusted header which will correctly point to the start of each new string. Thus, translated strings can be longer than the original strings.

    Further Work
    Exploiting this same approach, we can intercept and modify other game resources including fonts, images, and anything else that might need to be translated. I will explore specific examples in a later blog post.

    Followup

    The post Approaches To Modifying Game Resource Files first appeared on Breaking Eggs And Making Omelettes.

  • How to transcode MP3 files in django by using FFMPEG, Celery and RabbitMQ ?

    12 janvier 2017, par Srinivas 25

    I am trying to transcode user uploaded MP3 audio files into ogg, ac3 wav or other formats by using django, celery, rabbitMQ and FFMPEG. But i am getting the error with [WinError 10042] An unknown, invalid, or unsupported option or level was specified in a getsockopt or setsockopt call

    OS-Window 10-64bit
    Python 3.0
    Django - 1.10

    here is the code I followed :

    models.py
    import uuid
    from django.db import models

      # Create your models here.

       def unique_file_path(instance, filename):
       new_file_name = uuid.uuid4()
       return str(new_file_name)

       class AudioFile(models.Model):
       name = models.CharField(max_length=100, blank=True)
       mp3_file = models.FileField(upload_to=unique_file_path)
       ogg_file = models.FileField(blank=True, upload_to=unique_file_path)
       wav_file = models.FileField(blank=True, upload_to=unique_file_path)
       ac3_file = models.FileField(blank=True, upload_to=unique_file_path)

       def __str__(self):
           return self.name

       views.py
       from django.shortcuts import render

       # Create your views here.

       from django.views.generic.edit import FormView
       from django.http import HttpResponseRedirect
       from django.core.urlresolvers import reverse

       from django.views.generic import FormView
       from audio_transcoder.taskapp.tasks import transcode_mp3

       from .forms import AudioFileFrom
       from .models import AudioFile

       class UploadAudioFileView(FormView):
       template_name = 'upload/upload.html'
       form_class = AudioFileFrom


       def form_valid(self, form):
           audio_file = AudioFile(
               name=self.get_form_kwargs().get('data')['name'],
               mp3_file=self.get_form_kwargs().get('files')['mp3_file']
           )
           audio_file.save()
           transcode_mp3.delay(audio_file.id)

           return HttpResponseRedirect(self.get_success_url())

       def get_success_url(self):
           return reverse('/')


       tasks.py
       import os
       import os.path
       import subprocess

       from audio_transcoder.taskapp.celery import app




       from celery import Celery

       app = Celery('fftest',
                broker='amqp://guest@localhost//',
                include=['taskapp.tasks'])

       if __name__ == '__main__':
       app.start()

       from audio_transcoder.models import AudioFile
       import fftest.settings as settings

       @app.task
       def transcode_mp3(mp3_id):
       audio_file = AudioFile.objects.get(id=mp3_id)
       input_file_path = audio_file.mp3_file.path
       filename = os.path.basename(input_file_path)

       ogg_output_file_name = os.path.join('transcoded', '{}.ogg'.format(filename))
       ogg_output_file_path = os.path.join(settings.MEDIA_ROOT, ogg_`enter code    
       here`output_file_name)
       enter code here
       ac3_output_file_name = os.path.join('transcoded', '{}.ac3'.format(filename))
       ac3_output_file_path = os.path.join(settings.MEDIA_ROOT,  
       ac3_output_file_name)

       wav_output_file_name = os.path.join('transcoded', '{}.wav'.format(filename))
       wav_output_file_path = os.path.join(settings.MEDIA_ROOT,
       wav_output_file_name)

       if not os.path.isdir(os.path.dirname(ogg_output_file_path)):
           os.makedirs(os.path.dirname(ogg_output_file_path))

       subprocess.call([
               settings.FFMPEG_PATH,
               '-i',
               input_file_path,
               ogg_output_file_path,
               ac3_output_file_path,
               wav_output_file_path
           ]
       )

       audio_file.ogg_file = ogg_output_file_name
       audio_file.ac3_file = ac3_output_file_name
       audio_file.wav_file = wav_output_file_name
       audio_file.save()

    Not sure where the mistake is happening. While uploading video it is showing below :

    OperationalError at /new/
    [WinError 10042] An unknown, invalid, or unsupported option or level was specified in a getsockopt or setsockopt call
    Request Method: POST
    Request URL:  http://127.0.0.1:8000/new/
    Django Version: 1.10.4
    Exception Type: OperationalError`enter code here`
    Exception Value:  
    [WinError 10042] An unknown, invalid, or unsupported option or level was specified in a getsockopt or setsockopt call
    Exception Location: C:\Users\RAMa2r3e4s5h6\fftest\lib\site-packages\amqp\transport.py in _set_socket_options, line 204
  • saving ffmpeg output in a file field in django using tempfiles

    27 janvier 2017, par StarLord

    I am trying to extract audio from video when uploaded, and store it in a different model.

    this is the task code :

    def set_metadata(input_file, video_id):
       """
       Takes the file path and video id, sets the metadata and audio
       :param input_file: file url or file path
       :param video_id: video id of the file
       :return: True
       """
       # extract metadata
       command = [FFPROBE_BIN,
                  '-v', 'quiet',
                  '-print_format', 'json',
                  '-show_format',
                  '-show_streams',
                  '-select_streams', 'v:0',
                  input_file]
       output = sp.check_output(command)
       output = output.decode('utf-8')
       metadata_output = json.loads(output)
       video_instance = Video.objects.get(pk=video_id)
       stream = metadata_output['streams'][0]
       tot_frames_junk = int(stream['avg_frame_rate'].split("/")[0])
       tot_time_junk = int(stream['avg_frame_rate'].split("/")[1])
       # update the video model with newly acquired metadata
       video_instance.width = stream['width']
       video_instance.height = stream['height']
       video_instance.frame_rate = tot_frames_junk/tot_time_junk
       video_instance.duration = stream['duration']
       video_instance.total_frames = stream['nb_frames']
       video_instance.video_codec = stream['codec_name']
       video_instance.save()

       # extract audio
       tmpfile = temp.NamedTemporaryFile(suffix='.mp2')
       command = ['ffmpeg',
                  '-y',
                  '-i', input_file,
                  '-loglevel', 'quiet',
                  '-acodec', 'copy',
                  tmpfile.name]
       sp.check_output(command)
       audio_obj = Audio.objects.create(title='awesome', audio=tmpfile)
       audio_obj.save()

    I am passing video object id and the file path to the method. The file path is a url from azure storage.

    The part where I am processing for metadata, it works and the video object gets updated. But the audio model is not created.

    It throws this error :

    AttributeError("'_io.BufferedRandom' object has no attribute '_committed'",)

    at command :

    audio_obj = Audio.objects.create(title='awesome', audio=tmpfile)

    What am I doing wrong with the temp file.