
Recherche avancée
Autres articles (97)
-
Websites made with MediaSPIP
2 mai 2011, parThis page lists some websites based on MediaSPIP.
-
Problèmes fréquents
10 mars 2010, parPHP et safe_mode activé
Une des principales sources de problèmes relève de la configuration de PHP et notamment de l’activation du safe_mode
La solution consiterait à soit désactiver le safe_mode soit placer le script dans un répertoire accessible par apache pour le site -
Possibilité de déploiement en ferme
12 avril 2011, parMediaSPIP peut être installé comme une ferme, avec un seul "noyau" hébergé sur un serveur dédié et utilisé par une multitude de sites différents.
Cela permet, par exemple : de pouvoir partager les frais de mise en œuvre entre plusieurs projets / individus ; de pouvoir déployer rapidement une multitude de sites uniques ; d’éviter d’avoir à mettre l’ensemble des créations dans un fourre-tout numérique comme c’est le cas pour les grandes plate-formes tout public disséminées sur le (...)
Sur d’autres sites (6472)
-
Convert a video with content type video/quicktime to video/mp4 using ffmpeg
25 juin 2021, par schubI have a strange problem. I start with a video file recored with an iPhone. The output is
video.mov
. I convert this to mp4 using ffmpeg :

ffmpeg -i video.mov -vcodec h264 -acodec aac video.mp4


If I use a tool like exiftool to show the metadata the output for
content-type
isvideo/mp4
all seems to be correct. But my backend, which receives the video, uses a library called Apache Tika to extract the content type and the result here is :video/quicktime
.

Scala code to retrieve the content type from the file :


// byteArray: Array[Byte]

val tika = new TikaConfig()
val metadata = new Metadata()
val contentType = tika.getDetector.detect(TikaInputStream.get(byteArray), metadata)



BTW : If I use a video editing program (DaVinci Resolve in my case) I can load the video, adjust settings and explicitly set the codec to mp4, export the video and then the resulting file works and Apache Tika extract the desired content-type. This is a workaround, but it does not scale and I like to automate this process via ffmpeg.


I'm stuck here. Can anyone give me a hint what I can do ?


Versions :


tika : 1.22

ffmpeg : 4.4

ffmpeg log :


$ffmpeg -i video.mov -vcodec h264 -acodec aac video.mp4
ffmpeg version 4.4 Copyright (c) 2000-2021 the FFmpeg developers
 built with Apple clang version 12.0.0 (clang-1200.0.32.29)
 configuration: --prefix=/usr/local/Cellar/ffmpeg/4.4_2 --enable-shared --enable-pthreads --enable-version3 --cc=clang --host-cflags= --host-ldflags= --enable-ffplay --enable-gnutls --enable-gpl --enable-libaom --enable-libbluray --enable-libdav1d --enable-libmp3lame --enable-libopus --enable-librav1e --enable-librubberband --enable-libsnappy --enable-libsrt --enable-libtesseract --enable-libtheora --enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxml2 --enable-libxvid --enable-lzma --enable-libfontconfig --enable-libfreetype --enable-frei0r --enable-libass --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libspeex --enable-libsoxr --enable-libzmq --enable-libzimg --disable-libjack --disable-indev=jack --enable-avresample --enable-videotoolbox
 libavutil 56. 70.100 / 56. 70.100
 libavcodec 58.134.100 / 58.134.100
 libavformat 58. 76.100 / 58. 76.100
 libavdevice 58. 13.100 / 58. 13.100
 libavfilter 7.110.100 / 7.110.100
 libavresample 4. 0. 0 / 4. 0. 0
 libswscale 5. 9.100 / 5. 9.100
 libswresample 3. 9.100 / 3. 9.100
 libpostproc 55. 9.100 / 55. 9.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'video.mov':
 Metadata:
 major_brand : qt
 minor_version : 0
 compatible_brands: qt
 creation_time : 2021-06-24T11:19:37.000000Z
 com.apple.quicktime.location.accuracy.horizontal: 65.000000
 com.apple.quicktime.location.ISO6709: +52.5554+013.3772+042.268/
 com.apple.quicktime.make: Apple
 com.apple.quicktime.model: iPhone 8
 com.apple.quicktime.software: 14.4.2
 com.apple.quicktime.creationdate: 2021-06-24T13:19:36+0200
 Duration: 00:00:09.83, start: 0.000000, bitrate: 7954 kb/s
 Stream #0:0(und): Video: hevc (Main) (hvc1 / 0x31637668), yuv420p(tv, bt709), 1920x1080, 7810 kb/s, 30.01 fps, 30 tbr, 600 tbn, 600 tbc (default)
 Metadata:
 rotate : 90
 creation_time : 2021-06-24T11:19:37.000000Z
 handler_name : Core Media Video
 vendor_id : [0][0][0][0]
 encoder : HEVC
 Side data:
 displaymatrix: rotation of -90.00 degrees
 Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, mono, fltp, 96 kb/s (default)
 Metadata:
 creation_time : 2021-06-24T11:19:37.000000Z
 handler_name : Core Media Audio
 vendor_id : [0][0][0][0]
 Stream #0:2(und): Data: none (mebx / 0x7862656D), 0 kb/s (default)
 Metadata:
 creation_time : 2021-06-24T11:19:37.000000Z
 handler_name : Core Media Metadata
 Stream #0:3(und): Data: none (mebx / 0x7862656D), 0 kb/s (default)
 Metadata:
 creation_time : 2021-06-24T11:19:37.000000Z
 handler_name : Core Media Metadata
 Stream #0:4(und): Data: none (mebx / 0x7862656D), 34 kb/s (default)
 Metadata:
 creation_time : 2021-06-24T11:19:37.000000Z
 handler_name : Core Media Metadata
