Answers.Body: <p><a href="https://developer.android.com/media/platform/supported-formats" rel="nofollow noreferrer">Supported media formats</a> mentions a baseline profile, the ffmpeg encode command should have</p>
  <pre><code>-c:v libx264 -crf 23 -profile:v baseline -level 3.0 -pix_fmt yuv420p
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2024-07-07T02:14:42.260Z
Answers.LastActivityDate: 2024-07-07T02:14:42.260Z
Answers.UserDisplayName: xer-rex
Answers.Body: <p>The main problem is in the <strong>profile</strong> (which limits the set of compressing algorithm). You didn't use the <code>-profile</code> option, so the (default) x264 encoder automatically selects one for you.</p>
  <p>In your case, this automatically selected profile is not appropriate for your device, because it obviously <em>enables enhanced compression algorithms for which there is no appropriate decoder</em> in your (maybe older or modest) device.</p>
  <p>So change this option to the simplest one: <code>-profile:v baseline</code>. After a successful result, you may try the more advanced profile: <code>-profile:v main</code> to obtain a smaller-sized output.</p>
  <p>Next, change your <strong>preset</strong> from <code>ultrafast</code> (which produces a very large output file — possibly another difficulty for your slower device, because it may require <em>higher speed for decoding frames</em>) to something more appropriate —  as <code>medium</code> (which is the default one, so you may omit your <code>-preset ultrafast</code> option) or <code>slow</code>.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2024-12-05T17:43:18.330Z
Answers.LastActivityDate: 2024-12-06T09:49:08.640Z
Answers.LastEditDate: 2024-12-06T09:49:08.640Z
Answers.UserDisplayName: MarianD
Answers.Body: <p>please, try:</p>
  <pre><code>ffmpeg -loglevel quiet -input_format mjpeg -i &quot;$1&quot; -c:v libx264 -preset ultrafast -profile:v main -pix_fmt yuv420p -movflags +faststart video.mp4
  </code></pre>
  <p>explanation:</p>
  <p><strong>&quot;$1&quot;</strong> - the use of quotation marks to better handle whitespace in directory names and paths.</p>
  <p><strong>-c:v libx264</strong> - to force the use of x264.</p>
  <p><strong>-profile:v main</strong> - to force compatibility with Android 6 or higher according to documentation provided by xer-rex</p>
  <p><strong>-pix_fmt yuv420p</strong> - to force the 8-bit color standard accepted on most devices.</p>
  <p><strong>-movflags +faststart</strong> - to move muxer information to the beginning of the file and thus allow &quot;instant&quot; execution in web scenarios.</p>
  <p>see: <a href="https://trac.ffmpeg.org/wiki/Encode/H.264" rel="nofollow noreferrer">ffmeg/h.264</a> <a href="https://jellyfin.org/docs/general/clients/codec-support" rel="nofollow noreferrer">jellyfin/codec-support</a> <a href="https://developer.android.com/media/platform/supported-formats" rel="nofollow noreferrer">android/supported-formats</a></p>
  <p>_o/</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2024-07-08T02:33:32.847Z
