2 votes

Comment convertir un fichier vidéo .raw en .avi en utilisant ffmpeg ?

mediainfo sur le fichier donne la sortie suivante -

General
Complete name                            : 0x5C3C6393.raw
Format                                   : AVC
Format/Info                              : Advanced Video Codec
File size                                : 91.7 MiB

Video
Format                                   : AVC
Format/Info                              : Advanced Video Codec
Format profile                           : Main@L3.1
Format settings, CABAC                   : Yes
Format settings, ReFrames                : 1 frame
Format settings, GOP                     : M=1, N=15
Width                                    : 800 pixels
Height                                   : 600 pixels
Display aspect ratio                     : 4:3
Color space                              : YUV
Chroma subsampling                       : 4:2:0
Bit depth                                : 8 bits
Scan type                                : Progressive
Color range                              : Full
Color primaries                          : BT.709
Transfer characteristics                 : BT.709
Matrix coefficients                      : BT.709

J'ai essayé ffmpeg -f rawvideo -pixel_format yuv420p -video_size 800x600 -framerate 15 -i 0x5C3C6393.raw test.avi mais ça ne marche pas. Sortie de cette commande -

ffmpeg version 2.8.15-0ubuntu0.16.04.1 Copyright (c) 2000-2018 the FFmpeg developers
  built with gcc 5.4.0 (Ubuntu 5.4.0-6ubuntu1~16.04.10) 20160609
  configuration: --prefix=/usr --extra-version=0ubuntu0.16.04.1 --build-suffix=-ffmpeg --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --cc=cc --cxx=g++ --enable-gpl --enable-shared --disable-stripping --disable-decoder=libopenjpeg --disable-decoder=libschroedinger --enable-avresample --enable-avisynth --enable-gnutls --enable-ladspa --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libmodplug --enable-libmp3lame --enable-libopenjpeg --enable-libopus --enable-libpulse --enable-librtmp --enable-libschroedinger --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx265 --enable-libxvid --enable-libzvbi --enable-openal --enable-opengl --enable-x11grab --enable-libdc1394 --enable-libiec61883 --enable-libzmq --enable-frei0r --enable-libx264 --enable-libopencv
  libavutil      54. 31.100 / 54. 31.100
  libavcodec     56. 60.100 / 56. 60.100
  libavformat    56. 40.101 / 56. 40.101
  libavdevice    56.  4.100 / 56.  4.100
  libavfilter     5. 40.101 /  5. 40.101
  libavresample   2.  1.  0 /  2.  1.  0
  libswscale      3.  1.101 /  3.  1.101
  libswresample   1.  2.101 /  1.  2.101
  libpostproc    53.  3.100 / 53.  3.100
[rawvideo @ 0x819e00] Estimating duration from bitrate, this may be inaccurate
Input #0, rawvideo, from '0x5C3C6393.raw':
  Duration: 00:00:08.93, start: 0.000000, bitrate: 86129 kb/s
    Stream #0:0: Video: rawvideo (I420 / 0x30323449), yuv420p, 800x600, 86400 kb/s, 15 tbr, 15 tbn, 15 tbc
Output #0, avi, to 'test.avi':
  Metadata:
    ISFT            : Lavf56.40.101
    Stream #0:0: Video: mpeg4 (FMP4 / 0x34504D46), yuv420p, 800x600, q=2-31, 200 kb/s, 15 fps, 15 tbn, 15 tbc
    Metadata:
      encoder         : Lavc56.60.100 mpeg4
Stream mapping:
  Stream #0:0 -> #0:0 (rawvideo (native) -> mpeg4 (native))
Press [q] to stop, [?] for help
[rawvideo @ 0x8236c0] Invalid buffer size, packet size 417540 < expected frame_size 720000
Error while decoding stream #0:0: Invalid argument
frame=  133 fps=0.0 q=24.8 Lsize=   31118kB time=00:00:08.86 bitrate=28750.0kbits/s
video:31109kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.028070%

Sortie de ffmpeg -i 0x5C3C6393.raw -c copy output.mp4 -