Stream mapping:
 Stream #0:0 -> #0:0 (hevc (native) -> h264 (libx264))
 Stream #0:1 -> #0:1 (aac (native) -> aac (native))
Press [q] to stop, [?] for help
[libx264 @ 0x7fbe08009400] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX FMA3 BMI2 AVX2
[libx264 @ 0x7fbe08009400] profile High, level 4.0, 4:2:0, 8-bit
[libx264 @ 0x7fbe08009400] 264 - core 163 r3060 5db6aa6 - H.264/MPEG-4 AVC codec - Copyleft 2003-2021 - http://www.videolan.org/x264.html - options: cabac=1 ref=3 deblock=1:0:0 analyse=0x3:0x113 me=hex subme=7 psy=1 psy_rd=1.00:0.00 mixed_ref=1 me_range=16 chroma_me=1 trellis=1 8x8dct=1 cqm=0 deadzone=21,11 fast_pskip=1 chroma_qp_offset=-2 threads=12 lookahead_threads=2 sliced_threads=0 nr=0 decimate=1 interlaced=0 bluray_compat=0 constrained_intra=0 bframes=3 b_pyramid=2 b_adapt=1 b_bias=0 direct=1 weightb=1 open_gop=0 weightp=2 keyint=250 keyint_min=25 scenecut=40 intra_refresh=0 rc_lookahead=40 rc=crf mbtree=1 crf=23.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 ip_ratio=1.40 aq=1:1.00
Output #0, mp4, to 'video.mp4':
 Metadata:
 major_brand : qt
 minor_version : 0
 compatible_brands: qt
 com.apple.quicktime.creationdate: 2021-06-24T13:19:36+0200
 com.apple.quicktime.location.accuracy.horizontal: 65.000000
 com.apple.quicktime.location.ISO6709: +52.5554+013.3772+042.268/
 com.apple.quicktime.make: Apple
 com.apple.quicktime.model: iPhone 8
 com.apple.quicktime.software: 14.4.2
 encoder : Lavf58.76.100
 Stream #0:0(und): Video: h264 (avc1 / 0x31637661), yuv420p(tv, bt709, progressive), 1080x1920, q=2-31, 30 fps, 15360 tbn (default)
 Metadata:
 encoder : Lavc58.134.100 libx264
 creation_time : 2021-06-24T11:19:37.000000Z
 handler_name : Core Media Video
 vendor_id : [0][0][0][0]
 Side data:
 cpb: bitrate max/min/avg: 0/0/0 buffer size: 0 vbv_delay: N/A
 displaymatrix: rotation of -0.00 degrees
 Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, mono, fltp, 69 kb/s (default)
 Metadata:
 creation_time : 2021-06-24T11:19:37.000000Z
 handler_name : Core Media Audio
 vendor_id : [0][0][0][0]
 encoder : Lavc58.134.100 aac
