
Recherche avancée
Médias (91)
-
Richard Stallman et le logiciel libre
19 octobre 2011, par
Mis à jour : Mai 2013
Langue : français
Type : Texte
-
Stereo master soundtrack
17 octobre 2011, par
Mis à jour : Octobre 2011
Langue : English
Type : Audio
-
Elephants Dream - Cover of the soundtrack
17 octobre 2011, par
Mis à jour : Octobre 2011
Langue : English
Type : Image
-
#7 Ambience
16 octobre 2011, par
Mis à jour : Juin 2015
Langue : English
Type : Audio
-
#6 Teaser Music
16 octobre 2011, par
Mis à jour : Février 2013
Langue : English
Type : Audio
-
#5 End Title
16 octobre 2011, par
Mis à jour : Février 2013
Langue : English
Type : Audio
Autres articles (103)
-
MediaSPIP 0.1 Beta version
25 avril 2011, parMediaSPIP 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 (...) -
MediaSPIP version 0.1 Beta
16 avril 2011, parMediaSPIP 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 (...) -
Amélioration de la version de base
13 septembre 2013Jolie sélection multiple
Le plugin Chosen permet d’améliorer l’ergonomie des champs de sélection multiple. Voir les deux images suivantes pour comparer.
Il suffit pour cela d’activer le plugin Chosen (Configuration générale du site > Gestion des plugins), puis de configurer le plugin (Les squelettes > Chosen) en activant l’utilisation de Chosen dans le site public et en spécifiant les éléments de formulaires à améliorer, par exemple select[multiple] pour les listes à sélection multiple (...)
Sur d’autres sites (9387)
-
Piping yt_dlp to FFMPEG using python : ffmpeg failing to recognize video data from pipe
19 juillet 2024, par ThePrinceI am trying to pipe the output of yt_dlp into a pipe used by ffmpeg which then outputs. :


def pipe_function(url):

ydl_command = [
 'yt-dlp', '-f', 'bestvideo+bestaudio', '--quiet', '--no-warnings', '-o', '-', url
]


ffmpeg_command = [
 'ffmpeg', '-v', 'debug', '-i', '-', '-c', 'copy', 'output.mp4'
]


# Start yt-dlp process
ydl_process = subprocess.Popen(
 ydl_command,
 stdout=subprocess.PIPE,
 stderr=subprocess.PIPE
)


# Start ffmpeg process and pipe output from yt-dlp to ffmpeg
ffmpeg_process = subprocess.Popen(
 ffmpeg_command,
 stdin=ydl_process.stdout,
 stdout=subprocess.PIPE,
 stderr=subprocess.PIPE
)



ydl_stdout, ydl_stderr = ydl_process.communicate()


try:
 print(ydl_stdout[:100].decode('utf-8'))
except UnicodeDecodeError:
 print(ydl_stdout[:100].decode('latin-1', errors='ignore'))

ffmpeg_stdout, ffmpeg_stderr = ffmpeg_process.communicate()


if ydl_stderr:
 try:
 print("error in yt-dlp: ", ydl_stderr.decode('utf-8'))
 except UnicodeDecodeError:
 print("decode error in yt-dlp: ", ydl_stderr)

if ffmpeg_stderr:
 try:
 print("error in ffmpeg: ", ffmpeg_stderr.decode('utf-8'))
 except UnicodeDecodeError:
 print("decode error in ffmpeg: ", ffmpeg_stderr)


try:
 print(ffmpeg_stdout[:100].decode('utf-8'))
except UnicodeDecodeError:
 print(ffmpeg_stdout[:100].decode('latin-1', errors='ignore'))

return ffmpeg_stdout



This outputs an audio file. If I look at the console I see some messages. I have removed the lengthier stuff and shown only what I find the most interesting :


[mpegts @ 0000021b8576a380] probing stream 0 pp:1457
[mpegts @ 0000021b8576a380] probed stream 0
[mpegts @ 0000021b8576a380] parser not found for codec bin_data, packets or times may be invalid.
For transform of length 120, inverse, mdct_float, flags: [aligned, out_of_place], found 6 matches:
 1: mdct_inv_float_avx2 - type: mdct_float, len: [16, ∞], factors[2]: [2, any], flags: [aligned, out_of_place, inv_only], prio: 544
 2: mdct_pfa_15xM_inv_float_c - type: mdct_float, len: [30, ∞], factors[2]: [15, any], flags: [unaligned, out_of_place, inv_only], prio: 304
 3: mdct_pfa_5xM_inv_float_c - type: mdct_float, len: [10, ∞], factors[2]: [5, any], flags: [unaligned, out_of_place, inv_only], prio: 144
 4: mdct_pfa_3xM_inv_float_c - type: mdct_float, len: [6, ∞], factors[2]: [3, any], flags: [unaligned, out_of_place, inv_only], prio: 112
 5: mdct_inv_float_c - type: mdct_float, len: [2, ∞], factors[2]: [2, any], flags: [unaligned, out_of_place, inv_only], prio: 96
 6: mdct_naive_inv_float_c - type: mdct_float, len: [2, ∞], factors[2]: [2, any], flags: [unaligned, out_of_place, inv_only], prio: -130976
