Recherche avancée

Médias (1)

Mot : - Tags -/biographie

Autres articles (32)

  • Automated installation script of MediaSPIP

    25 avril 2011, par

    To overcome the difficulties mainly due to the installation of server side software dependencies, an "all-in-one" installation script written in bash was created to facilitate this step on a server with a compatible Linux distribution.
    You must have access to your server via SSH and a root account to use it, which will install the dependencies. Contact your provider if you do not have that.
    The documentation of the use of this installation script is available here.
    The code of this (...)

  • Création définitive du canal

    12 mars 2010, par

    Lorsque votre demande est validée, vous pouvez alors procéder à la création proprement dite du canal. Chaque canal est un site à part entière placé sous votre responsabilité. Les administrateurs de la plateforme n’y ont aucun accès.
    A la validation, vous recevez un email vous invitant donc à créer votre canal.
    Pour ce faire il vous suffit de vous rendre à son adresse, dans notre exemple "http://votre_sous_domaine.mediaspip.net".
    A ce moment là un mot de passe vous est demandé, il vous suffit d’y (...)

  • Keeping control of your media in your hands

    13 avril 2011, par

    The vocabulary used on this site and around MediaSPIP in general, aims to avoid reference to Web 2.0 and the companies that profit from media-sharing.
    While using MediaSPIP, you are invited to avoid using words like "Brand", "Cloud" and "Market".
    MediaSPIP is designed to facilitate the sharing of creative media online, while allowing authors to retain complete control of their work.
    MediaSPIP aims to be accessible to as many people as possible and development is based on expanding the (...)

Sur d’autres sites (3264)

  • Bash script to automate FFmpeg operations fails when calling the command, but copy-pasting the generated command into the terminal works [duplicate]

    28 février, par GaboScharff99

    I wrote a bash script which automates a number of conversion operations on video files using FFmpeg. Oddly enough, the FFmpeg call itself now fails when running the script, with a very confusing error message, I might add, but when I copy the command generated by the script into the terminal and run it, it works flawlessly. I'm sorry to insert such a long code block here, but considering how strange this error is, it might be anywhere in the script, so here it is :

    


    #!/bin/bash

audioTrack=1
subSource=1
subTrack=0
transcodeVideo=1
transcodeAudio=1
volumeMultiplier=1
degradeToStereo=0
subLanguage="Japanese"

while getopts "t:ns:vam:dl:h" opt; do
    case "$opt" in
        t) audioTrack=${OPTARG};;
        n) subSource=0;;
        s) subTrack=${OPTARG};;
        v) transcodeVideo=0;;
        a) transcodeAudio=0;;
        m) volumeMultiplier=${OPTARG};;
        d) degradeToStereo=1;;
        l) subLanguage=${OPTARG};;
        h)
            echo "Options:"
            echo "-t [integer]: Audio track number. Default: 1."
            echo "-n: If included, subtitles will be taken from internal source."
            echo "-s [integer]: Subtitles track number. Default: 0."
            echo "-v: If included, video source will be copied without transcoding."
            echo "-a: If included, audio source will be copied without transcoding."
            echo "-m [number]: Volume multiplier. If 1, volume is unaffected. Default: 1"
            echo "-d: If included, audio will be degraded to stereo."
            echo "-l [language]: Subtitles language. Only used for external subtitles source. Default: Japanese."
            exit 0
        ;;
    esac
done

echo "Audio track: $audioTrack."
echo "Subtitles track: $subTrack."
params="-map 0:0 -map 0:$audioTrack -map $subSource:$subTrack -c:v"

if [[ $transcodeVideo -eq 1 ]]; then
    echo "Video will be transcoded."
    params="$params hevc"
elif [[ $transcodeVideo -eq 0 ]]; then
    echo "Video will be copied without transcoding."
    params="$params copy"
fi

params="$params -c:a"

if [[ $transcodeAudio -eq 1 ]]; then
    echo "Audio will be transcoded."
    params="$params libopus"
elif [[ $transcodeAudio -eq 0 ]]; then
    echo "Audio will be copied without transcoding."
    params="$params copy"
fi

if [[ $volumeMultiplier -ne 1 ]]; then
    echo "Volume will be multiplied by a factor of $volumeMultiplier."
    params="$params -filter:a 'volume=$volumeMultiplier'"
else
    echo "Volume will be unaffected."
fi

if [[ $degradeToStereo -eq 1 ]]; then
    echo "Audio will be degraded to stereo."
    params="$params -ac 2"
elif [[ $degradeToStereo -eq 0 ]]; then
    echo "Audio will not be degraded to stereo."
fi

params="$params -c:s copy"

if [[ $subSource -eq 1 ]]; then
    echo "Subtitles source is external."
    echo "Subtitles language is $subLanguage."
    params="$params -metadata:s:s:0 title='' -metadata:s:s:0 language='$subLanguage'"
