Recherche avancée

Médias (1)

Mot : - Tags -/bug

Autres articles (111)

  • MediaSPIP version 0.1 Beta

    16 avril 2011, par

    MediaSPIP 0.1 beta est la première version de MediaSPIP décrétée comme "utilisable".
    Le fichier zip ici présent contient uniquement les sources de MediaSPIP en version standalone.
    Pour avoir une installation fonctionnelle, il est nécessaire d’installer manuellement l’ensemble des dépendances logicielles sur le serveur.
    Si vous souhaitez utiliser cette archive pour une installation en mode ferme, il vous faudra également procéder à d’autres modifications (...)

  • MediaSPIP 0.1 Beta version

    25 avril 2011, par

    MediaSPIP 0.1 beta is the first version of MediaSPIP proclaimed as "usable".
    The zip file provided here only contains the sources of MediaSPIP in its standalone version.
    To get a working installation, you must manually install all-software dependencies on the server.
    If you want to use this archive for an installation in "farm mode", you will also need to proceed to other manual (...)

  • Websites made ​​with MediaSPIP

    2 mai 2011, par

    This page lists some websites based on MediaSPIP.

Sur d’autres sites (11554)

  • FFMPEG-Convert video from variable FPS to fixed FPS, without reencode

    23 janvier 2021, par the_RR

    Context

    


    Some videos are composed by joining several other videos with the same codec / resolution.
The ffmpeg 'concat' function is commonly used to accomplish this task.

    


    When concatenating videos of the same codec, resolution, but with different FPS, there will be no error, being concatenated without reencoding and generating a video file with variable FPS.

    


    With metadata similar to :

    


    Frame rate                     : 29.838 FPS
Minimum frame rate             : 2.602 FPS
Maximum frame rate             : 29.970 FPS
Original frame rate            : 12.500 FPS


    


    note_01 : Metadata extracted from wmpc. See the full metadata information

    


    The problem with this profile is that some streaming platforms, despite recognizing the x264 codec and format profile High, do not play streaming videos with variable FPS.
    
Example : Sending video using python lib pyrogram via API to Telegram.

    


    Attempts to solve

    


    All failures, because it was not possible to find a method without reencode that does not generate loss of sync with audio.

    


    With reencode

    


    Result : The transformation process is very long (6x), as there is a reencode. But the FPS becomes successfully fixed. As it takes time, it does not meet the purpose of the search.

    


    ffmpeg -i "input.mp4" -filter:v fps=fps=12.5 "output.mp4"

    


    Without reencode

    


    Result : The complete process is fast (50x), but it generates a side effect of increasing the length of the video, losing the synchronization of the video with the audio. 01h 45min 24sec video, it was improperly transformed into 04h 11min 36sec.

    


    note_02 : This side effect of loss of sync, only occurs when the the input_video has variable FPS. But performs perfectly when the video already has fixed FPS, serving as a means for changing FPS, with 'setpts' flag that accelerates/decelerate the video to counterbalance the effect of the FPS change without reencode in duration, as describe here.

    
Steps


    ffmpeg -y -i "input.mp4" -c copy -f h264 "output_raw_bitstream.h264"
ffmpeg -i "input.mp4" -vn -acodec copy "input_audio.aac"
ffmpeg -r 12.5 -i "input_audio.aac" -i "output_raw_bitstream.h264" -acodec copy -vcodec copy "output.mp4"


    


      

    • 01-Generate raw_bitstream version
    • 


    • 02-Extract audio
    • 


    • 03-Merge raw_bitstream and audio, defining the new FPS
    • 


    


    note_03 : Process suggested in the topic Using ffmpeg to change framerate

    


    note_04 : I also tried to pass '-bsf : v h264_mp4toannexb' in the previous process, generating a .ts file, before turning the video into raw_bitstream.
    