For transform of length 60, inverse, fft_float, flags: [aligned, inplace, preshuf, asm_call], found 1 matches:
 1: fft_pfa_15xM_asm_float_avx2 - type: fft_float, len: [60, ∞], factors[2]: [15, 2], flags: [aligned, inplace, out_of_place, preshuf, asm_call], prio: 688
For transform of length 4, inverse, fft_float, flags: [aligned, inplace, preshuf, asm_call], found 1 matches:
 1: fft4_fwd_asm_float_sse2 - type: fft_float, len: 4, factor: 2, flags: [aligned, inplace, out_of_place, preshuf, asm_call], prio: 352
Transform tree:
 mdct_inv_float_avx2 - type: mdct_float, len: 120, factors[2]: [2, any], flags: [aligned, out_of_place, inv_only]
 fft_pfa_15xM_asm_float_avx2 - type: fft_float, len: 60, factors[2]: [15, 2], flags: [aligned, inplace, out_of_place, preshuf, asm_call]
 fft4_fwd_asm_float_sse2 - type: fft_float, len: 4, factor: 2, flags: [aligned, inplace, out_of_place, preshuf, asm_call]
For transform of length 128, inverse, mdct_float, flags: [aligned, out_of_place], found 3 matches:
 1: mdct_inv_float_avx2 - type: mdct_float, len: [16, ∞], factors[2]: [2, any], flags: [aligned, out_of_place, inv_only], prio: 544
 2: mdct_inv_float_c - type: mdct_float, len: [2, ∞], factors[2]: [2, any], flags: [unaligned, out_of_place, inv_only], prio: 96
 3: mdct_naive_inv_float_c - type: mdct_float, len: [2, ∞], factors[2]: [2, any], flags: [unaligned, out_of_place, inv_only], prio: -130976
For transform of length 64, inverse, fft_float, flags: [aligned, inplace, preshuf, asm_call], found 3 matches:
 1: fft_sr_asm_float_avx2 - type: fft_float, len: [64, 131072], factor: 2, flags: [aligned, inplace, out_of_place, preshuf, asm_call], prio: 480
 2: fft_sr_asm_float_fma3 - type: fft_float, len: [64, 131072], factor: 2, flags: [aligned, inplace, out_of_place, preshuf, asm_call], prio: 448
 3: fft_sr_asm_float_avx - type: fft_float, len: [64, 131072], factor: 2, flags: [aligned, inplace, out_of_place, preshuf, asm_call], prio: 416
Transform tree:
 mdct_inv_float_avx2 - type: mdct_float, len: 128, factors[2]: [2, any], flags: [aligned, out_of_place, inv_only]
 fft_sr_asm_float_avx2 - type: fft_float, len: 64, factor: 2, flags: [aligned, inplace, out_of_place, preshuf, asm_call]
For transform of length 480, inverse, mdct_float, flags: [aligned, out_of_place], found 6 matches:
 1: mdct_inv_float_avx2 - type: mdct_float, len: [16, ∞], factors[2]: [2, any], flags: [aligned, out_of_place, inv_only], prio: 544
 2: mdct_pfa_15xM_inv_float_c - type: mdct_float, len: [30, ∞], factors[2]: [15, any], flags: [unaligned, out_of_place, inv_only], prio: 304
 3: mdct_pfa_5xM_inv_float_c - type: mdct_float, len: [10, ∞], factors[2]: [5, any], flags: [unaligned, out_of_place, inv_only], prio: 144
 4: mdct_pfa_3xM_inv_float_c - type: mdct_float, len: [6, ∞], factors[2]: [3, any], flags: [unaligned, out_of_place, inv_only], prio: 112
 5: mdct_inv_float_c - type: mdct_float, len: [2, ∞], factors[2]: [2, any], flags: [unaligned, out_of_place, inv_only], prio: 96
 6: mdct_naive_inv_float_c - type: mdct_float, len: [2, ∞], factors[2]: [2, any], flags: [unaligned, out_of_place, inv_only], prio: -130976
For transform of length 240, inverse, fft_float, flags: [aligned, inplace, preshuf, asm_call], found 1 matches:
 1: fft_pfa_15xM_asm_float_avx2 - type: fft_float, len: [60, ∞], factors[2]: [15, 2], flags: [aligned, inplace, out_of_place, preshuf, asm_call], prio: 688
For transform of length 16, inverse, fft_float, flags: [aligned, inplace, preshuf, asm_call], found 2 matches:
 1: fft16_asm_float_fma3 - type: fft_float, len: 16, factor: 2, flags: [aligned, inplace, out_of_place, preshuf, asm_call], prio: 512
 2: fft16_asm_float_avx - type: fft_float, len: 16, factor: 2, flags: [aligned, inplace, out_of_place, preshuf, asm_call], prio: 480
Transform tree:
 mdct_inv_float_avx2 - type: mdct_float, len: 480, factors[2]: [2, any], flags: [aligned, out_of_place, inv_only]
 fft_pfa_15xM_asm_float_avx2 - type: fft_float, len: 240, factors[2]: [15, 2], flags: [aligned, inplace, out_of_place, preshuf, asm_call]
 fft16_asm_float_fma3 - type: fft_float, len: 16, factor: 2, flags: [aligned, inplace, out_of_place, preshuf, asm_call]
