Recherche avancée

Médias (2)

Mot : - Tags -/documentation

Autres articles (78)

  • Dépôt de média et thèmes par FTP

    31 mai 2013, par

    L’outil MédiaSPIP traite aussi les média transférés par la voie FTP. Si vous préférez déposer par cette voie, récupérez les identifiants d’accès vers votre site MédiaSPIP et utilisez votre client FTP favori.
    Vous trouverez dès le départ les dossiers suivants dans votre espace FTP : config/ : dossier de configuration du site IMG/ : dossier des média déjà traités et en ligne sur le site local/ : répertoire cache du site web themes/ : les thèmes ou les feuilles de style personnalisées tmp/ : dossier de travail (...)

  • Qualité du média après traitement

    21 juin 2013, par

    Le bon réglage du logiciel qui traite les média est important pour un équilibre entre les partis ( bande passante de l’hébergeur, qualité du média pour le rédacteur et le visiteur, accessibilité pour le visiteur ). Comment régler la qualité de son média ?
    Plus la qualité du média est importante, plus la bande passante sera utilisée. Le visiteur avec une connexion internet à petit débit devra attendre plus longtemps. Inversement plus, la qualité du média est pauvre et donc le média devient dégradé voire (...)

  • Le plugin : Podcasts.

    14 juillet 2010, par

    Le problème du podcasting est à nouveau un problème révélateur de la normalisation des transports de données sur Internet.
    Deux formats intéressants existent : Celui développé par Apple, très axé sur l’utilisation d’iTunes dont la SPEC est ici ; Le format "Media RSS Module" qui est plus "libre" notamment soutenu par Yahoo et le logiciel Miro ;
    Types de fichiers supportés dans les flux
    Le format d’Apple n’autorise que les formats suivants dans ses flux : .mp3 audio/mpeg .m4a audio/x-m4a .mp4 (...)

Sur d’autres sites (6466)

  • ffmpeg doesn't generate a ISO/IEC 14496-17 (MPEG-4 text) track when ingesting WebVTT subtitles to produce MPEGTS

    10 avril 2024, par Daniel Andres Pelaez Lopez

    We are trying to create a mpegts with an ISO/IEC 14496-17 (MPEG-4 text) subtitles track, using WebVTT, but seems like ffmpeg creates a ISO 13818-1 PES private data instead.

    


    The following is the ffmpeg command :

    


    ffmpeg -i subtitle.vtt -c:s mov_text -f mpegts output3GPP.ts

    


    This is using the following subtitle.vtt file :

    


    WEBVTT

00:00.000 --> 00:01.000
Subtitle 1

00:01.000 --> 00:02.000
Subtitle 2

00:02.000 --> 00:03.000
Subtitle 3

00:03.000 --> 00:04.000
Subtitle 4


    


    And the following is the output of the ffprobe for that file :

    


    Input #0, mpegts, from 'output3GPP.ts':
  Duration: 00:00:19.00, start: 1.400000, bitrate: 1 kb/s
  Program 1
    Metadata:
      service_name    : Service01
      service_provider: FFmpeg
  Stream #0:0[0x100]: Data: bin_data ([6][0][0][0] / 0x0006)
Unsupported codec with id 98314 for input stream 0


    


    However, if we generate an mp4, it works, the following is the command :

    


    ffmpeg -i subtitle.vtt -c:s mov_text -f mp4 output3GPP.ts

    


    And the following is the output of the ffprobe for that file :

    


    Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'output3GPP.ts':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2mp41
    encoder         : Lavf57.83.100
  Duration: 00:00:20.00, start: 0.000000, bitrate: 0 kb/s
  Stream #0:0[0x1](und): Subtitle: mov_text (tx3g / 0x67337874), 0
kb/s (default)
    Metadata:
      handler_name    : SubtitleHandler


    


    Any reason why both commands behave differently ? is mpegts not supporting ISO/IEC 14496-17 (MPEG-4 text) ?

    


  • Transcoding Videos Using FastAPI and ffmpeg

    15 janvier 2024, par Sanji Vinsmoke

    I created an API using Fast API where I upload one or more videos, may specify the resolution of transcoding, and the output is transcoded video from 240p upto the resolution I specified. Available resolutions are - 240p, 360p, 480p, 720p, 1080p. I used ffmpeg for the transcoding job.

    


    The problem that is bugging me since yesterday is that, after deploying to the s3 bucket and adding the url for the index.m3u8 file in any hls player, the video is blank. Only the audio and streaming are working. I have tried tweaking with the parameters in the ffmpeg parameters, the error is still there. I tried manually transcoding a video file locally, even that video's index.m3u8 file is blank in live version. I added the relevant codes for this project. I implemented each feature one by one, but I simply cannot find the reason why the video is totally blank on live.

    


    def transcode_video(input_path, output_folder, res, video_id, video_resolution, progress_bar=None):
    # Transcode the video into .m3u8 format with segment format
    output_path = os.path.join(output_folder, f"{res}_{video_id}.m3u8")

    # Use subprocess for command execution
    chunk_size = 1 # Specify the desired chunk size in seconds

    transcode_command = [
        "ffmpeg", "-i", input_path, "-vf", f"scale={res}:'trunc(ow/a/2)*2'", "-c:a", "aac", "-strict", "-2",
        "-f", "segment", "-segment_time", str(chunk_size), "-segment_list", output_path, "-segment_format", "ts",
        f"{output_path.replace('.m3u8', '_%03d.ts')}"
    ]

    try:
        subprocess.run(transcode_command, check=True, capture_output=True)
    except subprocess.CalledProcessError as e:
        print(f"Error during transcoding: {e}")
        print(f"FFmpeg error output: {e.stderr}")
        # Continue with the next video even if an error occurs
        return False

    # Update the progress bar
    if progress_bar:
        progress_bar.update(1)
    return True