frame= 295 fps= 18 q=-1.0 Lsize= 9980kB time=00:00:09.82 bitrate=8323.6kbits/s speed=0.614x
video:9884kB audio:85kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.103401%
[libx264 @ 0x7fbe08009400] frame I:6 Avg QP:21.84 size: 50301
[libx264 @ 0x7fbe08009400] frame P:217 Avg QP:24.23 size: 35435
[libx264 @ 0x7fbe08009400] frame B:72 Avg QP:24.97 size: 29582
[libx264 @ 0x7fbe08009400] consecutive B-frames: 66.8% 0.7% 4.1% 28.5%
[libx264 @ 0x7fbe08009400] mb I I16..4: 6.7% 88.9% 4.4%
[libx264 @ 0x7fbe08009400] mb P I16..4: 4.2% 32.9% 0.5% P16..4: 49.6% 5.0% 2.3% 0.0% 0.0% skip: 5.5%
[libx264 @ 0x7fbe08009400] mb B I16..4: 0.9% 6.9% 0.0% B16..8: 51.8% 7.7% 0.8% direct:12.2% skip:19.6% L0:50.1% L1:46.9% BI: 3.0%
[libx264 @ 0x7fbe08009400] 8x8 transform intra:87.7% inter:88.8%
[libx264 @ 0x7fbe08009400] coded y,uvDC,uvAC intra: 59.2% 41.2% 0.9% inter: 38.3% 57.3% 0.0%
[libx264 @ 0x7fbe08009400] i16 v,h,dc,p: 15% 23% 8% 53%
[libx264 @ 0x7fbe08009400] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 16% 14% 29% 7% 8% 7% 7% 6% 6%
[libx264 @ 0x7fbe08009400] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 23% 18% 18% 9% 11% 7% 7% 4% 3%
[libx264 @ 0x7fbe08009400] i8c dc,h,v,p: 60% 20% 18% 1%
[libx264 @ 0x7fbe08009400] Weighted P-Frames: Y:3.2% UV:2.3%
[libx264 @ 0x7fbe08009400] ref P L0: 54.2% 10.7% 22.2% 12.5% 0.4%
[libx264 @ 0x7fbe08009400] ref B L0: 75.5% 19.6% 4.9%
[libx264 @ 0x7fbe08009400] ref B L1: 88.7% 11.3%
[libx264 @ 0x7fbe08009400] kb/s:8234.01
[aac @ 0x7fbe0802e000] Qavg: 446.889



-
HLS script has been lost to time, previous content was made in specific format, attempting to recreate using FFMPEG primitives
28 février, par WungoLooking to add this video to a stitched playlist. The variants, encoding, and everything must match exactly. We have no access to how things were done previously, so I am literally vibing through this as best as I can.


I recommend using a clip of buck bunny that's 30 seconds long, or the original buck bunny 1080p video.