else
    echo "Subtitles source is internal."
fi

if [[ -f titles.txt ]]; then
    echo "A titles.txt file was found. Titles will be changed according to it."
    echo "Please check titles.txt to make sure the titles are correct."
    changeTitles=1
    counter=0
else
    echo "A titles.txt file was not found. Titles will not be changed."
    changeTitles=0
fi

read -p "Are these options correct? (y/n) " choice

case "$choice" in
    y|Y)
        echo "Initiating conversion sequence. This may take a while..."

        mkdir output
        currentParams=""

        shopt -s nullglob
        for i in *.mp4 *.mkv; do
            currentParams=$params
            fileNameNoExtension=$(echo $i | rev | cut -f 2- -d '.' | rev)

            if [[ $subSource -eq 1 ]]; then
                currentParams="-f srt -i $fileNameNoExtension.srt $currentParams"
            fi

            if [[ $changeTitles -eq 1 ]]; then
                ((counter++))
                currentParams="$currentParams -metadata title='$(awk "NR==$counter" titles.txt)'"
            fi

            ffmpeg -i "$i" $currentParams "output/$fileNameNoExtension.mkv"
        done

        echo "Conversion finished!"
    ;;
    n|N) echo "Operation canceled. Exiting.";;
    *) echo "Invalid input. Try again.";;
esac


    


    The directory I'm running this in contains six video files :

    


      

    1. E1 - The Pirates of Orion.mkv
    2. 


    3. E2 - Bem.mkv
    4. 


    5. E3 - The Practical Joker.mkv
    6. 


    7. E4 - Albatross.mkv
    8. 


    9. E5 - How Sharper Than a Serpent's Tooth.mkv
    10. 


    11. E6 - The Counter-Clock Incident.mkv
    12. 


    


    Here's the titles.txt file, for completion's sake :

    


    Star Trek: The Animated Series - Season 2, Episode 1 - The Pirates of Orion
Star Trek: The Animated Series - Season 2, Episode 2 - Bem
Star Trek: The Animated Series - Season 2, Episode 3 - The Practical Joker
Star Trek: The Animated Series - Season 2, Episode 4 - Albatross
Star Trek: The Animated Series - Season 2, Episode 5 - How Sharper Than a Serpent's Tooth
Star Trek: The Animated Series - Season 2, Episode 6 - The Counter-Clock Incident


    


    And finally, here's the error message given by FFmpeg on the terminal for every video file when running the command :

    


    Unable to find a suitable output format for 'Trek:'
Trek:: Invalid argument


    


    Maybe there are better ways to handle all of this, but first and foremost, I would like to figure out why the command fails with such a confusing error message. The only place where the string 'Trek :' is found is in the title taken from titles.txt, but I don't understand why that's seemingly being passed to the name of the output file instead of the title, and apparently only when running the script.

    


    Thanks a lot for your answers ! I know this is quite a bit of text, so I really appreciate you taking your time to read through this.

    


  • Python-ffmpeg video metadata editing script - Error splitting the argument list : Option not found

    16 janvier, par maric193

    I have been updating a simple script that allows me to mass edit video files metadata (in a specific folder) and save them with a new filename (inside the same folder). I have been bouncing around different forums and decided to try python-ffmpeg.
For some reason right now I am getting the below FFmpegInvalidCommand exception

    


    Error splitting the argument list: Option not found

    


    I am not quite sure what I am doing wrong here, so I am wondering if someone can give me a fresh set of eyes to determine what the problem is. Apologies in advance, there may be some leftover code that I have not cut out yet. Thanks in advance !

    


    import os
import re
import sys
from pathlib import Path
from ffmpeg import FFmpeg, FFmpegFileNotFound, FFmpegInvalidCommand
#Project looks through a folder, checks all the files in there, then edits metadata (and filename)
#and returns a new file for each file inside the folder

video = 'Anime' #Movie/TVSeries/Anime/etc...
name = 'Sword Art Online (2012)'
extension = '.mkv'
season = '01'
episode = 1

try:
    folder = r'D:\ServerTransfer\Update Server\%s\%s\S%s\\' % (video, name, season)

    #Check current file names
    print('Current names are: ')
    res = os.listdir(folder)
    print(res)
    
    # episode increase by 1 in each iteration
    # iterate all files from a directory
    for file_name in os.listdir(folder):
        # Construct old file name
        source = folder + file_name
        try:
            title = ''
            if episode < 100:
                # Adding the season & episode #'s
                destination = folder + name + '.S' + season + 'E0' + str(episode) + extension
                title = name + '.S' + season + 'E0' + str(episode)