ffmpeg version 2.8.15-0ubuntu0.16.04.1 Copyright (c) 2000-2018 the FFmpeg developers
  built with gcc 5.4.0 (Ubuntu 5.4.0-6ubuntu1~16.04.10) 20160609
  configuration: --prefix=/usr --extra-version=0ubuntu0.16.04.1 --build-suffix=-ffmpeg --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --cc=cc --cxx=g++ --enable-gpl --enable-shared --disable-stripping --disable-decoder=libopenjpeg --disable-decoder=libschroedinger --enable-avresample --enable-avisynth --enable-gnutls --enable-ladspa --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libmodplug --enable-libmp3lame --enable-libopenjpeg --enable-libopus --enable-libpulse --enable-librtmp --enable-libschroedinger --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx265 --enable-libxvid --enable-libzvbi --enable-openal --enable-opengl --enable-x11grab --enable-libdc1394 --enable-libiec61883 --enable-libzmq --enable-frei0r --enable-libx264 --enable-libopencv
  libavutil      54. 31.100 / 54. 31.100
  libavcodec     56. 60.100 / 56. 60.100
  libavformat    56. 40.101 / 56. 40.101
  libavdevice    56.  4.100 / 56.  4.100
  libavfilter     5. 40.101 /  5. 40.101
  libavresample   2.  1.  0 /  2.  1.  0
  libswscale      3.  1.101 /  3.  1.101
  libswresample   1.  2.101 /  1.  2.101
  libpostproc    53.  3.100 / 53.  3.100
[image2 @ 0xdf4de0] Format image2 detected only with low score of 5, misdetection possible!
[rawvideo @ 0xdf6200] Invalid pixel format.
[image2 @ 0xdf4de0] Failed to open codec in av_find_stream_info
[rawvideo @ 0xdf6200] Invalid pixel format.
[image2 @ 0xdf4de0] Could not find codec parameters for stream 0 (Video: rawvideo, none): unspecified size
Consider increasing the value for the 'analyzeduration' and 'probesize' options
0x5C3C6393.raw: could not find codec parameters
Input #0, image2, from '0x5C3C6393.raw':
  Duration: 00:00:00.04, start: 0.000000, bitrate: N/A
    Stream #0:0: Video: rawvideo, none, 25 tbr, 25 tbn, 25 tbc
[mp4 @ 0xdf6f00] dimensions not set
Output #0, mp4, to 'output.mp4':
    Stream #0:0: Video: rawvideo, none, q=2-31, 25 tbr, 25 tbn, 25 tbc
Stream mapping:
  Stream #0:0 -> #0:0 (copy)
Could not write header for output file #0 (incorrect codec parameters ?): Invalid argument

Mise à jour -