Answers.LastActivityDate: 2024-07-08T02:33:32.847Z
Answers.UserDisplayName: ofernandofilo
Body: <p>I am facing a problem which seems to be a common one; my recorded videos using ffmpeg on raspbian is not playable in any mobile browser (android and iphone).</p>
  <pre><code>ffmpeg -loglevel quiet -input_format mjpeg -i $1 -preset ultrafast video.mp4
  </code></pre>
  <ul>
  <li>$1 is /dev/video0</li>
  </ul>
  <p>The output of ffprobe of the recorded video is:</p>
  <pre><code>ffprobe version 6.0-full_build-www.gyan.dev Copyright (c) 2007-2023 the FFmpeg developers
    built with gcc 12.2.0 (Rev10, Built by MSYS2 project)
    configuration: --enable-gpl --enable-version3 --enable-static --disable-w32threads --disable-autodetect --enable-fontconfig --enable-iconv --enable-gnutls --enable-libxml2 --enable-gmp --enable-bzlib --enable-lzma --enable-libsnappy --enable-zlib --enable-librist --enable-libsrt --enable-libssh --enable-libzmq --enable-avisynth --enable-libbluray --enable-libcaca --enable-sdl2 --enable-libaribb24 --enable-libdav1d --enable-libdavs2 --enable-libuavs3d --enable-libzvbi --enable-librav1e --enable-libsvtav1 --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxavs2 --enable-libxvid --enable-libaom --enable-libjxl --enable-libopenjpeg --enable-libvpx --enable-mediafoundation --enable-libass --enable-frei0r --enable-libfreetype --enable-libfribidi --enable-liblensfun --enable-libvidstab --enable-libvmaf --enable-libzimg --enable-amf --enable-cuda-llvm --enable-cuvid --enable-ffnvcodec --enable-nvdec --enable-nvenc --enable-d3d11va --enable-dxva2 --enable-libvpl --enable-libshaderc --enable-vulkan --enable-libplacebo --enable-opencl --enable-libcdio --enable-libgme --enable-libmodplug --enable-libopenmpt --enable-libopencore-amrwb --enable-libmp3lame --enable-libshine --enable-libtheora --enable-libtwolame --enable-libvo-amrwbenc --enable-libilbc --enable-libgsm --enable-libopencore-amrnb --enable-libopus --enable-libspeex --enable-libvorbis --enable-ladspa --enable-libbs2b --enable-libflite --enable-libmysofa --enable-librubberband --enable-libsoxr --enable-chromaprint
    libavutil      58.  2.100 / 58.  2.100
    libavcodec     60.  3.100 / 60.  3.100
    libavformat    60.  3.100 / 60.  3.100
    libavdevice    60.  1.100 / 60.  1.100
    libavfilter     9.  3.100 /  9.  3.100
    libswscale      7.  1.100 /  7.  1.100
    libswresample   4. 10.100 /  4. 10.100
    libpostproc    57.  1.100 / 57.  1.100
  Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '..\videos\1_1.mp4':
    Metadata:
      major_brand     : isom
      minor_version   : 512
      compatible_brands: isomiso2avc1mp41
      encoder         : Lavf59.5.100
    Duration: 00:00:36.10, start: 0.016016, bitrate: 11896 kb/s
    Stream #0:0[0x1](und): Video: h264 (High 4:2:2) (avc1 / 0x31637661), yuvj422p(pc, bt470bg/unknown/unknown, progressive), 1920x1080, 11894 kb/s, 60 fps, 60 tbr, 15360 tbn (default)
      Metadata:
        handler_name    : VideoHandler
        vendor_id       : [0][0][0][0]
  </code></pre>
  <p>I have already tried multiple possible solutions like pix_fmt etc but it didnt work. The device under /dev/video0 deliveres mjpeg.</p>
  <p>Thank you very much in advance!</p>
  