For transform of length 512, inverse, mdct_float, flags: [aligned, out_of_place], found 3 matches:
 1: mdct_inv_float_avx2 - type: mdct_float, len: [16, ∞], factors[2]: [2, any], flags: [aligned, out_of_place, inv_only], prio: 544
 2: mdct_inv_float_c - type: mdct_float, len: [2, ∞], factors[2]: [2, any], flags: [unaligned, out_of_place, inv_only], prio: 96
 3: mdct_naive_inv_float_c - type: mdct_float, len: [2, ∞], factors[2]: [2, any], flags: [unaligned, out_of_place, inv_only], prio: -130976
For transform of length 256, inverse, fft_float, flags: [aligned, inplace, preshuf, asm_call], found 3 matches:
 1: fft_sr_asm_float_avx2 - type: fft_float, len: [64, 131072], factor: 2, flags: [aligned, inplace, out_of_place, preshuf, asm_call], prio: 480
 2: fft_sr_asm_float_fma3 - type: fft_float, len: [64, 131072], factor: 2, flags: [aligned, inplace, out_of_place, preshuf, asm_call], prio: 448
 3: fft_sr_asm_float_avx - type: fft_float, len: [64, 131072], factor: 2, flags: [aligned, inplace, out_of_place, preshuf, asm_call], prio: 416
Transform tree:
 mdct_inv_float_avx2 - type: mdct_float, len: 512, factors[2]: [2, any], flags: [aligned, out_of_place, inv_only]
 fft_sr_asm_float_avx2 - type: fft_float, len: 256, factor: 2, flags: [aligned, inplace, out_of_place, preshuf, asm_call]
For transform of length 960, inverse, mdct_float, flags: [aligned, out_of_place], found 6 matches:
 1: mdct_inv_float_avx2 - type: mdct_float, len: [16, ∞], factors[2]: [2, any], flags: [aligned, out_of_place, inv_only], prio: 544
 2: mdct_pfa_15xM_inv_float_c - type: mdct_float, len: [30, ∞], factors[2]: [15, any], flags: [unaligned, out_of_place, inv_only], prio: 304
 3: mdct_pfa_5xM_inv_float_c - type: mdct_float, len: [10, ∞], factors[2]: [5, any], flags: [unaligned, out_of_place, inv_only], prio: 144
 4: mdct_pfa_3xM_inv_float_c - type: mdct_float, len: [6, ∞], factors[2]: [3, any], flags: [unaligned, out_of_place, inv_only], prio: 112
 5: mdct_inv_float_c - type: mdct_float, len: [2, ∞], factors[2]: [2, any], flags: [unaligned, out_of_place, inv_only], prio: 96
 6: mdct_naive_inv_float_c - type: mdct_float, len: [2, ∞], factors[2]: [2, any], flags: [unaligned, out_of_place, inv_only], prio: -130976
For transform of length 480, inverse, fft_float, flags: [aligned, inplace, preshuf, asm_call], found 1 matches:
 1: fft_pfa_15xM_asm_float_avx2 - type: fft_float, len: [60, ∞], factors[2]: [15, 2], flags: [aligned, inplace, out_of_place, preshuf, asm_call], prio: 688
For transform of length 32, inverse, fft_float, flags: [aligned, inplace, preshuf, asm_call], found 2 matches:
 1: fft32_asm_float_fma3 - type: fft_float, len: 32, factor: 2, flags: [aligned, inplace, out_of_place, preshuf, asm_call], prio: 512
 2: fft32_asm_float_avx - type: fft_float, len: 32, factor: 2, flags: [aligned, inplace, out_of_place, preshuf, asm_call], prio: 480
Transform tree:
 mdct_inv_float_avx2 - type: mdct_float, len: 960, factors[2]: [2, any], flags: [aligned, out_of_place, inv_only]
 fft_pfa_15xM_asm_float_avx2 - type: fft_float, len: 480, factors[2]: [15, 2], flags: [aligned, inplace, out_of_place, preshuf, asm_call]
 fft32_asm_float_fma3 - type: fft_float, len: 32, factor: 2, flags: [aligned, inplace, out_of_place, preshuf, asm_call]
For transform of length 1024, inverse, mdct_float, flags: [aligned, out_of_place], found 3 matches:
 1: mdct_inv_float_avx2 - type: mdct_float, len: [16, ∞], factors[2]: [2, any], flags: [aligned, out_of_place, inv_only], prio: 544
 2: mdct_inv_float_c - type: mdct_float, len: [2, ∞], factors[2]: [2, any], flags: [unaligned, out_of_place, inv_only], prio: 96
 3: mdct_naive_inv_float_c - type: mdct_float, len: [2, ∞], factors[2]: [2, any], flags: [unaligned, out_of_place, inv_only], prio: -130976
For transform of length 512, inverse, fft_float, flags: [aligned, inplace, preshuf, asm_call], found 3 matches:
 1: fft_sr_asm_float_avx2 - type: fft_float, len: [64, 131072], factor: 2, flags: [aligned, inplace, out_of_place, preshuf, asm_call], prio: 480
 2: fft_sr_asm_float_fma3 - type: fft_float, len: [64, 131072], factor: 2, flags: [aligned, inplace, out_of_place, preshuf, asm_call], prio: 448
 3: fft_sr_asm_float_avx - type: fft_float, len: [64, 131072], factor: 2, flags: [aligned, inplace, out_of_place, preshuf, asm_call], prio: 416