Unfortunately it generated the same result.

    


    The search continues...

    


  • How to optimize encoding and packaging videos using ffmpeg and shaka-packager

    16 novembre 2020, par Saidamir Botirov

    I'm trying to encode and package uploaded videos for an LMS website where video size may differ. How can I write a sh script that converts and packages the given video based on its size (For ex. if the given video resolution is bigger than 720p and less than 1080p FFmpeg should convert videos in 2 sizes [360p, 720p] then shaka-packager should package them).

    


    So far I have this script assuming that input video resolution is 1080p (or 1080p <= size < 4k)

    &#xA;

    #!/bin/sh&#xA;pwd&#xA;URL="$1"&#xA;ID="$2"&#xA;FOLDER="$3"&#xA;&#xA;if [ -z "$URL" ];then&#xA;    echo "Must input a file"&#xA;    $SHELL&#xA;    exit&#xA;fi&#xA;&#xA;DIR="$FOLDER/$ID"&#xA;OUTDIR="$DIR/cmaf"&#xA;mkdir -p -v $DIR&#xA;mkdir -p -v $OUTDIR&#xA;&#xA;GOP_SIZE=50&#xA;FPS=25&#xA;CRF=28&#xA;&#xA;INPUT="$DIR/input"&#xA;wget -c -O $INPUT $URL &amp;&amp;&#xA;&#xA;if [ ! -f $FILE ]; then&#xA;    echo "$FILE does not exists"&#xA;    $SHELL&#xA;    exit&#xA;fi&#xA;&#xA;ffmpeg -i $INPUT -y \&#xA;-threads 1 \&#xA;-c:v libx264 -crf $CRF -profile:v high -pix_fmt yuv420p \&#xA;-keyint_min $GOP_SIZE -g $GOP_SIZE -sc_threshold 0 \&#xA;-color_primaries 1 -color_trc 1 -colorspace 1 -movflags &#x2B;faststart \&#xA;-c:a aac -b:a 128k -ar 44100 \&#xA;-r $FPS \&#xA;"$DIR/input.mp4" &amp;&amp;&#xA;&#xA;ffmpeg -i "$DIR/input.mp4" -y \&#xA;-threads 1 \&#xA;-vn -acodec copy "$DIR/a.mp4" \&#xA;-vf scale=640:360 -an "$DIR/360p.mp4" \&#xA;-vf scale=1280:720 -an "$DIR/720p.mp4" \&#xA;-vf scale=1920:1080 -an "$DIR/1080p.mp4" &amp;&amp;&#xA;&#xA;rm -R $OUTDIR&#xA;&#xA;packager \&#xA;in="$DIR/a.mp4",stream=audio,output="$OUTDIR/a.mp4",drm_label=AUDIO \&#xA;in="$DIR/360p.mp4",stream=video,output="$OUTDIR/360p.mp4",drm_label=SD \&#xA;in="$DIR/720p.mp4",stream=video,output="$OUTDIR/720p.mp4",drm_label=HD \&#xA;in="$DIR/1080p.mp4",stream=video,output="$OUTDIR/1080p.mp4",drm_label=HD \&#xA;--enable_raw_key_encryption \&#xA;--keys label=AUDIO:key_id=f3c5e0761e6654b28f8049c778b23947:key=a4637a153a443df9eed0593043db7517,label=SD:key_id=abba277e8bcf552bbd2e86a434a9a5d7:key=69eaa807a6763af979e8d1940fb88397,label=HD:key_id=6d76f25cb17f5e76b8eaef6b7f582d87:key=cb541784c99737aef4fff74500c12ea7 \&#xA;--pssh 000000377073776800000000EDEF8BA979D64ACEA3C877DCD51D21ED00000071220F7465737420636F6E74656E74206967 \&#xA;--mpd_output "$OUTDIR/h264.mpd" \&#xA;--hls_master_playlist_output "$OUTDIR/h264_master.m3u8"&#xA;

    &#xA;

    The above script first downloads a video by a given URL then converts it to appropriate video format before resizing and packaging. I assumed if I convert the video before scaling would be more performant than every time converting and resizing it. Also, I assumed if I resize to all resolutions in one command it would be much faster, but I think that is not how FFmpeg works. I'm stack in the world of FFmpeg not knowing how to write sh(or bash) script better, cleaner and dynamic for encoding and packaging videos for online streaming. I think there are others with the same problem or the same case. So any help, fix and recommendation is appreciated

    &#xA;

  • How to set a dictionary based off of subprocess.check_output

    5 juillet 2020, par Jessie Wilson

    This is a confusing question, however I will try to make it as clear as possible.&#xA;Currently when I build my app, if I run it via the .py file it works perfectly. However, once I compile it some parts of my app aren't functioning, specifically this code here.

    &#xA;

    def ffprobe_run():&#xA;global output&#xA;global acodec_choices&#xA;run = subprocess.check_output("ffprobe " &#x2B; videoinputquoted &#x2B; " " &#x2B; ffprobecommand, universal_newlines=True)&#xA;print(run)&#xA;if run[-2] == &#x27;3&#x27;:&#xA;    acodec_choices = {"One": "1",&#xA;                      "Two": "2",&#xA;                      "Three": "3"}&#xA;elif run[-2] == &#x27;2&#x27;:&#xA;    acodec_choices = {"One": "1",&#xA;                      "Two": "2",}&#xA;elif run[-2] == &#x27;1&#x27;:&#xA;    acodec_choices = {"One": "1",}&#xA;print(acodec_choices.values())&#xA;

    &#xA;

    I am able to get the results I want with this command. Currently that's using FFPROBE to check for the amount of audio tracks there is in a file. It returns values like so

    &#xA;

    1&#xA;2&#xA;3&#xA;

    &#xA;

    If there is 3 tracks. Or

    &#xA;

    1 &#xA;2&#xA;

    &#xA;

    If it's two tracks. I use the command[-2]&#xA;which will give me the result of '2'

    &#xA;

    So I'm taking that result and defining a dictionary to automatically populate/change an OptionMenu

    &#xA;

    It defines this in my main app

    &#xA;

     # Audio Stream Selection&#xA;    acodec_stream = StringVar(audio_window)&#xA;    if ffprobeinfo[-2] == &#x27;1&#x27;:&#xA;        acodec_stream_choices = {&#x27;Track 1&#x27;: "-map 0:a:0"}&#xA;    elif ffprobeinfo[-2] == &#x27;2&#x27;:&#xA;        acodec_stream_choices = {&#x27;Track 1&#x27;: "-map 0:a:0",&#xA;                                 &#x27;Track 2&#x27;: "-map 0:a:1"}&#xA;    elif ffprobeinfo[-2] == &#x27;3&#x27;:&#xA;        acodec_stream_choices = {&#x27;Track 1&#x27;: "-map 0:a:0",&#xA;                                 &#x27;Track 2&#x27;: "-map 0:a:1",&#xA;                                 &#x27;Track 3&#x27;: "-map 0:a:2"}&#xA;    elif ffprobeinfo[-2] == &#x27;4&#x27;:&#xA;        acodec_stream_choices = {&#x27;Track 1&#x27;: "-map 0:a:0",&#xA;                                 &#x27;Track 2&#x27;: "-map 0:a:1",&#xA;                                 &#x27;Track 3&#x27;: "-map 0:a:2",&#xA;                                 &#x27;Track 4&#x27;: "-map 0:a:3"}&#xA;    elif ffprobeinfo[-2] == &#x27;5&#x27;:&#xA;        acodec_stream_choices = {&#x27;Track 1&#x27;: "-map 0:a:0",&#xA;                                 &#x27;Track 2&#x27;: "-map 0:a:1",&#xA;                                 &#x27;Track 3&#x27;: "-map 0:a:2",&#xA;                                 &#x27;Track 4&#x27;: "-map 0:a:3",&#xA;                                 &#x27;Track 5&#x27;: "-map 0:a:4"}&#xA;    elif ffprobeinfo[-2] == &#x27;6&#x27;:&#xA;        acodec_stream_choices = {&#x27;Track 1&#x27;: "-map 0:a:0",&#xA;                                 &#x27;Track 2&#x27;: "-map 0:a:1",&#xA;                                 &#x27;Track 3&#x27;: "-map 0:a:2",&#xA;                                 &#x27;Track 4&#x27;: "-map 0:a:3",&#xA;                                 &#x27;Track 5&#x27;: "-map 0:a:4",&#xA;                                 &#x27;Track 6&#x27;: "-map 0:a:5"}&#xA;    elif ffprobeinfo[-2] == &#x27;7&#x27;:&#xA;        acodec_stream_choices = {&#x27;Track 1&#x27;: "-map 0:a:0",&#xA;                                 &#x27;Track 2&#x27;: "-map 0:a:1",&#xA;                                 &#x27;Track 3&#x27;: "-map 0:a:2",&#xA;                                 &#x27;Track 4&#x27;: "-map 0:a:3",&#xA;                                 &#x27;Track 5&#x27;: "-map 0:a:4",&#xA;                                 &#x27;Track 6&#x27;: "-map 0:a:5",&#xA;                                 &#x27;Track 7&#x27;: "-map 0:a:6"}&#xA;    elif ffprobeinfo[-2] == &#x27;8&#x27;:&#xA;        acodec_stream_choices = {&#x27;Track 1&#x27;: "-map 0:a:0",&#xA;                                 &#x27;Track 2&#x27;: "-map 0:a:1",&#xA;                                 &#x27;Track 3&#x27;: "-map 0:a:2",&#xA;                                 &#x27;Track 4&#x27;: "-map 0:a:3",&#xA;                                 &#x27;Track 5&#x27;: "-map 0:a:4",&#xA;                                 &#x27;Track 6&#x27;: "-map 0:a:5",&#xA;                                 &#x27;Track 7&#x27;: "-map 0:a:6",&#xA;                                 &#x27;Track 8&#x27;: "-map 0:a:7"}&#xA;    elif ffprobeinfo[-2] == &#x27;9&#x27;:&#xA;        acodec_stream_choices = {&#x27;Track 1&#x27;: "-map 0:a:0",&#xA;                                 &#x27;Track 2&#x27;: "-map 0:a:1",&#xA;                                 &#x27;Track 3&#x27;: "-map 0:a:2",&#xA;                                 &#x27;Track 4&#x27;: "-map 0:a:3",&#xA;                                 &#x27;Track 5&#x27;: "-map 0:a:4",&#xA;                                 &#x27;Track 6&#x27;: "-map 0:a:5",&#xA;                                 &#x27;Track 7&#x27;: "-map 0:a:6",&#xA;                                 &#x27;Track 8&#x27;: "-map 0:a:7",&#xA;                                 &#x27;Track 9&#x27;: "-map 0:a:8"}&#xA;    elif ffprobeinfo[-2] == &#x27;10&#x27;:&#xA;        acodec_stream_choices = {&#x27;Track 1&#x27;: "-map 0:a:0",&#xA;                                 &#x27;Track 2&#x27;: "-map 0:a:1",&#xA;                                 &#x27;Track 3&#x27;: "-map 0:a:2",&#xA;                                 &#x27;Track 4&#x27;: "-map 0:a:3",&#xA;                                 &#x27;Track 5&#x27;: "-map 0:a:4",&#xA;                                 &#x27;Track 6&#x27;: "-map 0:a:5",&#xA;                                 &#x27;Track 7&#x27;: "-map 0:a:6",&#xA;                                 &#x27;Track 8&#x27;: "-map 0:a:7",&#xA;                                 &#x27;Track 9&#x27;: "-map 0:a:8",&#xA;                                 &#x27;Track 10&#x27;: "-map 0:a:9"}&#xA;    acodec_stream.set(&#x27;Track 1&#x27;)  # set the default option&#xA;    acodec_stream_label = Label(audio_window, text="Track :")&#xA;    acodec_stream_label.grid(row=0, column=0, columnspan=1, padx=5, pady=5)&#xA;    acodec_stream_menu = OptionMenu(audio_window, acodec_stream, *acodec_stream_choices.keys())&#xA;    acodec_stream_menu.grid(row=1, column=0, columnspan=1, padx=5, pady=5)&#xA;

    &#xA;

    This is all working great, If I am running the app via the .py file. Once I compile it's missing the entire defined dictionary selection.

    &#xA;

    This is what it's supposed to look like&#xA;enter image description here

    &#xA;

    However, this is what it looks like with the code above. enter image description here

    &#xA;

    If I define the dictionary myself, it works fine. However, then I can't automatically input the correct amount of available audio tracks.

    &#xA;

    I hope this isn't too much code. I'm very new at this.

    &#xA;

    EDIT :

    &#xA;

    If I compile via pyinstaller and remove the -w flag, the program runs correctly, shows the tracks.

    &#xA;

    I'm assuming I'm not using subprocess/calling something correctly. The program I don't think is calling to FFPROBE when it doesn't have a console, vs calling it and getting the value when it has it's own console.

    &#xA;