#!/bin/bash
ffmpeg -i bbb_30s.mp4 -filter_complex "
[0:v]split=7[v1][v2][v3][v4][v5][v6][v7];
[v1]scale=416:234[v1out];
[v2]scale=416:234[v2out];
[v3]scale=640:360[v3out];
[v4]scale=768:432[v4out];
[v5]scale=960:540[v5out];
[v6]scale=1280:720[v6out];
[v7]scale=1920:1080[v7out]
" \
-map "[v1out]" -c:v:0 libx264 -b:v:0 200k -maxrate 361k -bufsize 400k -r 29.97 -g 60 -keyint_min 60 -sc_threshold 0 -preset veryfast -profile:v baseline -level 3.0 \
-map "[v2out]" -c:v:1 libx264 -b:v:1 500k -maxrate 677k -bufsize 700k -r 29.97 -g 60 -keyint_min 60 -sc_threshold 0 -preset veryfast -profile:v baseline -level 3.0 \
-map "[v3out]" -c:v:2 libx264 -b:v:2 1000k -maxrate 1203k -bufsize 1300k -r 29.97 -g 60 -keyint_min 60 -sc_threshold 0 -preset veryfast -profile:v main -level 3.1 \
-map "[v4out]" -c:v:3 libx264 -b:v:3 1800k -maxrate 2057k -bufsize 2200k -r 29.97 -g 60 -keyint_min 60 -sc_threshold 0 -preset veryfast -profile:v main -level 3.1 \
-map "[v5out]" -c:v:4 libx264 -b:v:4 2500k -maxrate 2825k -bufsize 3000k -r 29.97 -g 60 -keyint_min 60 -sc_threshold 0 -preset veryfast -profile:v main -level 4.0 \
-map "[v6out]" -c:v:5 libx264 -b:v:5 5000k -maxrate 5525k -bufsize 6000k -r 29.97 -g 60 -keyint_min 60 -sc_threshold 0 -preset veryfast -profile:v high -level 4.1 \
-map "[v7out]" -c:v:6 libx264 -b:v:6 8000k -maxrate 9052k -bufsize 10000k -r 29.97 -g 60 -keyint_min 60 -sc_threshold 0 -preset veryfast -profile:v high -level 4.2 \
-map a:0 -c:a:0 aac -b:a:0 128k -ar 48000 -ac 2 \
-f hls -hls_time 6 -hls_playlist_type vod -hls_flags independent_segments \
-hls_segment_type fmp4 \
-hls_segment_filename "output_%v_%03d.mp4" \
-master_pl_name master.m3u8 \
-var_stream_map "v:0,name:layer-416x234-200k v:1,name:layer-416x234-500k v:2,name:layer-640x360-1000k v:3,name:layer-768x432-1800k v:4,name:layer-960x540-2500k v:5,name:layer-1280x720-5000k v:6,name:layer-1920x1080-8000k a:0,name:layer-audio-128k" \
output_%v.m3u8




Above is what i've put together over the past few days.


I consistently run into the same issues :


- 

- my variants must match identically, the bit rate etc. must match identically no excuses. No variance allowed.
- When I did it a different way previously, it became impossible to sync the variants timing, thus making the project not stitchable, making the asset useless.The variants are encoded to last longer than the master.m3u8 says it will last. Rejecting the asset downstream.
- I end up either having variants mismatched with timing, or no audio/audio channels synced properly. Here is what the master.m3u8 should look like.








#EXTM3U
#EXT-X-VERSION:7

#EXT-X-STREAM-INF:AUDIO="aac",AVERAGE-BANDWIDTH=333000,BANDWIDTH=361000,CLOSED-CAPTIONS="cc1",CODECS="avc1.4d400d,mp4a.40.2",FRAME-RATE=29.97,RESOLUTION=416x234
placeholder.m3u8
#EXT-X-STREAM-INF:AUDIO="aac",AVERAGE-BANDWIDTH=632000,BANDWIDTH=677000,CLOSED-CAPTIONS="cc1",CODECS="avc1.4d400d,mp4a.40.2",FRAME-RATE=29.97,RESOLUTION=416x234
placeholder2.m3u8
#EXT-X-STREAM-INF:AUDIO="aac",AVERAGE-BANDWIDTH=1133000,BANDWIDTH=1203000,CLOSED-CAPTIONS="cc1",CODECS="avc1.4d401e,mp4a.40.2",FRAME-RATE=29.97,RESOLUTION=640x360
placeholder3.m3u8

#EXT-X-STREAM-INF:AUDIO="aac",AVERAGE-BANDWIDTH=1933000,BANDWIDTH=2057000,CLOSED-CAPTIONS="cc1",CODECS="avc1.4d401f,mp4a.40.2",FRAME-RATE=29.97,RESOLUTION=768x432
placeholder4.m3u8

#EXT-X-STREAM-INF:AUDIO="aac",AVERAGE-BANDWIDTH=2633000,BANDWIDTH=2825000,CLOSED-CAPTIONS="cc1",CODECS="avc1.4d401f,mp4a.40.2",FRAME-RATE=29.97,RESOLUTION=960x540
placeholder5.m3u8

