Capturing audio and video from different sources, how to sync? - ffmpeg

Here is my code:
Lapaki:~ Lapaki$ /Users/Lapaki/Desktop/ffmpeg -f avfoundation -video_size 960x540 -pixel_format uyvy422 -framerate ntsc -thread_queue_size 8B -i "XI:none" -f avfoundation -thread_queue_size 8B -i "none:XI" -vf 'crop=iw-240:ih:120:0' -af 'asetpts=PTS+.58735/TB' -pix_fmt yuv420p -aspect 4:3 -s 720x480 -q:v 3 -maxrate 5000k -bufsize 2000k -acodec ac3 -ac 2 -ab 256k -ar 48000 -f dvd /Users/Lapaki/Desktop/FF\ Test/`date +%F`\ `date +%H_%M_%S`.mpg
ffmpeg version 3.2.3-tessus Copyright (c) 2000-2017 the FFmpeg developers
built with Apple LLVM version 8.0.0 (clang-800.0.42.1)
configuration: --cc=/usr/bin/clang --prefix=/opt/ffmpeg --extra-version=tessus --enable-avisynth --enable-fontconfig --enable-gpl --enable-libass --enable-libbluray --enable-libfreetype --enable-libgsm --enable-libmodplug --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopus --enable-libschroedinger --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libtheora --enable-libvidstab --enable-libvo-amrwbenc --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libx264 --enable-libx265 --enable-libxavs --enable-libxvid --enable-libzmq --enable-version3 --disable-ffplay --disable-indev=qtkit --disable-indev=x11grab_xcb
libavutil 55. 34.101 / 55. 34.101
libavcodec 57. 64.101 / 57. 64.101
libavformat 57. 56.101 / 57. 56.101
libavdevice 57. 1.100 / 57. 1.100
libavfilter 6. 65.100 / 6. 65.100
libswscale 4. 2.100 / 4. 2.100
libswresample 2. 3.100 / 2. 3.100
libpostproc 54. 1.100 / 54. 1.100
Input #0, avfoundation, from 'XI:none':
Duration: N/A, start: 648413.295900, bitrate: N/A
Stream #0:0: Video: rawvideo (UYVY / 0x59565955), uyvy422, 960x540, 29.97 fps, 29.97 tbr, 1000k tbn, 1000k tbc
Input #1, avfoundation, from 'none:XI':
Duration: N/A, start: 648413.884042, bitrate: 3072 kb/s
Stream #1:0: Audio: pcm_f32le, 48000 Hz, stereo, flt, 3072 kb/s
Output #0, dvd, to '/Users/Lapaki/Desktop/FF Test/2017-02-16 04_16_33.mpg':
Metadata:
encoder : Lavf57.56.101
Stream #0:0: Video: mpeg2video (Main), yuv420p, 720x480 [SAR 8:9 DAR 4:3], q=2-31, 200 kb/s, 29.97 fps, 90k tbn, 29.97 tbc
Metadata:
encoder : Lavc57.64.101 mpeg2video
Side data:
cpb: bitrate max/min/avg: 5000000/0/200000 buffer size: 2000000 vbv_delay: -1
Stream #0:1: Audio: ac3, 48000 Hz, stereo, fltp, 256 kb/s
Metadata:
encoder : Lavc57.64.101 ac3
Stream mapping:
Stream #0:0 -> #0:0 (rawvideo (native) -> mpeg2video (native))
Stream #1:0 -> #0:1 (pcm_f32le (native) -> ac3 (native))
Press [q] to stop, [?] for help
[swscaler # 0x7f8e0c8ab400] Warning: data is not aligned! This can lead to a speedloss
frame= 33 fps=0.0 q=3.0 size= 266kB time=00:00:01.06 bitrate=2051.9kbits/sframe= 49 fps= 48 q=3.0 size= 444kB time=00:00:01.54 bitrate=2358.8kbits/sframe= 64 fps= 42 q=3.0 size= 652kB time=00:00:02.08 bitrate=2560.5kbits/sframe= 79 fps= 39 q=3.0 size= 838kB time=00:00:02.59 bitrate=2642.4kbits/sframe= 94 fps= 37 q=3.0 size= 1022kB time=00:00:03.07 bitrate=2720.0kbits/sframe= 109 fps= 36 q=3.0 size= 1208kB time=00:00:03.59 bitrate=2756.5kbits/sframe= 124 fps= 35 q=3.0 size= 1406kB time=00:00:04.07 bitrate=2830.0kbits/sframe= 127 fps= 35 q=3.0 Lsize= 1474kB time=00:00:04.19 bitrate=2876.4kbits/s dup=12 drop=0 speed=1.15x
video:1310kB audio:113kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 3.604597%
The start of Input #0 is 648413.295900, and the start of Input #1 is 648413.884042.
I've been able to keep the audio and video in very close sync by subtracting the two values (which I assume are wallclock values), and using the asetpts audio filter to delay the audio stream of the recorded mpeg-2 file by that amount.
I'd like to be able to do this exactly though, and that value changes slightly every time I start a new capture. Not to mention, I'd like to be able to do this reliably on different machines, where I assume the value will most likely be different, thus using a calculation as opposed to a fixed number is obviously the best option, if it's possible.
Is there a way to subtract the wallclock start time of input #0 from the wallclock start time of input #1? I'd like to do this inside the asetpts filter, instead of manually finding the difference from a previous run, which again is slightly different every time...
I was thinking something like -af asetpts=PTS-([1:0]RTCSTART-[0:0]RTCSTART)/TB might work, but I have no idea how to format it.
Thanks in advance!

Related

FFmpeg filter complex add audio file to video at specific points

atrim=0:2 starts fine when I play the video it plays the mp3 now how do I add a working end time say finish at 9 seconds?
Summary I want to start at 2 seconds and finish at 9 seconds.
ffmpeg -y -i "C:\Users\test\Desktop\vidz\New folder (2)\target\vaastav song .mp4" -i "C:\Users\test\Desktop\vidz\New folder (2)\target\2.mp3" -filter_complex "[0]atrim=0:2[Apre];[0]atrim=5,asetpts=PTS-STARTPTS[Apost];[Apre][1][Apost]concat=n=3:v=0:a=1" -vcodec copy -y "C:\Users\test\Desktop\vidz\New folder (2)\target\output1.mp4"
log file
ffmpeg version git-2020-04-13-59e3a9a Copyright (c) 2000-2020 the FFmpeg developers
built with gcc 9.3.1 (GCC) 20200328
configuration: --enable-gpl --enable-version3 --enable-sdl2 --enable-fontconfig --enable-gnutls --enable-iconv --enable-libass --enable-libdav1d --enable-libbluray --enable-libfreetype --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libsrt --enable-libtheora --enable-libtwolame --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxml2 --enable-libzimg --enable-lzma --enable-zlib --enable-gmp --enable-libvidstab --enable-libvmaf --enable-libvorbis --enable-libvo-amrwbenc --enable-libmysofa --enable-libspeex --enable-libxvid --enable-libaom --disable-w32threads --enable-libmfx --enable-ffnvcodec --enable-cuda-llvm --enable-cuvid --enable-d3d11va --enable-nvenc --enable-nvdec --enable-dxva2 --enable-avisynth --enable-libopenmpt --enable-amf
libavutil 56. 42.102 / 56. 42.102
libavcodec 58. 78.102 / 58. 78.102
libavformat 58. 42.100 / 58. 42.100
libavdevice 58. 9.103 / 58. 9.103
libavfilter 7. 77.101 / 7. 77.101
libswscale 5. 6.101 / 5. 6.101
libswresample 3. 6.100 / 3. 6.100
libpostproc 55. 6.100 / 55. 6.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'C:\Users\test\Desktop\vidz\New folder (2)\target\vaastav song .mp4':
Metadata:
major_brand : mp42
minor_version : 0
compatible_brands: isommp42
creation_time : 2018-09-02T04:28:46.000000Z
Duration: 00:05:08.80, start: 0.000000, bitrate: 2289 kb/s
Stream #0:0(und): Video: h264 (Main) (avc1 / 0x31637661), yuv420p(tv, bt709), 1280x720 [SAR 1:1 DAR 16:9], 2160 kb/s, 25 fps, 25 tbr, 90k tbn, 50 tbc (default)
Metadata:
creation_time : 2018-09-02T04:28:46.000000Z
handler_name : ISO Media file produced by Google Inc. Created on: 09/01/2018.
Stream #0:1(eng): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 125 kb/s (default)
Metadata:
creation_time : 2018-09-02T04:28:46.000000Z
handler_name : ISO Media file produced by Google Inc. Created on: 09/01/2018.
Input #1, mp3, from 'C:\Users\test\Desktop\vidz\New folder (2)\target\2.mp3':
Metadata:
genre : Electronic;Indie
title : A Distorted Noise With A Little Bit Of Sense
artist : Lenin Was A Zombie
encoder : Lavf56.19.100
major_brand : mp42
minor_version : 0
compatible_brands: isommp42
Duration: 00:00:54.00, start: 0.025057, bitrate: 192 kb/s
Stream #1:0: Audio: mp3, 44100 Hz, stereo, fltp, 192 kb/s
Metadata:
encoder : Lavc56.21
Stream mapping:
Stream #0:1 (aac) -> atrim
Stream #0:1 (aac) -> atrim
Stream #1:0 (mp3float) -> concat:in1:a0
concat -> Stream #0:0 (aac)
Stream #0:0 -> #0:1 (copy)
Press [q] to stop, [?] for help
Output #0, mp4, to 'C:\Users\test\Desktop\vidz\New folder (2)\target\output1.mp4':
Metadata:
major_brand : mp42
minor_version : 0
compatible_brands: isommp42
encoder : Lavf58.42.100
Stream #0:0: Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 128 kb/s (default)
Metadata:
encoder : Lavc58.78.102 aac
Stream #0:1(und): Video: h264 (Main) (avc1 / 0x31637661), yuv420p(tv, bt709), 1280x720 [SAR 1:1 DAR 16:9], q=2-31, 2160 kb/s, 25 fps, 25 tbr, 90k tbn, 90k tbc (default)
Metadata:
creation_time : 2018-09-02T04:28:46.000000Z
handler_name : ISO Media file produced by Google Inc. Created on: 09/01/2018.
frame= 737 fps=0.0 q=-1.0 size= 7936kB time=00:00:29.44 bitrate=2208.1kbits/s speed=58.9x
[out_0_0 # 000000000312c900] 100 buffers queued in out_0_0, something may be wrong.
[out_0_0 # 000000000312c900] 1000 buffers queued in out_0_0, something may be wrong.
frame= 1401 fps=876 q=-1.0 size= 16640kB time=00:01:46.85 bitrate=1275.7kbits/s speed=66.8x
frame= 2281 fps=1086 q=-1.0 size= 26112kB time=00:02:22.01 bitrate=1506.3kbits/s speed=67.6x
frame= 3152 fps=1212 q=-1.0 size= 35584kB time=00:02:56.58 bitrate=1650.8kbits/s speed=67.9x
frame= 4011 fps=1294 q=-1.0 size= 45824kB time=00:03:31.32 bitrate=1776.4kbits/s speed=68.2x
frame= 4882 fps=1356 q=-1.0 size= 56320kB time=00:04:06.03 bitrate=1875.2kbits/s speed=68.3x
frame= 5753 fps=1403 q=-1.0 size= 66560kB time=00:04:40.79 bitrate=1941.8kbits/s speed=68.5x
frame= 6622 fps=1440 q=-1.0 size= 77056kB time=00:05:15.37 bitrate=2001.6kbits/s speed=68.6x
frame= 7482 fps=1467 q=-1.0 size= 85248kB time=00:05:50.20 bitrate=1994.1kbits/s speed=68.7x
frame= 7720 fps=1479 q=-1.0 Lsize= 87248kB time=00:05:59.79 bitrate=1986.5kbits/s speed=68.9x
video:81451kB audio:5634kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.186449%
[aac # 0000000003017ac0] Qavg: 648.065
I tried messing about with the line of code but no success so I turn to you for additional support

ffmpeg is preferring to encode in VP9 but I'm trying to encode in VP8

I'm trying to encode webm video files specifically in VP8, but ffmpeg is forcing VP9. I'm using -c:v libvpx, which to my knowledge is supposed to be VP8, but when it encodes I see it's encoding in VP9 instead:
ffmpeg -framerate 7 -loop 1 -i "C:\converted\cover.jpg" -c:v libvpx
-i "C:\converted\Image.wav" -b:v 50k -c:a libvorbis -b:a 96k
-vf scale=-1:300 -shortest -metadata title="%artist% - %album%"
-metadata author="%artist%" -threads 8 -y "C:\converted\%artist% - %album%.webm"
ffmpeg version N-81489-ga37e6dd Copyright (c) 2000-2016 the FFmpeg developers
built with gcc 5.4.0 (GCC)
configuration: --enable-gpl --enable-version3 --disable-w32threads --enable-dx
va2 --enable-libmfx --enable-nvenc --enable-avisynth --enable-bzlib --enable-lib
ebur128 --enable-fontconfig --enable-frei0r --enable-gnutls --enable-iconv --ena
ble-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libfree
type --enable-libgme --enable-libgsm --enable-libilbc --enable-libmodplug --enab
le-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-lib
openh264 --enable-libopenjpeg --enable-libopus --enable-librtmp --enable-libschr
oedinger --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libtheor
a --enable-libtwolame --enable-libvidstab --enable-libvo-amrwbenc --enable-libvo
rbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --ena
ble-libx265 --enable-libxavs --enable-libxvid --enable-libzimg --enable-lzma --e
nable-decklink --enable-zlib
libavutil 55. 29.100 / 55. 29.100
libavcodec 57. 54.101 / 57. 54.101
libavformat 57. 48.101 / 57. 48.101
libavdevice 57. 0.102 / 57. 0.102
libavfilter 6. 57.100 / 6. 57.100
libswscale 4. 1.100 / 4. 1.100
libswresample 2. 1.100 / 2. 1.100
libpostproc 54. 0.100 / 54. 0.100
Input #0, image2, from 'C:\converted\cover.jpg':
Duration: 00:00:00.14, start: 0.000000, bitrate: 3159 kb/s
Stream #0:0: Video: mjpeg, yuvj420p(pc, bt470bg/unknown/unknown), 500x495 [S
AR 1:1 DAR 100:99], 7 fps, 7 tbr, 7 tbn, 7 tbc
Guessed Channel Layout for Input Stream #1.0 : stereo
Input #1, wav, from 'C:\converted\Image.wav':
Metadata:
artist : ???????
genre : Alternative Rock
title : goodnight, wonderend
date : 2014
Duration: 00:04:48.00, bitrate: 1421 kb/s
Stream #1:0: Audio: pcm_s16le ([1][0][0][0] / 0x0001), 44100 Hz, 2 channels,
s16, 1411 kb/s
[swscaler # 055f7d60] deprecated pixel format used, make sure you did set range
correctly
[libvpx-vp9 # 0312d8e0] v1.6.0
[webm # 0316e380] Using AVStream.codec to pass codec parameters to muxers is dep
recated, use AVStream.codecpar instead.
Last message repeated 1 times
Output #0, webm, to 'C:\converted\カラスヤサボウ - goodnight, wonderend.w
ebm':
Metadata:
title : カラスヤサボウ - goodnight, wonderend
author : カラスヤサボウ
encoder : Lavf57.48.101
Stream #0:0: Video: vp9 (libvpx-vp9), yuv420p, 303x300 [SAR 10000:9999 DAR 1
00:99], q=-1--1, 50 kb/s, 7 fps, 1k tbn, 7 tbc
Metadata:
encoder : Lavc57.54.101 libvpx-vp9
Side data:
cpb: bitrate max/min/avg: 0/0/0 buffer size: 0 vbv_delay: -1
Stream #0:1: Audio: vorbis (libvorbis), 44100 Hz, stereo, fltp, 96 kb/s
Metadata:
encoder : Lavc57.54.101 libvorbis
Stream mapping:
Stream #0:0 -> #0:0 (mjpeg (native) -> vp9 (libvpx-vp9))
Stream #1:0 -> #0:1 (pcm_s16le (native) -> vorbis (libvorbis))
Press [q] to stop, [?] for help
frame= 30 fps=0.0 q=0.0 size= 29kB time=00:00:00.71 bitrate= 333.4kbits/s
frame= 37 fps= 36 q=0.0 size= 49kB time=00:00:01.71 bitrate= 233.6kbits/s
frame= 45 fps= 27 q=0.0 size= 60kB time=00:00:02.85 bitrate= 170.6kbits/s
frame= 53 fps= 23 q=0.0 size= 84kB time=00:00:04.00 bitrate= 172.7kbits/s
frame= 57 fps= 21 q=0.0 size= 102kB time=00:00:04.57 bitrate= 183.5kbits/s
frame= 62 fps= 19 q=0.0 size= 112kB time=00:00:05.28 bitrate= 173.4kbits/s
frame= 64 fps= 12 q=0.0 Lsize= 141kB time=00:00:09.00 bitrate= 128.1kbits/
s speed=1.69x
video:87kB audio:47kB subtitle:0kB other streams:0kB global headers:4kB muxing o
verhead: 4.908199%
Exiting normally, received signal 2.
The build I have does have --enable-libvpx and --enable-libvpx-vp9 flags. It is also the latest default static build, I made no changes, just extracted it: ffmpeg-20160828-a37e6dd-win32-static.zip
I was using an outdated build for a long time and updated today. I can't find any documentation online to help me with this problem.
Option placement matters. You're attempting to apply -c:v libvpx to Image.wav. Move this option so it is before the output name.
You should place the codec option right before your output.
Following is a simple example
$ ffmpeg -f lavfi -i testsrc2=d=5 -vcodec libvpx -f lavfi -i sine=d=5 -acodec libvorbis o.webm
The command above only select the -acodec as libvorbis, and use the default video codec.
The command below will select video codec as libvpx and audio codec as libvorbis
$ ffmpeg -f lavfi -i testsrc2=d=5 -f lavfi -i sine=d=5 -vcodec libvpx -acodec libvorbis o.webm

What is the best way to split a transport stream file?

I have a .ts file (Download files here: http://dropcanvas.com/2gmsg/1).
I want to split this video while I expect ALL other properties remain same including pts time.
Here is what I try to achieve this:
ffmpeg -ss 0.000 -i sample.ts -y -c copy -t 3 splitted.ts
Expected start time: 94678.950389
New start time: 1.402367
I expect the above command should only take first 3 seconds of the .ts file and all other stuff to stay same. I've seen copyts and copytb options from the documentation but I wasn't able to use them.
So how do I do this?
Thank you
Here are the logs for copyts. It creates a 0 byte splitted.ts file:
ffmpeg -ss 0:00:00 -i sample.ts -to 00:00:03 -y -c copy -copyts splitted.ts
ffmpeg version 3.0 Copyright (c) 2000-2016 the FFmpeg developers
built with Apple LLVM version 7.0.0 (clang-700.0.72)
configuration: --prefix=/usr/local/Cellar/ffmpeg/3.0 --enable-shared --enable-pthreads --enable-gpl --enable-version3 --enable-hardcoded-tables --enable-avresample --cc=clang --host-cflags= --host-ldflags= --enable-opencl --enable-libx264 --enable-libmp3lame --enable-libxvid --enable-libfreetype --enable-libvorbis --enable-libvpx --enable-libass --enable-ffplay --enable-libfdk-aac --enable-libopus --enable-libx265 --enable-nonfree --enable-vda
libavutil 55. 17.103 / 55. 17.103
libavcodec 57. 24.102 / 57. 24.102
libavformat 57. 25.100 / 57. 25.100
libavdevice 57. 0.101 / 57. 0.101
libavfilter 6. 31.100 / 6. 31.100
libavresample 3. 0. 0 / 3. 0. 0
libswscale 4. 0.100 / 4. 0.100
libswresample 2. 0.101 / 2. 0.101
libpostproc 54. 0.100 / 54. 0.100
[NULL # 0x7fafac02fc00] start time for stream 2 is not set in estimate_timings_from_pts
Input #0, mpegts, from 'sample.ts':
Duration: 00:00:10.07, start: 94678.950389, bitrate: 934 kb/s
Program 1
Stream #0:0[0x100]: Video: h264 (Main) ([27][0][0][0] / 0x001B), yuv420p, 854x480 [SAR 1280:1281 DAR 16:9], 29.97 fps, 29.97 tbr, 90k tbn, 59.94 tbc
Stream #0:1[0x101]: Audio: aac (LC) ([15][0][0][0] / 0x000F), 44100 Hz, stereo, fltp, 140 kb/s
Stream #0:2[0x102]: Data: timed_id3 (ID3 / 0x20334449)
Output #0, mpegts, to 'splitted.ts':
Metadata:
encoder : Lavf57.25.100
Stream #0:0: Video: h264 ([27][0][0][0] / 0x001B), yuv420p, 854x480 [SAR 1280:1281 DAR 16:9], q=2-31, 29.97 fps, 29.97 tbr, 90k tbn, 90k tbc
Stream #0:1: Audio: aac (LC) ([15][0][0][0] / 0x000F), 44100 Hz, stereo, 140 kb/s
Stream mapping:
Stream #0:0 -> #0:0 (copy)
Stream #0:1 -> #0:1 (copy)
Press [q] to stop, [?] for help
frame= 0 fps=0.0 q=-1.0 Lsize= 0kB time=00:00:00.00 bitrate=N/A speed= 0x
video:0kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: unknown
Output file is empty, nothing was encoded (check -ss / -t / -frames parameters if used)
This works for me
ffmpeg -seek_timestamp 1 -ss 94678.950389 -i sample.ts -y -c copy -copyts -to 94681.950389 -muxdelay 0 splitted.ts
Your original command can work if you use the frames flag.
ffmpeg -ss 0.000 -i sample.ts -y -c copy -copyts -muxdelay 0 -vframes 90 splitted.ts
Where 90 represents amount of frames in t seconds.

FFMPEG Audio and Video Streams merging and restreaming

I have multiple streaming sources that need to combined and re-streamed as a single source.
My sources are:
A local low rate RTP audio stream
A camera
I need to redistribute the combined stream (via UDP multicast) across the local network.
The problem I am seeing is that periodically ffmpeg appears to lock up and stop processing the combination after an indeterminate amount of time (sometimes as little as 15 min sometimes almost an hour). However if I redirect the streams independently (audio or video only) there appears to be no problem and the run indefinitely.
Command
ffmpeg -f rtp -i rtp://127.0.0.1:6666 -f video4linux2 -standard NTSC -s 704x480 -i /dev/video1 -strict experimental -vcodec libx264 -acodec ac3 -preset ultrafast -r 3 -g 3 -keyint_min 6 -x264opts "keyint=6:min-keyint=6:no-scenecut" -b:v 200k -ac 1 -b:a 64k -f mpegts udp://225.1.1.15:30000
Output
ffmpeg version 2.5.1- http://johnvansickle.com/ffmpeg/ Copyright (c) 2000-2014 the FFmpeg developers
built on Dec 18 2014 09:06:26 with gcc 4.8 (Debian 4.8.3-19)
configuration: --enable-gpl --enable-version3 --disable-shared --disable- debug --enable-runtime-cpudetect --enable-libmp3lame --enable-libx264 --enable- libx265 --enable-libwebp --enable-libspeex --enable-libvorbis --enable-libvpx -- enable-libfreetype --enable-fontconfig --enable-libxvid --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libtheora --enable-libvo-aacenc -- enable-libvo-amrwbenc --enable-gray --enable-libopenjpeg --enable-libopus -- disable-ffserver --enable-libass --enable-gnutls --cc=gcc-4.8
libavutil 54. 15.100 / 54. 15.100
libavcodec 56. 13.100 / 56. 13.100
libavformat 56. 15.102 / 56. 15.102
libavdevice 56. 3.100 / 56. 3.100
libavfilter 5. 2.103 / 5. 2.103
libswscale 3. 1.101 / 3. 1.101
libswresample 1. 1.100 / 1. 1.100
libpostproc 53. 3.100 / 53. 3.100
[rtp # 0xb61abe0] Guessing on RTP content - if not received properly you need an SDP file describing it
Guessed Channel Layout for Input Stream #0.0 : mono
Input #0, rtp, from 'rtp://127.0.0.1:6666':
Duration: N/A, start: 0.000000, bitrate: 64 kb/s
Stream #0:0: Audio: pcm_mulaw, 8000 Hz, 1 channels, s16, 64 kb/s
Input #1, video4linux2,v4l2, from '/dev/video1':
Duration: N/A, start: 1424887596.039777, bitrate: 162039 kb/s
Stream #1:0: Video: rawvideo (YUY2 / 0x32595559`enter code here`), yuyv422, 704x480, 162039 kb/s, 29.97 fps, 29.97 tbr, 1000k tbn, 1000k tbc
No pixel format specified, yuv422p for H.264 encoding chosen.
Use -pix_fmt yuv420p for compatibility with outdated media players.
[libx264 # 0xb61f900] using cpu capabilities: MMX2 SSE2Fast SSSE3 Cache64
[libx264 # 0xb61f900] profile High 4:2:2, level 2.2, 4:2:2 8-bit
Output #0, mpegts, to 'udp://225.1.1.15:30000':
Metadata:
encoder : Lavf56.15.102
Stream #0:0: Video: h264 (libx264), yuv422p, 704x480, q=-1--1, 200 kb/s, 3 fps, 90k tbn, 3 tbc
Metadata:
encoder : Lavc56.13.100 libx264
Stream #0:1: Audio: ac3, 8000 Hz, mono, fltp, 64 kb/s
Metadata:
encoder : Lavc56.13.100 ac3
Stream mapping:
Stream #1:0 -> #0:0 (rawvideo (native) -> h264 (libx264))
Stream #0:0 -> #0:1 (pcm_mulaw (native) -> ac3 (native))
Press [q] to stop, [?] for help
frame= 5 fps=0.0 q=12.0 size= 0kB time=00:00:00.33 bitrate= 0.0kbits/s dup=0 drop=12
Turns out the only way I was able to get the streams to run for an extended period was to split them into two independent streams.

ffmpeg: stream copy from .mxf into NLE-compatible format [closed]

Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 9 years ago.
Improve this question
Because my NLE software does not support the .mxf-files from Canon XF100 I need to convert them into a supported format.
As far as I know, mxf-files are just another container format for mpeg2 streams, so it would be really nice to extract the streams and place them into another container (without reencoding).
I think ffmpeg can do this – correct me if I'm wrong – by running the following command:
ffmpeg -i in.mxf -vcodec copy out.m2ts (or .ts, .mts, ...)
ffmpeg finishes without errors after about 2 seconds (in.mxf is abut 170mb):
c:\video>c:\ffmpeg\bin\ffmpeg -i in.MXF -vcodec copy out.m2ts
ffmpeg version N-53680-g0ab9362 Copyright (c) 2000-2013 the FFmpeg developers
built on May 30 2013 12:14:03 with gcc 4.7.3 (GCC)
configuration: --enable-gpl --enable-version3 --disable-w32threads --enable-av
isynth --enable-bzlib --enable-fontconfig --enable-frei0r --enable-gnutls --enab
le-iconv --enable-libass --enable-libbluray --enable-libcaca --enable-libfreetyp
e --enable-libgsm --enable-libilbc --enable-libmodplug --enable-libmp3lame --ena
ble-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-l
ibopus --enable-librtmp --enable-libschroedinger --enable-libsoxr --enable-libsp
eex --enable-libtheora --enable-libtwolame --enable-libvo-aacenc --enable-libvo-
amrwbenc --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libxavs --
enable-libxvid --enable-zlib
libavutil 52. 34.100 / 52. 34.100
libavcodec 55. 12.102 / 55. 12.102
libavformat 55. 8.100 / 55. 8.100
libavdevice 55. 2.100 / 55. 2.100
libavfilter 3. 73.100 / 3. 73.100
libswscale 2. 3.100 / 2. 3.100
libswresample 0. 17.102 / 0. 17.102
libpostproc 52. 3.100 / 52. 3.100
Guessed Channel Layout for Input Stream #0.1 : mono
Guessed Channel Layout for Input Stream #0.2 : mono
Input #0, mxf, from 'in.MXF':
Metadata:
uid : 1bb23c97-6205-4800-80a2-e00002244ba7
generation_uid : 1bb23c97-6205-4800-8122-e00002244ba7
company_name : CANON
product_name : XF100
product_version : 1.00
product_uid : 060e2b34-0401-010d-0e15-005658460100
modification_date: 2013-01-06 11:05:02
timecode : 01:42:14:22
Duration: 00:00:28.32, start: 0.000000, bitrate: 51811 kb/s
Stream #0:0: Video: mpeg2video (4:2:2), yuv422p, 1920x1080 [SAR 1:1 DAR 16:9
], 25 fps, 25 tbr, 25 tbn, 50 tbc
Stream #0:1: Audio: pcm_s16le, 48000 Hz, mono, s16, 768 kb/s
Stream #0:2: Audio: pcm_s16le, 48000 Hz, mono, s16, 768 kb/s
Output #0, mpegts, to 'out.m2ts':
Metadata:
uid : 1bb23c97-6205-4800-80a2-e00002244ba7
generation_uid : 1bb23c97-6205-4800-8122-e00002244ba7
company_name : CANON
product_name : XF100
product_version : 1.00
product_uid : 060e2b34-0401-010d-0e15-005658460100
modification_date: 2013-01-06 11:05:02
timecode : 01:42:14:22
encoder : Lavf55.8.100
Stream #0:0: Video: mpeg2video, yuv422p, 1920x1080 [SAR 1:1 DAR 16:9], q=2-3
1, 25 fps, 90k tbn, 25 tbc
Stream #0:1: Audio: mp2, 48000 Hz, mono, s16, 128 kb/s
Stream mapping:
Stream #0:0 -> #0:0 (copy)
Stream #0:1 -> #0:1 (pcm_s16le -> mp2)
Press [q] to stop, [?] for help
frame= 532 fps=0.0 q=-1.0 size= 143511kB time=00:00:21.25 bitrate=55314.1kbits
frame= 561 fps=435 q=-1.0 size= 151254kB time=00:00:22.42 bitrate=55242.0kbits
frame= 586 fps=314 q=-1.0 size= 158021kB time=00:00:23.41 bitrate=55288.0kbits
frame= 609 fps=255 q=-1.0 size= 164182kB time=00:00:24.34 bitrate=55235.4kbits
frame= 636 fps=217 q=-1.0 size= 171463kB time=00:00:25.42 bitrate=55235.1kbits
frame= 669 fps=194 q=-1.0 size= 180133kB time=00:00:26.72 bitrate=55226.3kbits
frame= 699 fps=173 q=-1.0 size= 188326kB time=00:00:27.92 bitrate=55256.6kbits
frame= 708 fps=169 q=-1.0 Lsize= 190877kB time=00:00:28.30 bitrate=55233.6kbit
s/s
video:172852kB audio:442kB subtitle:0 global headers:0kB muxing overhead 10.1461
18%
Unfortunately the output file turns out to be displayed correctly only by vlc player.
My NLE-software (Cyberlink Power Director) is able to open the file but most of the picture is green. Only a few pixels on the left edge show the original video:
output file
Any ideas how to solve that problem? Is there a better way to use .mxf-files in NLE-software without native support?
thanks in advance
Thanks to Carl
ffmpeg -fflags +genpts -i in.MXF -c copy out.mkv

Resources