Tags: <ffmpeg>
Title: FFMPEG recorded video not playable in browser on mobile phone (Android/iPhone)
UserDisplayName: scdev
ThreadText: # FFMPEG recorded video not playable in browser on mobile phone (Android/iPhone)
  
  (Asked by: username_0 on 2024-07-01)
  
  I am facing a problem which seems to be a common one; my recorded videos using ffmpeg on raspbian is not playable in any mobile browser (android and iphone).
  
  ```
  ffmpeg -loglevel quiet -input_format mjpeg -i $1 -preset ultrafast video.mp4
  
  ```
  
  * $1 is /dev/video0
  
  The output of ffprobe of the recorded video is:
  
  ```
  ffprobe version 6.0-full_build-www.gyan.dev Copyright (c) 2007-2023 the FFmpeg developers
    built with gcc 12.2.0 (Rev10, Built by MSYS2 project)
    configuration: --enable-gpl --enable-version3 --enable-static --disable-w32threads --disable-autodetect --enable-fontconfig --enable-iconv --enable-gnutls --enable-libxml2 --enable-gmp --enable-bzlib --enable-lzma --enable-libsnappy --enable-zlib --enable-librist --enable-libsrt --enable-libssh --enable-libzmq --enable-avisynth --enable-libbluray --enable-libcaca --enable-sdl2 --enable-libaribb24 --enable-libdav1d --enable-libdavs2 --enable-libuavs3d --enable-libzvbi --enable-librav1e --enable-libsvtav1 --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxavs2 --enable-libxvid --enable-libaom --enable-libjxl --enable-libopenjpeg --enable-libvpx --enable-mediafoundation --enable-libass --enable-frei0r --enable-libfreetype --enable-libfribidi --enable-liblensfun --enable-libvidstab --enable-libvmaf --enable-libzimg --enable-amf --enable-cuda-llvm --enable-cuvid --enable-ffnvcodec --enable-nvdec --enable-nvenc --enable-d3d11va --enable-dxva2 --enable-libvpl --enable-libshaderc --enable-vulkan --enable-libplacebo --enable-opencl --enable-libcdio --enable-libgme --enable-libmodplug --enable-libopenmpt --enable-libopencore-amrwb --enable-libmp3lame --enable-libshine --enable-libtheora --enable-libtwolame --enable-libvo-amrwbenc --enable-libilbc --enable-libgsm --enable-libopencore-amrnb --enable-libopus --enable-libspeex --enable-libvorbis --enable-ladspa --enable-libbs2b --enable-libflite --enable-libmysofa --enable-librubberband --enable-libsoxr --enable-chromaprint
    libavutil      58.  2.100 / 58.  2.100
    libavcodec     60.  3.100 / 60.  3.100
    libavformat    60.  3.100 / 60.  3.100
    libavdevice    60.  1.100 / 60.  1.100
    libavfilter     9.  3.100 /  9.  3.100
    libswscale      7.  1.100 /  7.  1.100
    libswresample   4. 10.100 /  4. 10.100
    libpostproc    57.  1.100 / 57.  1.100
  Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '..\videos\1_1.mp4':
    Metadata:
      major_brand     : isom
      minor_version   : 512
      compatible_brands: isomiso2avc1mp41
      encoder         : Lavf59.5.100
    Duration: 00:00:36.10, start: 0.016016, bitrate: 11896 kb/s
    Stream #0:0[0x1](und): Video: h264 (High 4:2:2) (avc1 / 0x31637661), yuvj422p(pc, bt470bg/unknown/unknown, progressive), 1920x1080, 11894 kb/s, 60 fps, 60 tbr, 15360 tbn (default)
      Metadata:
        handler_name    : VideoHandler
        vendor_id       : [0][0][0][0]
  
  ```
  
  I have already tried multiple possible solutions like pix\_fmt etc but it didnt work. The device under /dev/video0 deliveres mjpeg.
  
  Thank you very much in advance!
  
  **Tags:** ffmpeg
  
  
  ---
  
  ## 3 answers
  
  ### Answer by username_1 on 2024-07-07. Score: 0
  
  [Supported media formats](https://developer.android.com/media/platform/supported-formats) mentions a baseline profile, the ffmpeg encode command should have
  
  ```
  -c:v libx264 -crf 23 -profile:v baseline -level 3.0 -pix_fmt yuv420p
  
  ```
  
  
  ---
  
  ### Answer by username_2 on 2024-12-05. Score: 0
  
  The main problem is in the **profile** (which limits the set of compressing algorithm). You didn't use the `-profile` option, so the (default) x264 encoder automatically selects one for you.
  
  In your case, this automatically selected profile is not appropriate for your device, because it obviously *enables enhanced compression algorithms for which there is no appropriate decoder* in your (maybe older or modest) device.
  
  So change this option to the simplest one: `-profile:v baseline`. After a successful result, you may try the more advanced profile: `-profile:v main` to obtain a smaller-sized output.
  
  Next, change your **preset** from `ultrafast` (which produces a very large output file — possibly another difficulty for your slower device, because it may require *higher speed for decoding frames*) to something more appropriate — as `medium` (which is the default one, so you may omit your `-preset ultrafast` option) or `slow`.
  
  
  ---
  
  ### Answer by username_3 on 2024-07-08. Score: 0
  
  please, try:
  
  ```
  ffmpeg -loglevel quiet -input_format mjpeg -i "$1" -c:v libx264 -preset ultrafast -profile:v main -pix_fmt yuv420p -movflags +faststart video.mp4
  
  ```
  
  explanation:
  
  **"$1"** - the use of quotation marks to better handle whitespace in directory names and paths.
  
  **-c:v libx264** - to force the use of x264.
  
  **-profile:v main** - to force compatibility with Android 6 or higher according to documentation provided by username_1
  
  **-pix\_fmt yuv420p** - to force the 8-bit color standard accepted on most devices.
  
  **-movflags +faststart** - to move muxer information to the beginning of the file and thus allow "instant" execution in web scenarios.
  
  see: [ffmeg/h.264](https://trac.ffmpeg.org/wiki/Encode/H.264) [jellyfin/codec-support](https://jellyfin.org/docs/general/clients/codec-support) [android/supported-formats](https://developer.android.com/media/platform/supported-formats)
  
  \_o/
  
  
  ---
  
  