def get_bandwidth(resolution):
    # Define a simple function to calculate bandwidth based on resolution
    resolutions_and_bandwidths = {
        240: 400000,
        360: 850000,
        480: 1400000,
        720: 2500000,
        1080: 4500000,
    }
    
    return resolutions_and_bandwidths.get(resolution, 0)
def create_index_m3u8(video_id, resolutions_to_transcode):
    # Write the index.m3u8 file
    index_m3u8_path = os.path.join(OUTPUT_FOLDER, f"index_{video_id}.m3u8")
    with open(index_m3u8_path, "w") as index_file:
        index_file.write("#EXTM3U\n")
        index_file.write("#EXT-X-VERSION:3\n")

        for res in resolutions_to_transcode:
            aspect_ratio = 16 / 9
            folder_name = f"{res}p_{video_id}"
            resolution_file_name = f"{res}_{video_id}.m3u8"
            index_file.write(
                f"#EXT-X-STREAM-INF:BANDWIDTH={get_bandwidth(res)},RESOLUTION={int(res * aspect_ratio)}x{res}\n{folder_name}/{resolution_file_name}\n"
            )


    


    I tried reducing or increasing chunk size, adding codecs, setting up dimensions. Where am I doing wrong ?

    


    My python version is 3.8.18, ffmpeg version-4.4.4, ffmpeg-python version-0.2.0

    


  • Problem opening xvid264 with avcodec_alloc_context(NULL)

    12 juillet 2024, par user3763774

    I want to multiplex audio and video together using the ffmpeg encoding library with xvid264rgb codec. I can open the codec when I create the context specifying that codec, but not if I use NULL for the argument with allocate context. My understanding is I need to use NULL so I can open the audio codec as well.

    


    In the example, the first open works with codec indicated in the allocate context. The second doesn't.

    


    #include &#xA;#include &#xA;#include &#xA;#include <libavcodec></libavcodec>avcodec.h>&#xA;#include <libavutil></libavutil>opt.h>&#xA;#define WIDTH 400&#xA;#define HEIGHT 300&#xA;&#xA;const AVCodec *videocodec;&#xA;&#xA;bool init_video_encoder(AVCodecContext *c, int width, int height) {&#xA;    int ret;&#xA;    &#xA;    const AVRational tb_rat = {1, 30};&#xA;    const AVRational fr_rat = {30, 1};&#xA;&#xA;    fprintf(stderr, "init video encoder\n");&#xA;    // video&#xA;    //fprintf(stderr, "speed= %d \n", videocodec->speed);&#xA;    c->bit_rate = 400000;&#xA;    c->width = width;&#xA;    c->height = height;&#xA;    c->time_base = tb_rat;&#xA;    c->framerate = fr_rat;&#xA;    c->gop_size = 10;&#xA;    c->max_b_frames = 1;&#xA;    c->pix_fmt = AV_PIX_FMT_RGB24;&#xA;    if( videocodec->id == AV_CODEC_ID_H264 ) &#xA;        av_opt_set(c->priv_data, "preset", "slow", 0);&#xA;        &#xA;    ret = avcodec_open2(c, videocodec, NULL);&#xA;    if( ret &lt; 0 ) {&#xA;        fprintf(stderr, "failure to open codec: %s\n", av_err2str(ret));&#xA;        return false;&#xA;    }&#xA;    //avcodec_free_context(&amp;c);&#xA;    return true;&#xA;}&#xA;&#xA;int main(int argc, char **argv) {&#xA;&#xA;    AVCodecContext *context = NULL;&#xA;&#xA;    videocodec = avcodec_find_encoder_by_name("libx264rgb");&#xA;    if( videocodec == NULL ) {&#xA;        fprintf(stderr, "video encoder &#x27;libx264rgb&#x27; not found");&#xA;        exit;&#xA;    }&#xA;&#xA;    context = avcodec_alloc_context3(videocodec);&#xA;    if( context == NULL ) {&#xA;        fprintf(stderr, "could not allocate context with codec");&#xA;        return false;&#xA;    }&#xA;    if( init_video_encoder( context, WIDTH, HEIGHT ) ) &#xA;        fprintf(stderr, " success initializing video encoder case one\n");&#xA;    else&#xA;        fprintf(stderr, " failure to initialize video encoder case one\n");&#xA;    avcodec_close( context );&#xA;&#xA;    context = avcodec_alloc_context3(NULL);&#xA;    if( context == NULL ) {&#xA;        fprintf(stderr, "could not allocate context without codec");&#xA;        return false;&#xA;    }&#xA;    if( init_video_encoder( context, WIDTH, HEIGHT ) ) &#xA;        fprintf(stderr, " success initializing video encoder case two\n");&#xA;    else&#xA;        fprintf(stderr, " failure to initialize video encoder case two\n");&#xA;    avcodec_close( context );&#xA;}&#xA;

    &#xA;

    Here is the error message :

    &#xA;

    broken ffmpeg default settings detected&#xA;use an encoding preset (e.g. -vpre medium)&#xA;preset usage: -vpre <speed> -vpre <profile>&#xA;speed presets are listed in x264 --help&#xA;profile is optional; x264 defaults to high&#xA;failure to open codec: Generic error in an external library&#xA;failure to initialize video encoder case two&#xA;</profile></speed>

    &#xA;

    Is this the right approach to use ? How do I set the encoding preset ? The code appears already to do that.

    &#xA;