#EXT-X-STREAM-INF:AUDIO="aac",AVERAGE-BANDWIDTH=5134000,BANDWIDTH=5525000,CLOSED-CAPTIONS="cc1",CODECS="avc1.4d401f,mp4a.40.2",FRAME-RATE=29.97,RESOLUTION=1280x720
placeholder6.m3u8

#EXT-X-STREAM-INF:AUDIO="aac",AVERAGE-BANDWIDTH=8135000,BANDWIDTH=9052000,CLOSED-CAPTIONS="cc1",CODECS="avc1.640028,mp4a.40.2",FRAME-RATE=29.97,RESOLUTION=1920x1080
placeholder7.m3u8

#EXT-X-STREAM-INF:AUDIO="aac",AVERAGE-BANDWIDTH=129000,BANDWIDTH=130000,CLOSED-CAPTIONS="cc1",CODECS="mp4a.40.2"
placeholder8.m3u8

#EXT-X-MEDIA:AUTOSELECT=YES,CHANNELS="2",DEFAULT=YES,GROUP-ID="aac",LANGUAGE="en",NAME="English",TYPE=AUDIO,URI="placeholder8.m3u8"
#EXT-X-MEDIA:AUTOSELECT=YES,DEFAULT=YES,GROUP-ID="cc1",INSTREAM-ID="CC1",LANGUAGE="en",NAME="English",TYPE=CLOSED-CAPTIONS



Underlying playlist clips should be *.mp4 not *.m4s or anything like that. Audio must be on a single channel by itself, closed captions are handled by a remote server and aren't a concern.


as mentioned above :


- 

- I have tried transcoding separately and then combining manually or later. Here is an example of that.




#!/bin/bash
set -e

# Input file
INPUT_FILE="bbb_30.mp4"

# Output directory
OUTPUT_DIR="hls_output"
mkdir -p "$OUTPUT_DIR"

# First, extract exact duration from master.m3u8 (if it exists)
MASTER_M3U8="master.m3u8" # Change if needed

echo "Extracting exact duration from the source MP4..."
EXACT_DURATION=$(ffprobe -v error -show_entries format=duration -of default=noprint_wrappers=1:nokey=1 "$INPUT_FILE")
echo "Using exact duration: $EXACT_DURATION seconds"
# Create a reference file with exact duration from the source
echo "Creating reference file with exact duration..."
ffmpeg -y -i "$INPUT_FILE" -c copy -t "$EXACT_DURATION" "$OUTPUT_DIR/exact_reference.mp4"

# Calculate exact GOP size for segment alignment (for 6-second segments at 29.97fps)
FPS=29.97
SEGMENT_DURATION=6
GOP_SIZE=$(echo "$FPS * $SEGMENT_DURATION" | bc | awk '{print int($1)}')
echo "Using GOP size of $GOP_SIZE frames for $SEGMENT_DURATION-second segments at $FPS fps"