##            elif episode < 100:
##                # Adding the season & episode #'s
##                destination = folder + name + '.S' + season + '.E0' + str(episode) + extension
            else:
                # Adding the season & episode #'s
                destination = folder + name + '.S' + season + 'E' + str(episode) + extension
                title = name + '.S' + season + 'E' + str(episode)
            # Renaming the file
            if file_name.endswith(extension):
                ffmpeg = FFmpeg(executable=r'c:\FFmpeg\bin\ffmpeg.exe').option("y").input(source).output(destination,codec="copy",title=title)
                ffmpeg.execute()
        except FFmpegFileNotFound as exception:
            print("An FFmpegFileNotFound exception has been occurred!")
            print("- Message from ffmpeg:", exception.message)
            print("- Arguments to execute ffmpeg:", exception.arguments)
        except FFmpegInvalidCommand as exception:
            print("An FFmpegInvalidCommand exception has been occurred!")
            print("- Message from ffmpeg:", exception.message)
            print("- Arguments to execute ffmpeg:", exception.arguments)
        except Exception as err:
            print(f'Unexptected {err=}, {type(err)=}')
            raise
        episode += 1
    print('All Files Renamed')
    print('New Names are')
    # verify the result
    res = os.listdir(folder)
    print(res)
except OSError as err:
    print('OS error:', err)
except Exception as err:
    print(f'Unexptected {err=}, {type(err)=}')
    raise


    


    Here is what one of my print statements in the exception says is being executed

    


    - Arguments to execute ffmpeg: ['c:\\FFmpeg\\bin\\ffmpeg.exe', '-y', '-i', 'D:\\ServerTransfer\\Update Server\\Anime\\Sword Art Online (2012)\\S01\\\\[Kosaka] Sword Art Online - 01 - The World of Swords (1080p AV1 10Bit BluRay OPUS) [73066623].mkv', '-codec', 'copy', '-title', 'Sword Art Online (2012).S01E01', 'D:\\ServerTransfer\\Update Server\\Anime\\Sword Art Online (2012)\\S01\\\\Sword Art Online (2012).S01E01.mkv']


    


    I have tried different variations of trying to run ffmpeg via python including using subprocess and shlex libraries. I also tried moviepy, however no one has answered me back on their page.

    


  • HLS Encoding Resulting in "No Supported Source Was Found"

    18 février 2023, par Paulamonopoly

    I'm currently facing the most bizare problems I've come across, so I'm hoping someone can explain why this is happening. I'm currently converting my Movie and Show libary to HLS for buffering and bandwidth reasons etc.

    


    My file structure for these movies and shows are as follows :

    


    /Movies/[TMDB ID]/[TMDB ID].mp4

    


    /Shows/[TMDB ID/[Season Number]/[Episode Number]/[Episode Number].mp4

    


    I have converted my entire movie collection successfully using the below command.

    


    find /* -type f -name "*.mp4" -exec realpath {} \; -exec ffmpeg -i {} -codec: copy -start_number 0 -hls_time 10 -hls_list_size 0 -f hls -hls_segment_filename '{}-P%03d' {}.m3u8 \;


    


    This is taking my named mp4 files and converting them to the originalname.m3u8 with chunks following the naming scheme of originalname-PXXX where P indicates the part number. I know there's no file extensions attached with the chunks but it's not needed.

    


    You can view this result here : Example

    


    This result also works if loaded into HLS Player : HLS Player

    


    So there is evidently nothing wrong with the converting of my videos or even the result of the videos.

    


    Now, if I convert a TV Show using the exact same command, it does indeed convert them, it does use a slightly different file structure as with seasons and episodes etc which can be seen above, but now it results in the error : "No Supported Source Was Found" in the console and repeatedly tries to play Part 000 without success.

    


    This can be seen here : Example

    


    And the errors if loaded into HLS Player : HLS Player

    


    I have tried changing numerous things to try and resolve this error as well as checking things, the things I have checked are the media condition itself maybe it's a corrupted file ?

    


    The original Mp4 file can be played here without any problems, so we know the Mp4 file originally is perfectly fine. I have also tried adding a file extension to the chunks such as .ts and .mp4 etc etc with also no success.

    


    I have even thought maybe it's the directories so I have moved a show into the movies directory with no success, I have also moved a movie into the show directory which resulted in a working HLS Stream so it's nothing to do with the directories.

    


    I have tried exending the file name length thinking it's possibly the naming scheme with 1.m3u8 not been long enough of a file name by using placeholder text such as 03051.m3u8 as well as the chunk naming scheme 03051-PXXX possibly not been long enough.

    


    I have noticed though that using this command :

    


    ffmpeg -allowed_extensions ALL -i {} -c copy -bsf:a aac_adtstoasc {}.mkv \;


    


    Does recombine my HLS video correctly with the same file size etc, however I have noticed that the video itself is corrupt and doesn't play. So this makes be believe the issue lies within the converting of the initial Mp4 file into m3u8.