Après avoir mis à jour ffmpeg comme @slhck l'a suggéré et essayé la commande comme suggéré par @Gyan (légèrement modifié), ffmpeg -f h264 -r 15 -i 0x5C3C3031.raw -c copy output_3031.avi J'obtiens de bonnes vidéos avi. Cependant, la durée de la sortie est un peu inférieure à la durée attendue. La vidéo originale aurait dû durer 10:54, mais la sortie ici est de 9:54. J'ai spécifié une fréquence d'images de 15 (je compare les temps avec les vidéos converties par l'outil officiel fourni et ces vidéos ont 15 fps). De plus, sur un autre fichier plus grand que j'ai essayé, la sortie aurait dû être de 59:53 mais elle était de 57:41. Voici la sortie de la commande ffmpeg -f h264 -r 15 -i 0x5C3C3031.raw -c copy output_3031.avi -

ffmpeg version N-48102-g7cab5471b2-static https://johnvansickle.com/ffmpeg/  Copyright (c) 2000-2019 the FFmpeg developers
  built with gcc 6.3.0 (Debian 6.3.0-18+deb9u1) 20170516
  configuration: --enable-gpl --enable-version3 --enable-static --disable-debug --disable-ffplay --disable-indev=sndio --disable-outdev=sndio --cc=gcc-6 --enable-fontconfig --enable-frei0r --enable-gnutls --enable-gmp --enable-gray --enable-libaom --enable-libfribidi --enable-libass --enable-libvmaf --enable-libfreetype --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-librubberband --enable-libsoxr --enable-libspeex --enable-libvorbis --enable-libopus --enable-libtheora --enable-libvidstab --enable-libvo-amrwbenc --enable-libvpx --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxml2 --enable-libdav1d --enable-libxvid --enable-libzvbi --enable-libzimg
  libavutil      56. 26.100 / 56. 26.100
  libavcodec     58. 46.100 / 58. 46.100
  libavformat    58. 26.100 / 58. 26.100
  libavdevice    58.  6.101 / 58.  6.101
  libavfilter     7. 48.100 /  7. 48.100
  libswscale      5.  4.100 /  5.  4.100
  libswresample   3.  4.100 /  3.  4.100
  libpostproc    55.  4.100 / 55.  4.100
[h264 @ 0x5ca2540] non-existing PPS 0 referenced
[AVBSFContext @ 0x5cc0440] Invalid NAL unit 0, skipping.
    Last message repeated 3 times
[h264 @ 0x5ca2540] Invalid NAL unit 0, skipping.
    Last message repeated 3 times
[h264 @ 0x5ca2540] non-existing PPS 0 referenced
[h264 @ 0x5ca2540] decode_slice_header error
[h264 @ 0x5ca2540] no frame!
[h264 @ 0x5ca2540] non-existing PPS 0 referenced
[AVBSFContext @ 0x5cc0440] Invalid NAL unit 0, skipping.
    Last message repeated 2 times
[h264 @ 0x5ca2540] Invalid NAL unit 0, skipping.
    Last message repeated 2 times
[h264 @ 0x5ca2540] non-existing PPS 0 referenced
[h264 @ 0x5ca2540] decode_slice_header error
[h264 @ 0x5ca2540] no frame!
[h264 @ 0x5ca2540] non-existing PPS 0 referenced
[AVBSFContext @ 0x5cc0440] Invalid NAL unit 0, skipping.
    Last message repeated 3 times
[h264 @ 0x5ca2540] Invalid NAL unit 0, skipping.
    Last message repeated 3 times
[h264 @ 0x5ca2540] non-existing PPS 0 referenced
[h264 @ 0x5ca2540] decode_slice_header error
[h264 @ 0x5ca2540] no frame!
[h264 @ 0x5ca2540] non-existing PPS 0 referenced
[AVBSFContext @ 0x5cc0440] Invalid NAL unit 0, skipping.
    Last message repeated 2 times
[h264 @ 0x5ca2540] Invalid NAL unit 0, skipping.
    Last message repeated 2 times
[h264 @ 0x5ca2540] non-existing PPS 0 referenced
[h264 @ 0x5ca2540] decode_slice_header error
[h264 @ 0x5ca2540] no frame!
[h264 @ 0x5ca2540] non-existing PPS 0 referenced
[AVBSFContext @ 0x5cc0440] Invalid NAL unit 0, skipping.
    Last message repeated 2 times
[h264 @ 0x5ca2540] Invalid NAL unit 0, skipping.
    Last message repeated 2 times
[h264 @ 0x5ca2540] non-existing PPS 0 referenced
[h264 @ 0x5ca2540] decode_slice_header error
[h264 @ 0x5ca2540] A non-intra slice in an IDR NAL unit.
[h264 @ 0x5ca2540] decode_slice_header error
[h264 @ 0x5ca2540] no frame!
[h264 @ 0x5ca2540] non-existing PPS 0 referenced
[AVBSFContext @ 0x5cc0440] Invalid NAL unit 0, skipping.
    Last message repeated 1 times
[AVBSFContext @ 0x5cc0440] Invalid NAL unit 5, skipping.
[AVBSFContext @ 0x5cc0440] Invalid NAL unit 0, skipping.
[h264 @ 0x5ca2540] Invalid NAL unit 0, skipping.
    Last message repeated 1 times
[h264 @ 0x5ca2540] Invalid NAL unit 5, skipping.
[h264 @ 0x5ca2540] Invalid NAL unit 0, skipping.
[h264 @ 0x5ca2540] non-existing PPS 0 referenced
[h264 @ 0x5ca2540] decode_slice_header error
[h264 @ 0x5ca2540] no frame!
[h264 @ 0x5ca2540] non-existing PPS 0 referenced
[AVBSFContext @ 0x5cc0440] Invalid NAL unit 0, skipping.
    Last message repeated 2 times
[h264 @ 0x5ca2540] Invalid NAL unit 0, skipping.
    Last message repeated 2 times
[h264 @ 0x5ca2540] non-existing PPS 0 referenced
[h264 @ 0x5ca2540] decode_slice_header error
[h264 @ 0x5ca2540] no frame!
[h264 @ 0x5ca2540] non-existing PPS 0 referenced
[AVBSFContext @ 0x5cc0440] Invalid NAL unit 0, skipping.
    Last message repeated 2 times
[h264 @ 0x5ca2540] Invalid NAL unit 0, skipping.
    Last message repeated 2 times
[h264 @ 0x5ca2540] non-existing PPS 0 referenced
[h264 @ 0x5ca2540] decode_slice_header error
[h264 @ 0x5ca2540] no frame!
[h264 @ 0x5ca2540] non-existing PPS 0 referenced
[AVBSFContext @ 0x5cc0440] Invalid NAL unit 0, skipping.
    Last message repeated 2 times
[h264 @ 0x5ca2540] Invalid NAL unit 0, skipping.
    Last message repeated 2 times
[h264 @ 0x5ca2540] non-existing PPS 0 referenced
[h264 @ 0x5ca2540] decode_slice_header error
[h264 @ 0x5ca2540] no frame!
[h264 @ 0x5ca2540] non-existing PPS 0 referenced
[AVBSFContext @ 0x5cc0440] Invalid NAL unit 0, skipping.
    Last message repeated 2 times
[h264 @ 0x5ca2540] Invalid NAL unit 0, skipping.
    Last message repeated 2 times
[h264 @ 0x5ca2540] non-existing PPS 0 referenced
[h264 @ 0x5ca2540] decode_slice_header error
[h264 @ 0x5ca2540] no frame!
[AVBSFContext @ 0x5cc0440] Invalid NAL unit 0, skipping.
    Last message repeated 2 times
[h264 @ 0x5ca2540] Invalid NAL unit 0, skipping.
    Last message repeated 2 times
[h264 @ 0x5ca2540] Invalid NAL unit 8, skipping.
[h264 @ 0x5ca2540] Invalid NAL unit 5, skipping.
[h264 @ 0x5ca2540] Invalid NAL unit 0, skipping.
    Last message repeated 17 times
Input #0, h264, from '0x5C3C3031.raw':
  Duration: N/A, bitrate: N/A
    Stream #0:0: Video: h264 (Main), yuvj420p(pc, bt709, progressive), 800x600, 15 fps, 15 tbr, 1200k tbn, 30 tbc
Output #0, avi, to 'output_3031.avi':
  Metadata:
    ISFT            : Lavf58.26.100
    Stream #0:0: Video: h264 (Main) (H264 / 0x34363248), yuvj420p(pc, bt709, progressive), 800x600, q=2-31, 15 fps, 15 tbr, 15 tbn, 15 tbc
Stream mapping:
  Stream #0:0 -> #0:0 (copy)
Press [q] to stop, [?] for help
[avi @ 0x5cca640] Timestamps are unset in a packet for stream 0. This is deprecated and will stop working in the future. Fix your code to set the timestamps properly
Invalid UE golomb code-1.0 size=  206854kB time=00:22:02.26 bitrate=1281.5kbits/s speed=2.64e+03x
[NULL @ 0x5ca2540] pps_id 3199971767 out of range
[NULL @ 0x5ca2540] illegal POC type 6
[NULL @ 0x5ca2540] SEI type 156 size 488 truncated at 2480.40 bitrate=1281.2kbits/s speed=2.64e+03x
frame=51906 fps=39449 q=-1.0 Lsize=  543722kB time=00:57:41.06 bitrate=1286.9kbits/s speed=2.63e+03x
video:542474kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.229998%

1voto

Ce n'est pas brut. C'est AVC, c'est-à-dire H.264 Annexe B. On dirait que c'est l'annexe B, parce que de ce https://stackoverflow.com/questions/51353973/what-is-different-between-h-265-hevc-in-a-containermp4-mkv-and-h-265-hevc vous pouvez voir qu'il insère 0x000001 qui peut être reconnu comme NAL unit 0, pour décoder cela en avc classique vous devez utiliser non pas ffmpeg car il n'a que h264_mp4toannexb et pas de h264_annexbtomp4, mais il y en a un ici https://github.com/ireader/media-server/commit/76e62c806aaa5e1f97c626a52df0b03c2b2b47b1 Numéro de l'annexe B ici https://trac.ffmpeg.org/ticket/8781

De plus, la version 2.8.15 de ffmpeg est si vieille, c'est juste fou.

SistemesEz.com

SystemesEZ est une communauté de sysadmins où vous pouvez résoudre vos problèmes et vos doutes. Vous pouvez consulter les questions des autres sysadmins, poser vos propres questions ou résoudre celles des autres.

Powered by:

X