0

I'm trying to convert an mp4 file into y4m to use with Chrome as a webrtc fake device. (using --use-file-for-fake-video-capture=path/to/file.y4m as described in https://webrtc.org/testing/)

I'm using

ffmpeg -i myfile.mp4 -pix_fmt yuv420p myfile.y4m

and the video conversion does work, but the resulting file has no audio stream. Here's the full output of ffmpeg:

ffmpeg version 4.1 Copyright (c) 2000-2018 the FFmpeg developers
  built with Apple LLVM version 10.0.0 (clang-1000.11.45.5)
  configuration: --prefix=/usr/local/Cellar/ffmpeg/4.1 --enable-shared --enable-pthreads --enable-version3 --enable-hardcoded-tables --enable-avresample --cc=clang --host-cflags= --host-ldflags= --enable-ffplay --enable-gpl --enable-libmp3lame --enable-libopus --enable-libsnappy --enable-libtheora --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libx265 --enable-libxvid --enable-lzma --enable-opencl --enable-videotoolbox
  libavutil      56. 22.100 / 56. 22.100
  libavcodec     58. 35.100 / 58. 35.100
  libavformat    58. 20.100 / 58. 20.100
  libavdevice    58.  5.100 / 58.  5.100
  libavfilter     7. 40.101 /  7. 40.101
  libavresample   4.  0.  0 /  4.  0.  0
  libswscale      5.  3.100 /  5.  3.100
  libswresample   3.  3.100 /  3.  3.100
  libpostproc    55.  3.100 / 55.  3.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'myfile.mp4':
  Metadata:
    major_brand     : mp42
    minor_version   : 0
    compatible_brands: mp41isom
  Duration: 00:00:19.73, start: 0.000000, bitrate: 542 kb/s
    Stream #0:0(und): Video: h264 (Constrained Baseline) (avc1 / 0x31637661), yuv420p, 640x480, 342 kb/s, 29.97 fps, 29.97 tbr, 29970 tbn, 59940 tbc (default)
    Metadata:
      handler_name    : VideoHandler
      encoder         : AVC Coding
    Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 195 kb/s (default)
    Metadata:
      handler_name    : SoundHandler
File 'myfile.y4m' already exists. Overwrite ? [y/N] y
Stream mapping:
  Stream #0:0 -> #0:0 (h264 (native) -> wrapped_avframe (native))
Press [q] to stop, [?] for help
Output #0, yuv4mpegpipe, to 'myfile.y4m':
  Metadata:
    major_brand     : mp42
    minor_version   : 0
    compatible_brands: mp41isom
    encoder         : Lavf58.20.100
    Stream #0:0(und): Video: wrapped_avframe, yuv420p, 640x480, q=2-31, 200 kb/s, 29.97 fps, 29.97 tbn, 29.97 tbc (default)
    Metadata:
      handler_name    : VideoHandler
      encoder         : Lavc58.35.100 wrapped_avframe
frame=  593 fps=0.0 q=-0.0 Lsize=  266854kB time=00:00:19.78 bitrate=110482.9kbits/s speed=  30x    
video:310kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 85871.289062%

Looks like I'm missing some option to map the audio stream or some step to add the audio stream back to the y4m file but after trying several switches I'm still not able to get this working.

Does anybody have any suggestions on how to make this work?

  • 1
    You can't. YUV4MPEG is a video-only single-stream container. – Gyan Dec 2 '18 at 12:23
  • I think this is a typical [XY problem])(xyproblem.info) – perhaps you can explain more about the "fake device" and what kind of input it requires. – slhck Dec 2 '18 at 15:07
  • Thanks @Gyan, that's probably why. I didn't know about this. Using other y4m files it "looked like" chrome was producing sound (and I assumed that was contained in the y4m file which is probably wrong). – user2987504 Dec 3 '18 at 15:51
  • @slhck I've updated the "fake device" information; it's basically a chrome flag that allows you to use a recording instead of a real webcam for webrtc tests. – user2987504 Dec 3 '18 at 15:51
  • You need a separate WAV file for audio. See cs.chromium.org/chromium/src/media/base/… – Gyan Dec 3 '18 at 15:54

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Browse other questions tagged or ask your own question.