# Function to encode a variant with exact duration
encode_variant() {
 local resolution="$1"
 local bitrate="$2"
 local maxrate="$3"
 local bufsize="$4"
 local profile="$5"
 local level="$6"
 local audiorate="$7"
 local name_suffix="$8"
 
 echo "Encoding $resolution variant with video bitrate $bitrate kbps and audio bitrate ${audiorate}k..."
 
 # Step 1: Create an intermediate file with exact duration and GOP alignment
 ffmpeg -y -i "$OUTPUT_DIR/exact_reference.mp4" \
 -c:v libx264 -profile:v "$profile" -level "$level" \
 -x264-params "bitrate=$bitrate:vbv-maxrate=$maxrate:vbv-bufsize=$bufsize:keyint=$GOP_SIZE:min-keyint=$GOP_SIZE:no-scenecut=1" \
 -s "$resolution" -r "$FPS" \
 -c:a aac -b:a "${audiorate}k" \
 -vsync cfr -start_at_zero -reset_timestamps 1 \
 -map 0:v:0 -map 0:a:0 \
 -t "$EXACT_DURATION" \
 -force_key_frames "expr:gte(t,n_forced*6)" \
 "$OUTPUT_DIR/temp_${name_suffix}.mp4"
 
 # Step 2: Create HLS segments with exact boundaries from the intermediate file.
 ffmpeg -y -i "$OUTPUT_DIR/temp_${name_suffix}.mp4" \
 -c copy \
 -f hls \
 -hls_time "$SEGMENT_DURATION" \
 -hls_playlist_type vod \
 -hls_segment_filename "$OUTPUT_DIR/layer-${name_suffix}-segment-%03d.mp4" \
 -hls_flags independent_segments+program_date_time+round_durations \
 -hls_list_size 0 \
 "$OUTPUT_DIR/layer-${name_suffix}.m3u8"
 
 # Verify duration
 VARIANT_DURATION=$(ffprobe -v error -show_entries format=duration -of default=noprint_wrappers=1:nokey=1 "$OUTPUT_DIR/temp_${name_suffix}.mp4")
 echo "Variant $name_suffix duration: $VARIANT_DURATION (target: $EXACT_DURATION, diff: $(echo "$VARIANT_DURATION - $EXACT_DURATION" | bc))"
 
 # Clean up temporary file
 rm "$OUTPUT_DIR/temp_${name_suffix}.mp4"
}

# Process each variant with exact duration matching
# Format: resolution, bitrate, maxrate, bufsize, profile, level, audio bitrate, name suffix
encode_variant "416x234" "333" "361" "722" "baseline" "3.0" "64" "416x234-200k"
encode_variant "416x234" "632" "677" "1354" "baseline" "3.0" "64" "416x234-500k"
encode_variant "640x360" "1133" "1203" "2406" "main" "3.0" "96" "640x360-1000k"
encode_variant "768x432" "1933" "2057" "4114" "main" "3.1" "96" "768x432-1800k"
encode_variant "960x540" "2633" "2825" "5650" "main" "3.1" "128" "960x540-2500k"
encode_variant "1280x720" "5134" "5525" "11050" "main" "3.1" "128" "1280x720-5000k"
encode_variant "1920x1080" "8135" "9052" "18104" "high" "4.0" "128" "1920x1080-8000k"

# 8. Audio-only variant
echo "Creating audio-only variant..."


# ffmpeg -y -i "$INPUT_FILE" \
# -vn -map 0:a \
# -c:a aac -b:a 128k -ac 2 \ 
# -t "$EXACT_DURATION" \
# -f hls \
# -hls_time "$SEGMENT_DURATION" \
# -hls_playlist_type vod \
# -hls_flags independent_segments+program_date_time+round_durations \
# -hls_segment_filename "$OUTPUT_DIR/layer-audio-128k-segment-%03d.ts" \
# -hls_list_size 0 \
# "$OUTPUT_DIR/layer-audio-128k.m3u8"

ffmpeg -y -i "$INPUT_FILE" \
 -vn \
 -map 0:a \
 -c:a aac -b:a 128k \
 -t "$EXACT_DURATION" \
 -f hls \
 -hls_time "$SEGMENT_DURATION" \
 -hls_playlist_type vod \
 -hls_segment_type fmp4 \
 -hls_flags independent_segments+program_date_time+round_durations \
 -hls_list_size 0 \
 -hls_segment_filename "$OUTPUT_DIR/layer-audio-128k-segment-%03d.m4s" \
 "$OUTPUT_DIR/layer-audio-128k.m3u8"


# Create master playlist
cat > "$OUTPUT_DIR/master.m3u8" << EOF
#EXTM3U
#EXT-X-VERSION:7
#EXT-X-INDEPENDENT-SEGMENTS