Transform tree:
 mdct_inv_float_avx2 - type: mdct_float, len: 1024, factors[2]: [2, any], flags: [aligned, out_of_place, inv_only]
 fft_sr_asm_float_avx2 - type: fft_float, len: 512, factor: 2, flags: [aligned, inplace, out_of_place, preshuf, asm_call]
For transform of length 1024, forward, mdct_float, flags: [aligned, out_of_place], found 2 matches:
 1: mdct_fwd_float_c - type: mdct_float, len: [2, ∞], factors[2]: [2, any], flags: [unaligned, out_of_place, fwd_only], prio: 96
 2: mdct_naive_fwd_float_c - type: mdct_float, len: [2, ∞], factors[2]: [2, any], flags: [unaligned, out_of_place, fwd_only], prio: -130976
For transform of length 512, forward, fft_float, flags: [aligned, inplace, preshuf], found 5 matches:
 1: fft_sr_ns_float_avx2 - type: fft_float, len: [64, 131072], factor: 2, flags: [aligned, inplace, out_of_place, preshuf], prio: 480
 2: fft_sr_ns_float_fma3 - type: fft_float, len: [64, 131072], factor: 2, flags: [aligned, inplace, out_of_place, preshuf], prio: 448
 3: fft_sr_ns_float_avx - type: fft_float, len: [64, 131072], factor: 2, flags: [aligned, inplace, out_of_place, preshuf], prio: 416
 4: fft_pfa_ns_float_c - type: fft_float, len: [6, ∞], factors[2]: [7, 5, 3, 2, any], flags: [unaligned, inplace, out_of_place, preshuf], prio: 112
 5: fft512_ns_float_c - type: fft_float, len: 512, factor: 2, flags: [unaligned, inplace, out_of_place, preshuf], prio: 96
Transform tree:
 mdct_fwd_float_c - type: mdct_float, len: 1024, factors[2]: [2, any], flags: [unaligned, out_of_place, fwd_only]
 fft_sr_ns_float_avx2 - type: fft_float, len: 512, factor: 2, flags: [aligned, inplace, out_of_place, preshuf]
For transform of length 64, inverse, mdct_float, flags: [aligned, out_of_place], found 3 matches:
 1: mdct_inv_float_avx2 - type: mdct_float, len: [16, ∞], factors[2]: [2, any], flags: [aligned, out_of_place, inv_only], prio: 544
 2: mdct_inv_float_c - type: mdct_float, len: [2, ∞], factors[2]: [2, any], flags: [unaligned, out_of_place, inv_only], prio: 96
 3: mdct_naive_inv_float_c - type: mdct_float, len: [2, ∞], factors[2]: [2, any], flags: [unaligned, out_of_place, inv_only], prio: -130976
For transform of length 32, inverse, fft_float, flags: [aligned, inplace, preshuf, asm_call], found 2 matches:
 1: fft32_asm_float_fma3 - type: fft_float, len: 32, factor: 2, flags: [aligned, inplace, out_of_place, preshuf, asm_call], prio: 512
 2: fft32_asm_float_avx - type: fft_float, len: 32, factor: 2, flags: [aligned, inplace, out_of_place, preshuf, asm_call], prio: 480
Transform tree:
 mdct_inv_float_avx2 - type: mdct_float, len: 64, factors[2]: [2, any], flags: [aligned, out_of_place, inv_only]
 fft32_asm_float_fma3 - type: fft_float, len: 32, factor: 2, flags: [aligned, inplace, out_of_place, preshuf, asm_call]
For transform of length 64, inverse, mdct_float, flags: [aligned, out_of_place], found 3 matches:
 1: mdct_inv_float_avx2 - type: mdct_float, len: [16, ∞], factors[2]: [2, any], flags: [aligned, out_of_place, inv_only], prio: 544
 2: mdct_inv_float_c - type: mdct_float, len: [2, ∞], factors[2]: [2, any], flags: [unaligned, out_of_place, inv_only], prio: 96
 3: mdct_naive_inv_float_c - type: mdct_float, len: [2, ∞], factors[2]: [2, any], flags: [unaligned, out_of_place, inv_only], prio: -130976
For transform of length 32, inverse, fft_float, flags: [aligned, inplace, preshuf, asm_call], found 2 matches:
 1: fft32_asm_float_fma3 - type: fft_float, len: 32, factor: 2, flags: [aligned, inplace, out_of_place, preshuf, asm_call], prio: 512
 2: fft32_asm_float_avx - type: fft_float, len: 32, factor: 2, flags: [aligned, inplace, out_of_place, preshuf, asm_call], prio: 480
Transform tree:
 mdct_inv_float_avx2 - type: mdct_float, len: 64, factors[2]: [2, any], flags: [aligned, out_of_place, inv_only]
 fft32_asm_float_fma3 - type: fft_float, len: 32, factor: 2, flags: [aligned, inplace, out_of_place, preshuf, asm_call]
