ffmpeg – How do I convert mjpeg+aac=mp4 file to a h264+aac=mp4
I have a folder full of MP4 files that I want to convert. All are from X Spaces recordings that are done with –embed-thumbnail option of yt-dlp. I am using this command to convert them:
for %%F in (*.mp4) do (
ffmpeg -i "%%F" -c:v libx264 -preset medium -crf 23 -c:a aac -b:a 128k -ac 2 "..\Processed\%%F"
)
But the script fails with:
[mov,mp4,m4a,3gp,3g2,mj2 @ 000002ec6b08ad00] stream 0, timescale not set
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'Beklentiler 2025-09-22 20_21 [1OdJrOnZyYpxX].mp4':
Metadata:
major_brand : isom
minor_version : 512
compatible_brands: isomiso2mp41
encoder : Lavf61.7.100
Duration: 01:24:40.77, start: 0.000000, bitrate: 95 kb/s
Stream #0:0[0x1](und): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 93 kb/s (default)
Metadata:
handler_name : SoundHandler
vendor_id : [0][0][0][0]
Stream #0:1[0x0]: Video: mjpeg (Progressive), yuvj420p(pc, bt470bg/unknown/unknown), 400x400 [SAR 1:1 DAR 1:1], 90k tbr, 90k tbn (attached pic)
Stream mapping:
Stream #0:1 -> #0:0 (mjpeg (native) -> h264 (libx264))
Stream #0:0 -> #0:1 (aac (native) -> aac (native))
Press [q] to stop, [?] for help
[libx264 @ 000002ec6b08fcc0] using SAR=1/1
[libx264 @ 000002ec6b08fcc0] MB rate (56250000) > level limit (16711680)
[libx264 @ 000002ec6b08fcc0] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX
[libx264 @ 000002ec6b08fcc0] profile High, level 6.2, 4:2:0, 8-bit
[libx264 @ 000002ec6b08fcc0] 264 - core 164 r3204 373697b - H.264/MPEG-4 AVC codec - Copyleft 2003-2025 - 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
[mp4 @ 000002ec6b4bf640] Could not find tag for codec h264 in stream #0, codec not currently supported in container
[out#0/mp4 @ 000002ec6b12ed80] Could not write header (incorrect codec parameters ?): Invalid argument
[vf#0:0 @ 000002ec6b090a00] Error sending frames to consumers: Invalid argument
[vf#0:0 @ 000002ec6b090a00] Task finished with error code: -22 (Invalid argument)
[vf#0:0 @ 000002ec6b090a00] Terminating thread with return code -22 (Invalid argument)
[out#0/mp4 @ 000002ec6b12ed80] Nothing was written into output file, because at least one of its streams received no packets.
frame= 0 fps=0.0 q=0.0 Lsize= 0KiB time=N/A bitrate=N/A speed=N/A
[aac @ 000002ec6b4a2740] Qavg: 881.829
What do you suggestions?
Read more here: Source link