#EXT-X-STREAM-INF:BANDWIDTH=361000,AVERAGE-BANDWIDTH=333000,CODECS="avc1.4d400d,mp4a.40.2",RESOLUTION=416x234,FRAME-RATE=29.97
layer-416x234-200k.m3u8
#EXT-X-STREAM-INF:BANDWIDTH=677000,AVERAGE-BANDWIDTH=632000,CODECS="avc1.4d400d,mp4a.40.2",RESOLUTION=416x234,FRAME-RATE=29.97
layer-416x234-500k.m3u8
#EXT-X-STREAM-INF:BANDWIDTH=1203000,AVERAGE-BANDWIDTH=1133000,CODECS="avc1.4d401e,mp4a.40.2",RESOLUTION=640x360,FRAME-RATE=29.97
layer-640x360-1000k.m3u8
#EXT-X-STREAM-INF:BANDWIDTH=2057000,AVERAGE-BANDWIDTH=1933000,CODECS="avc1.4d401f,mp4a.40.2",RESOLUTION=768x432,FRAME-RATE=29.97
layer-768x432-1800k.m3u8
#EXT-X-STREAM-INF:BANDWIDTH=2825000,AVERAGE-BANDWIDTH=2633000,CODECS="avc1.4d401f,mp4a.40.2",RESOLUTION=960x540,FRAME-RATE=29.97
layer-960x540-2500k.m3u8
#EXT-X-STREAM-INF:BANDWIDTH=5525000,AVERAGE-BANDWIDTH=5134000,CODECS="avc1.4d401f,mp4a.40.2",RESOLUTION=1280x720,FRAME-RATE=29.97
layer-1280x720-5000k.m3u8
#EXT-X-STREAM-INF:BANDWIDTH=9052000,AVERAGE-BANDWIDTH=8135000,CODECS="avc1.640028,mp4a.40.2",RESOLUTION=1920x1080,FRAME-RATE=29.97
layer-1920x1080-8000k.m3u8
#EXT-X-STREAM-INF:BANDWIDTH=130000,AVERAGE-BANDWIDTH=129000,CODECS="mp4a.40.2"
layer-audio-128k.m3u8
EOF

# Verify all durations match
cat > "$OUTPUT_DIR/verify_all.sh" << 'EOF'
#!/bin/bash

# Get exact reference duration from the exact reference file
REFERENCE_DURATION=$(ffprobe -v error -show_entries format=duration -of default=noprint_wrappers=1:nokey=1 "exact_reference.mp4")
echo "Reference duration: $REFERENCE_DURATION seconds"

# Check each segment's duration
echo -e "\nChecking individual segments..."
for seg in layer-*-segment-*.mp4 layer-audio-128k-segment-*.ts; do
 dur=$(ffprobe -v error -show_entries format=duration -of default=noprint_wrappers=1:nokey=1 "$seg")
 echo "$seg: $dur seconds"
done

# Get total duration for each variant by summing segment EXTINF durations from each playlist
echo -e "\nChecking combined variant durations..."
for variant in layer-*.m3u8; do
 total=0
 while read -r line; do
 if [[ $line == "#EXTINF:"* ]]; then
 dur=$(echo "$line" | sed 's/#EXTINF:\([0-9.]*\).*/\1/')
 total=$(echo "$total + $dur" | bc)
 fi
 done < "$variant"
 echo "$variant: $total seconds (reference: $REFERENCE_DURATION, diff: $(echo "$total - $REFERENCE_DURATION" | bc))"
done
EOF

chmod +x "$OUTPUT_DIR/verify_all.sh"

echo "HLS packaging complete with exact duration matching."
echo "Master playlist available at: $OUTPUT_DIR/master.m3u8"
echo "Run $OUTPUT_DIR/verify_all.sh to verify durations."
rm "$OUTPUT_DIR/exact_reference.mp4"




I end up with weird audio in vlc which can't be right, and I also end up with variants being longer than the master.m3u8 playlist which is wonky.


I tried using AI to fix the audio sync issue, and honestly I'm more confused than when I started.


-
Revision 180cd5faa5 : General code cleanup. Removing redundant code, lower case variable names, bette
27 mars 2013, par Dmitry KovalevChanged Paths : Modify /vp9/common/vp9_entropymv.c Modify /vp9/common/vp9_extend.c Modify /vp9/common/vp9_extend.h Modify /vp9/common/vp9_postproc.c Modify /vp9/common/vp9_postproc.h Modify /vp9/decoder/vp9_dboolhuff.h Modify /vp9/decoder/vp9_onyxd_if.c (...)