[mpegts @ 0000021b8576a380] max_analyze_duration 5000000 reached at 5005000 microseconds st:0
[mpegts @ 0000021b8576a380] After avformat_find_stream_info() pos: 5403308 bytes read:5404624 seeks:0 frames:365
Input #0, mpegts, from 'fd:':
 Duration: N/A, start: 1.400000, bitrate: 130 kb/s
 Program 1
 Metadata:
 service_name : Service01
 service_provider: FFmpeg
 Stream #0:0[0x100], 152, 1/90000: Data: bin_data ([6][0][0][0] / 0x0006), 0/1
 Stream #0:1[0x101](und), 213, 1/90000: Audio: aac (LC) ([15][0][0][0] / 0x000F), 44100 Hz, stereo, fltp, 130 kb/s
Successfully opened the file.
Parsing a group of options: output url output.mp4.
Applying option c (codec name) with argument copy.
Successfully parsed a group of options.
Opening an output file: output.mp4.
[out#0/mp4 @ 0000021b89b251c0] No explicit maps, mapping streams automatically...
[aost#0:0/copy @ 0000021b89b8d800] Created audio stream from input stream 0:1
[file @ 0000021b89586680] Setting default whitelist 'file,crypto,data'
Successfully opened the file.
Stream mapping:
 Stream #0:1 -> #0:0 (copy)
Output #0, mp4, to 'output.mp4':
 Metadata:
 encoder : Lavf60.20.100
 Stream #0:0(und), 0, 1/44100: Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 130 kb/s
[out#0/mp4 @ 0000021b89b251c0] Starting thread...
[in#0/mpegts @ 0000021b85724080] Starting thread...
Automatically inserted bitstream filter 'aac_adtstoasc'; args=''
[in#0/mpegts @ 0000021b85724080] EOF while reading inputpeed= 40x
[in#0/mpegts @ 0000021b85724080] Terminating thread with return code 0 (success)
[out#0/mp4 @ 0000021b89b251c0] All streams finished
[out#0/mp4 @ 0000021b89b251c0] Terminating thread with return code 0 (success)
[AVIOContext @ 0000021b87146340] Statistics: 2723207 bytes written, 2 seeks, 14 writeouts
[out#0/mp4 @ 0000021b89b251c0] Output file #0 (output.mp4):
[out#0/mp4 @ 0000021b89b251c0] Output stream #0:0 (audio): 7232 packets muxed (2737451 bytes);
[out#0/mp4 @ 0000021b89b251c0] Total: 7232 packets (2737451 bytes) muxed
[out#0/mp4 @ 0000021b89b251c0] video:0kB audio:2673kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: unknown
size= 2659kB time=00:02:47.92 bitrate= 129.7kbits/s speed=41.3x
 Metadata:
 encoder : Lavf60.20.100
 Stream #0:0(und), 0, 1/44100: Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 130 kb/s
[out#0/mp4 @ 0000021b89b251c0] Starting thread...
[in#0/mpegts @ 0000021b85724080] Starting thread...
Automatically inserted bitstream filter 'aac_adtstoasc'; args=''
[in#0/mpegts @ 0000021b85724080] EOF while reading inputpeed= 40x
[in#0/mpegts @ 0000021b85724080] Terminating thread with return code 0 (success)
[out#0/mp4 @ 0000021b89b251c0] All streams finished
[out#0/mp4 @ 0000021b89b251c0] Terminating thread with return code 0 (success)
[AVIOContext @ 0000021b87146340] Statistics: 2723207 bytes written, 2 seeks, 14 writeouts
[out#0/mp4 @ 0000021b89b251c0] Output file #0 (output.mp4):
[out#0/mp4 @ 0000021b89b251c0] Output stream #0:0 (audio): 7232 packets muxed (2737451 bytes);
[out#0/mp4 @ 0000021b89b251c0] Total: 7232 packets (2737451 bytes) muxed
[out#0/mp4 @ 0000021b89b251c0] video:0kB audio:2673kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: unknown
size= 2659kB time=00:02:47.92 bitrate= 129.7kbits/s speed=41.3x
[in#0/mpegts @ 0000021b85724080] Starting thread...
Automatically inserted bitstream filter 'aac_adtstoasc'; args=''
[in#0/mpegts @ 0000021b85724080] EOF while reading inputpeed= 40x
[in#0/mpegts @ 0000021b85724080] Terminating thread with return code 0 (success)
[out#0/mp4 @ 0000021b89b251c0] All streams finished
[out#0/mp4 @ 0000021b89b251c0] Terminating thread with return code 0 (success)
[AVIOContext @ 0000021b87146340] Statistics: 2723207 bytes written, 2 seeks, 14 writeouts
[out#0/mp4 @ 0000021b89b251c0] Output file #0 (output.mp4):
[out#0/mp4 @ 0000021b89b251c0] Output stream #0:0 (audio): 7232 packets muxed (2737451 bytes);
[out#0/mp4 @ 0000021b89b251c0] Total: 7232 packets (2737451 bytes) muxed
[out#0/mp4 @ 0000021b89b251c0] video:0kB audio:2673kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: unknown
size= 2659kB time=00:02:47.92 bitrate= 129.7kbits/s speed=41.3x
[out#0/mp4 @ 0000021b89b251c0] All streams finished
[out#0/mp4 @ 0000021b89b251c0] Terminating thread with return code 0 (success)
[AVIOContext @ 0000021b87146340] Statistics: 2723207 bytes written, 2 seeks, 14 writeouts
[out#0/mp4 @ 0000021b89b251c0] Output file #0 (output.mp4):
[out#0/mp4 @ 0000021b89b251c0] Output stream #0:0 (audio): 7232 packets muxed (2737451 bytes);
[out#0/mp4 @ 0000021b89b251c0] Total: 7232 packets (2737451 bytes) muxed
[out#0/mp4 @ 0000021b89b251c0] video:0kB audio:2673kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: unknown
size= 2659kB time=00:02:47.92 bitrate= 129.7kbits/s speed=41.3x
[out#0/mp4 @ 0000021b89b251c0] Output file #0 (output.mp4):
[out#0/mp4 @ 0000021b89b251c0] Output stream #0:0 (audio): 7232 packets muxed (2737451 bytes);
[out#0/mp4 @ 0000021b89b251c0] Total: 7232 packets (2737451 bytes) muxed
[out#0/mp4 @ 0000021b89b251c0] video:0kB audio:2673kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: unknown
size= 2659kB time=00:02:47.92 bitrate= 129.7kbits/s speed=41.3x
[out#0/mp4 @ 0000021b89b251c0] Total: 7232 packets (2737451 bytes) muxed
[out#0/mp4 @ 0000021b89b251c0] video:0kB audio:2673kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: unknown
size= 2659kB time=00:02:47.92 bitrate= 129.7kbits/s speed=41.3x
[out#0/mp4 @ 0000021b89b251c0] video:0kB audio:2673kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: unknown
size= 2659kB time=00:02:47.92 bitrate= 129.7kbits/s speed=41.3x
[in#0/mpegts @ 0000021b85724080] Input file #0 (fd:):
size= 2659kB time=00:02:47.92 bitrate= 129.7kbits/s speed=41.3x
[in#0/mpegts @ 0000021b85724080] Input file #0 (fd:):
[in#0/mpegts @ 0000021b85724080] Input file #0 (fd:):
[in#0/mpegts @ 0000021b85724080] Input stream #0:1 (audio): 7232 packets read (2737451 bytes);
[in#0/mpegts @ 0000021b85724080] Total: 7232 packets (2737451 bytes) demuxed
[AVIOContext @ 0000021b85744880] Statistics: 27226912 bytes read, 0 seeks



It seems to me that the video data is being interpreted as bin_data and no codec is found for it. What is going on here ?


Must YT_DLP data be converted to some other format before being read by FFMPEG ?


Thank you.


-
Muxing H264 packets into a MPEGTS container using libav*
30 avril 2024, par LucenI'm writing a C++ program where I need to encode packets in h264 format and mux them to a MPEG TS container. For the encoding part, I based my code on the encode_video example (https://ffmpeg.org/doxygen/trunk/encode_video_8c-example.html#a9) provided in FFMPEG documentation, and it seems to work fine. In particular, I generate a std::vector of packets which I sequentially write to an output .ts file for debug. Such .ts file plays fine with SMPlayer, and a ffproba command gives


>> ffprobe -print_format json -show_format -show_streams out.ts
Input #0, h264, from 'out.ts':
 Duration: N/A, bitrate: N/A
 Stream #0:0: Video: h264 (Main), yuv420p(progressive), 640x480 [SAR 1:1 DAR 4:3], 25 fps, 25 tbr, 1200k tbn, 50 tbc
 "streams": [
 {
 "index": 0,
 "codec_name": "h264",
 "codec_long_name": "H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10",
 "profile": "Main",
 "codec_type": "video",
 "codec_time_base": "1/50",
 "codec_tag_string": "[0][0][0][0]",
 "codec_tag": "0x0000",
 "width": 640,
 "height": 480,
 "coded_width": 640,
 "coded_height": 480,
 "has_b_frames": 1,
 "sample_aspect_ratio": "1:1",
 "display_aspect_ratio": "4:3",
 "pix_fmt": "yuv420p",
 "level": 30,
 "chroma_location": "left",
 "field_order": "progressive",
 "refs": 1,
 "is_avc": "false",
 "nal_length_size": "0",
 "r_frame_rate": "25/1",
 "avg_frame_rate": "25/1",
 "time_base": "1/1200000",
 "bits_per_raw_sample": "8",
 "disposition": {
 "default": 0,
 "dub": 0,
 "original": 0,
 "comment": 0,
 "lyrics": 0,
 "karaoke": 0,
 "forced": 0,
 "hearing_impaired": 0,
 "visual_impaired": 0,
 "clean_effects": 0,
 "attached_pic": 0,
 "timed_thumbnails": 0
 }
 }
 ],
 "format": {
 "filename": "out.ts",
 "nb_streams": 1,
 "nb_programs": 0,
 "format_name": "h264",
 "format_long_name": "raw H.264 video",
 "size": "435443",
 "probe_score": 51
 }
}




The dts and pts timestamps are also set.
However, if I try to mux them in MPEG TS format, using as a base the example mux.c (https://ffmpeg.org/doxygen/trunk/mux_8c-example.html), it doesn't work. A shortened version of my muxing code is as follows : (the variables ending with "_" are class fields)


int MyProcessing::Mux(const std::string outputFilename) {
 AVFormatContext *muxingContest;
 avformat_alloc_output_context2(&muxingContest, NULL, NULL, m_output.c_str());

 auto outFormat = muxingContest->oformat;
 outFormat->video_codec = AV_CODEC_ID_H264;

 AVStream *outStream;
 const AVCodec *codec;

 Mux_AddStream(&outStream, muxingContest, &codec, outFormat->video_codec);

 AVDictionary *opt = nullptr;
 Mux_OpenVideo(muxingContest, codec, outStream, opt);
 
 if (!(muxingContest->flags & AVFMT_NOFILE)) {
 avio_open(&muxingContest->pb, m_output.c_str(), AVIO_FLAG_WRITE);
 }
 avformat_write_header(muxingContest, &opt);

 auto muxOk = true;
 size_t countMuxedFrames = 0;
 while ((muxOk) && (countMuxedFrames < packets_.size())) {
 muxOk = !MuxPacket(muxingContest, outStream, packets_[countMuxedFrames], &opt);
 countMuxedFrames++;
 }

 av_write_trailer(muxingContest);
 if (!(muxCodecContextPtr_->flags & AVFMT_NOFILE)) avio_closep(&muxingContest->pb);
 
 return 0;
}


int MyProcessing::Mux_AddStream(AVStream **stream, AVFormatContext *format, const AVCodec **codec, enum AVCodecID codecId) {
 *codec = avcodec_find_encoder(codecId);
 muxPacketTmpPtr_ = av_packet_alloc();
 *stream = avformat_new_stream(format, *codec);
 (*stream)->time_base = (AVRational){ 1, STREAM_FRAME_RATE };
 (*stream)->id = format->nb_streams-1;
 (*stream)->index = 0;
 muxCodecContextPtr_ = avcodec_alloc_context3(*codec);
 Mux_FillCodecContext(*muxCodecContextPtr_, codecId, **stream);
 if (format->oformat->flags & AVFMT_GLOBALHEADER)
 muxCodecContextPtr_->flags |= AV_CODEC_FLAG_GLOBAL_HEADER;
 return 0;
}


void MyProcessing::Mux_FillCodecContext(AVCodecContext &cc, enum AVCodecID codecId, AVStream &stream) {
 cc.codec_id = codecId;
 cc.bit_rate = 400000;
 cc.width = outputWidth_;
 cc.height = outputHeight_;
 cc.time_base = stream.time_base;
 cc.gop_size = 10;
 cc.max_b_frames = 1;
 cc.gop_size = 12;
 cc.pix_fmt = AV_PIX_FMT_YUV420P;
 if (cc.codec_id == AV_CODEC_ID_MPEG2VIDEO) cc.max_b_frames = 2;
 if (cc.codec_id == AV_CODEC_ID_MPEG1VIDEO) cc.mb_decision = 2;
 av_opt_set(&cc, "preset", "slow", 0);
 av_opt_set(&cc, "tune", "zerolatency", 0);
}


int MyProcessing::Mux_OpenVideo(AVFormatContext *format, const AVCodec *codec, AVStream *stream, AVDictionary *opt_arg) {
 AVDictionary *opt = nullptr;
 av_dict_copy(&opt, opt_arg, 0);
 muxCodecContextPtr_->flags |= AV_CODEC_FLAG_GLOBAL_HEADER;
 avcodec_open2(muxCodecContextPtr_, codec, &opt);
 av_dict_free(&opt);
 avcodec_parameters_from_context(stream->codecpar, muxCodecContextPtr_);
 return 0;
}

int MyProcessing::MuxPacket(AVFormatContext *format, AVStream *stream, AVPacket &pkt, AVDictionary **opt) {
 AVBitStreamFilterContext *bsf = av_bitstream_filter_init("h264_mp4toannexb");
 AVPacket filteredPkt = pkt;
 auto filterResult = av_bitstream_filter_filter(bsf, format->streams[stream->index]->codec, NULL,
 &filteredPkt.data, &filteredPkt.size,
 pkt.data, pkt.size,
 pkt.flags & AV_PKT_FLAG_KEY);

 if (filterResult < 0) return filterResult;
 else {
 filteredPkt.buf = av_buffer_create(filteredPkt.data, filteredPkt.size,
 av_buffer_default_free, NULL, 0);
 }
 av_bitstream_filter_close(bsf);
 filteredPkt.stream_index = stream->index;
 filteredPkt.dts = filteredPkt.pts;
 filteredPkt.duration = ((double)stream->time_base.num / (double)stream->time_base.den) / STREAM_FRAME_RATE;
 av_packet_rescale_ts(&filteredPkt, muxCodecContextPtr_->time_base, stream->time_base); // rescale output packet timestamp values from codec to stream timebase
 auto writePktResult = av_write_frame(format, &filteredPkt);
 // auto writePktResult = av_interleaved_write_frame(format, &filteredPkt);
 return 0;
}




The console error is


[mpegts @ 0x55555736edc0] H.264 bitstream malformed, no startcode found, use the video bitstream filter 'h264_mp4toannexb' to fix it ('-bsf:v h264_mp4toannexb' option with ffmpeg)



It Is telling me to apply the h264_mp4toannexb filter. As you see from the code, I've put the filtering accordingly, but the error message persists (unless I'm applying the filter in a wrong way).


In the last lines of method MuxPacket(), if I uncomment the line with av_interleaved_write_frame() and comment the previous one, I get the same error, as well as a seg fault. Inspecting with GDB, the call stack for the seg fault is as follows :


#0 __memmove_avx_unaligned_erms () at ../sysdeps/x86_64/multiarch/memmove-vec-unaligned-erms.S:440
#1 0x00007ffff67c7cb6 in av_packet_copy_props () at /lib/x86_64-linux-gnu/libavcodec.so.58
#2 0x00007ffff67c8447 in av_packet_ref () at /lib/x86_64-linux-gnu/libavcodec.so.58
#3 0x00007ffff7e2fa13 in () at /lib/x86_64-linux-gnu/libavformat.so.58
#4 0x00007ffff7e2fb11 in () at /lib/x86_64-linux-gnu/libavformat.so.58
#5 0x00007ffff7e30575 in av_interleaved_write_frame () at /lib/x86_64-linux-gnu/libavformat.so.58



I tried to look at solutions online, but they are either old or they don't work. Some of the things I tried and didn't work :


- 

- Putting the line




muxCodecContextPtr_->flags |= AV_CODEC_FLAG_GLOBAL_HEADER;



in Mux() after the call to avformat_alloc_output_context2.


- 

- Setting




packet.flags |= AV_PKT_FLAG_KEY;



before the call to av_write_frame / av_interleaved_write_frame.


- 

-
Trying to write by hand to the file the starting code as described here Need to convert h264 stream from annex-b format to AVCC format.


-
Playing with parameters in Mux_FillCodecContext().








-
Crash on ffmpeg avcodec_encode_video in a Console app
5 mars 2013, par Robel sharmaI want make an encoder which encode a raw image into h263 format.But after loading and initializing ffmpeg library I got crash on avcodec_encode_video for a demo image.
int _tmain(int argc, _TCHAR* argv[]) {
avcodec_register_all();
AVCodec *codec;
AVCodecContext *c= NULL;
int i, ret, x, y, got_output;
FILE *f;
AVFrame *frame;
AVPacket pkt;
int out_size, size, outbuf_size;
AVFrame *picture;
uint8_t *outbuf, *picture_buf;
AVRational rp;
rp.den = 1;
rp.num = 25;
uint8_t endcode[] = { 0, 0, 1, 0xb7 };
codec = avcodec_find_encoder(CODEC_ID_H263);
c = avcodec_alloc_context3(codec);
picture= avcodec_alloc_frame();
c->bit_rate = 400000;
/* resolution must be a multiple of two */
c->width = 352;
c->height = 288;
/* frames per second */
//c->time_base= (AVRational){1,25};
c->time_base = rp;
c->gop_size = 10; /* emit one intra frame every ten frames */
c->max_b_frames=1;
c->pix_fmt = PIX_FMT_YUV420P;
avcodec_open(c, codec);
outbuf_size = 100000;
outbuf = (uint8_t*)malloc(outbuf_size);
size = c->width * c->height;
picture_buf = (uint8_t*)malloc((size * 3) / 2); /* size for YUV 420 */
picture->data[0] = picture_buf;
picture->data[1] = picture->data[0] + size;
picture->data[2] = picture->data[1] + size / 4;
picture->linesize[0] = c->width;
picture->linesize[1] = c->width / 2;
picture->linesize[2] = c->width / 2;
/* encode 1 second of video */
for(i=0;i<25;i++) {
fflush(stdout);
/* prepare a dummy image */
/* Y */
for(y=0;yheight;y++) {
for(x=0;xwidth;x++) {
picture->data[0][y * picture->linesize[0] + x] = x + y + i * 3;
}
}
/* Cb and Cr */
for(y=0;yheight/2;y++) {
for(x=0;xwidth/2;x++) {
picture->data[1][y * picture->linesize[1] + x] = 128 + y + i * 2;
picture->data[2][y * picture->linesize[2] + x] = 64 + x + i * 5;
}
}
/* encode the image */
**Crash is here** ---> ///////////////////////////////////////////////////
out_size = avcodec_encode_video(c, outbuf, outbuf_size, picture);
printf("encoding frame %3d (size=%5d)\n", i, out_size);
fwrite(outbuf, 1, out_size, f);
}
/* get the delayed frames */
for(; out_size; i++) {
fflush(stdout);
out_size = avcodec_encode_video(c, outbuf, outbuf_size, NULL);
printf("write frame %3d (size=%5d)\n", i, out_size);
fwrite(outbuf, 1, out_size, f);
}
/* add sequence end code to have a real mpeg file */
outbuf[0] = 0x00;
outbuf[1] = 0x00;
outbuf[2] = 0x01;
outbuf[3] = 0xb7;
fwrite(outbuf, 1, 4, f);
fclose(f);
free(picture_buf);
free(outbuf);
avcodec_close(c);
av_free(c);
av_free(picture);
printf("\n");
return 0;
}