ffmpeg command gives error when used in python - bash

When I run this command from the shell it works perfectly.
ffmpeg -nostdin -i /data/binil/v2t_final/output/cnbctv18/2018_07_02_14_38_30/tmp/merged.avi -ss 00:00:00 -vcodec h264 -vf fps=25 -to 00:6:43 /data/binil/v2t_final/output/cnbctv18/2018_07_02_14_38_30/1/1.avi
But the same thing when I do in python it gives error:
import sys
import os
INPUT_DIR = sys.argv[1]
INPUT_VIDEO = sys.argv[2]
OUTPUT_PATH = sys.argv[3]
SOURCE = sys.argv[4]
DATE = sys.argv[5]
INPUT = INPUT_DIR+"sorted_result.txt"
COUNT=1
initial="00:00:00"
with open(INPUT,"r") as f:
for line in f.readlines():
OUT_DIR = OUTPUT_PATH+str(COUNT)
directory = os.path.abspath(OUT_DIR)
print('OUT DIR',OUT_DIR)
print('directory',directory)
try:
os.mkdir(directory)
except:
pass
cmd_1 = "ffmpeg -nostdin -i "+INPUT_VIDEO+" -ss " +initial+ " -vcodec h264 -vf fps=25 -to " +line+ " " +OUT_DIR+"/"+str(COUNT)+".avi"
os.system(cmd_1)
COUNT += 1
initial=line
I cant understand the problem:
The error is as follows:
ffmpeg version 4.0-static https://johnvansickle.com/ffmpeg/ Copyright (c) 2000-2018 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-libxml2 --enable-fontconfig --enable-frei0r --enable-gnutls --enable-gray --enable-libaom --enable-libfribidi --enable-libass --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-libxvid --enable-libzimg
libavutil 56. 14.100 / 56. 14.100
libavcodec 58. 18.100 / 58. 18.100
libavformat 58. 12.100 / 58. 12.100
libavdevice 58. 3.100 / 58. 3.100
libavfilter 7. 16.100 / 7. 16.100
libswscale 5. 1.100 / 5. 1.100
libswresample 3. 1.100 / 3. 1.100
libpostproc 55. 1.100 / 55. 1.100
Trailing options were found on the commandline.
Input #0, avi, from '/data/binil/v2t_final/output/cnbctv18/2018_07_02_14_38_30/tmp/merged.avi':
Metadata:
encoder : Lavf58.12.100
Duration: 01:00:50.23, start: 0.000000, bitrate: 1334 kb/s
Stream #0:0: Video: h264 (High) (H264 / 0x34363248), yuv420p(progressive), 512x288 [SAR 1:1 DAR 16:9], 1001 kb/s, 25 fps, 25 tbr, 25 tbn, 50 tbc
Stream #0:1: Audio: mp3 (U[0][0][0] / 0x0055), 48000 Hz, stereo, fltp, 639 kb/s
At least one output file must be specified
sh: line 1: /data/binil/v2t_final/output/cnbctv18/2018_07_02_14_38_30/1/1.avi: Permission denied
Please help.
This is some dummy text I am writing because it looks like stack overflow does not accept less description and more code. Please don't mind these sentences. I cant believe that I am still writing this and it is still requesting me to add some more description. I am still doing it. Don't know till what extent do I have to write. I hope this much is enough.

Got the error.
The input file contains timestamps each one on a new line so it was taking the '\n' character along with the timestamp in the ffmpeg command. Hence it considered -vcodec as a new command and resulted in error.

Related

Is it possible to merge 3 videos with ffmpeg by -f concat and crossfade without video content

I want to merge 3 .mov files quickly without losing any resolution. I want to be able to distinguish the 3 pieces of videos after merge.
"ffmpeg -f concat" does not lose resolution and quick without crossfade.
But, I can't distinguish 3 videos.
As far as I know ffmpeg filter can be used add crossfade, but it have to use video start/end content to do the merger, which might involve transcoding. It won't be fast compared with 'concat', which won't do transcoding, but simply copying.
Here is the content (ffmpeg -i video.mov) of one of 3 videos:
ffmpeg version 4.1.3 Copyright (c) 2000-2019 the FFmpeg developers
built with Apple LLVM version 10.0.1 (clang-1001.0.46.3)
configuration: --prefix=/usr/local/Cellar/ffmpeg/4.1.3 --enable-shared --enable-pthreads --enable-version3 --enable-hardcoded-tables --enable-avresample --cc=clang --host-cflags='-I/Library/Java/JavaVirtualMachines/openjdk-12.jdk/Contents/Home/include -I/Library/Java/JavaVirtualMachines/openjdk-12.jdk/Contents/Home/include/darwin' --host-ldflags= --enable-ffplay --enable-gnutls --enable-gpl --enable-libaom --enable-libbluray --enable-libmp3lame --enable-libopus --enable-librubberband --enable-libsnappy --enable-libtesseract --enable-libtheora --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libx265 --enable-libxvid --enable-lzma --enable-libfontconfig --enable-libfreetype --enable-frei0r --enable-libass --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-librtmp --enable-libspeex --enable-videotoolbox --disable-libjack --disable-indev=jack --enable-libaom --enable-libsoxr
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 '..../(edited)/VMEK8375.MOV':
Metadata:
major_brand : qt
minor_version : 0
compatible_brands: qt
creation_time : 2019-06-30T01:28:04.000000Z
com.apple.quicktime.model: iPhone
com.apple.quicktime.software: ZHIYUN
com.apple.quicktime.creationdate: 2019-06-30T09:28:04Z
Duration: 00:00:07.61, start: 0.000000, bitrate: 4386 kb/s
Stream #0:0(und): Video: hevc (Main) (hvc1 / 0x31637668), yuv420p(tv, smpte170m/bt709/bt709), 1280x720, 4329 kb/s, 30.01 fps, 30 tbr, 600 tbn, 600 tbc (default)
Metadata:
creation_time : 2019-06-30T01:28:04.000000Z
handler_name : Core Media Video
encoder : HEVC
Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, mono, fltp, 94 kb/s (default)
Metadata:
creation_time : 2019-06-30T01:28:04.000000Z
handler_name : Core Media Audio
If I don't care about crossfade with video content, just some 'nice' black screen in between (It would be nice I add some text, like date + time on the black screen) is good enough for me. Is it possible to do 'concat' and simple crossfade without video 'content'?
Filtering requires re-encoding, so fading is not an option. Instead you can make videos that go between the main content.
Create middle videos. Ensure that you match the attributes of the main videos:
ffmpeg -y -f lavfi -i color=c=black:s=1280x720:r=30 -f lavfi -i anullsrc=channel_layout=mono:sample_rate=44100 -vf "drawtext=text='your text':fontsize=24:fontcolor=white:x=(w-text_w)/2:y=(h-text_h)/2" -c:v libx265 -profile:v main -c:a aac -tag:v hvc1 -t 5 -video_track_timescale 600 black1.mov
Make input.txt:
file '1.mov'
file 'black1.mov'
file '2.mov'
file 'black2.mov'
file '3.mov'
Then use concat demuxer:
ffmpeg -f concat -i input.txt -c copy output.mov

Raspberry pi live stream to youtube stopped working

I have a working setup for streaming a video to youtube with my raspberry pi 3.
It was work until yesterday. Nothing changed but I have an error when I try to start the stream.
Running the following command:
raspivid -o - -t 0 -w 1280 -h 720 -p -hf -fps 25 -b 2560000 | avconv -re -ar 44100 -ac 2 -acodec pcm_s16le -f s16le -ac 2 -i /dev/zero -f h264 -i - -vcodec copy -acodec aac -ab 128k -g 50 -strict experimental -f flv rtmp://a.rtmp.youtube.com/live2/my_key
And get this error:
ffmpeg version 3.2.10-1~deb9u1+rpt1 Copyright (c) 2000-2018 the FFmpeg
developers built with gcc 6.3.0 (Raspbian 6.3.0-18+rpi1) 20170516
configuration: --prefix=/usr --extra-version='1~deb9u1+rpt1'
--toolchain=hardened --libdir=/usr/lib/arm-linux-gnueabihf --incdir=/usr/include/arm-linux-gnueabihf --enable-gpl --disable-stripping --enable-avresample --enable-avisynth --enable-gnutls --enable-ladspa --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libebur128 --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libmp3lame --enable-libopenjpeg --enable-libopenmpt --enable-libopus --enable-libpulse --enable-librubberband --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-libzmq --enable-libzvbi --enable-omx-rpi --enable-mmal --enable-openal --enable-opengl --enable-sdl2 --enable-libdc1394 --enable-libiec61883 --enable-chromaprint --enable-frei0r --enable-libopencv --enable-libx264 --enable-shared 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 libavresample 3. 1. 0 / 3. 1. 0 libswscale 4. 2.100 / 4. 2.100 libswresample 2. 3.100 / 2. 3.100 libpostproc 54. 1.100 /
54. 1.100 Guessed Channel Layout for Input Stream #0.0 : stereo Input #0, s16le, from '/dev/zero': Duration: N/A, bitrate: 1411 kb/s
Stream #0:0: Audio: pcm_s16le, 44100 Hz, stereo, s16, 1411 kb/s Input #1, h264, from 'pipe:': Duration: N/A, bitrate: N/A
Stream #1:0: Video: h264 (High), yuv420p(progressive), 1280x720, 25 fps, 25 tbr, 1200k tbn, 50 tbc
rtmp://a.rtmp.youtube.com/live2/my_key: Input/output error
It worked more over a month, but now (I don't know why) stopped working.
Can anyone help me?
Cheers,
Greg
I figured it out!
If you have the same problem just go to youtube stream now / encoder setup / stream name/key, push the reveal button and then the reset button to get a new stream name/key string.
Use the new key!

Use ffmpeg for incoming youtube HLS live stream and output to rtmp

I can't get ffmpeg to work with live streams from youtube. Normal non-live videos work just fine. But with live streams ffmpeg seems like it doesn't make enough requests for new segments. It basically downloads, say a 3 second segment, then nothing happens for 10 seconds or so, then it downloads a new segment, repeat...
ffmpeg -i '$(./youtube-dl -f best -g https://www.youtube.com/watch?v=emGI3UrzIMc)' -f flv rtmp://192.168.0.11/myapp/mystream
So what's the automagic command?
ffmpeg version:
ffmpeg version 3.4.2 Copyright (c) 2000-2018 the FFmpeg developers
built with gcc 7.3.0 (Rev1, Built by MSYS2 project)
configuration: --prefix=/mingw64 --target-os=mingw32 --arch=x86_64 --disable-debug --disable-static --enable-avresample --enable-dxva2 --enable-d3d11va --enable-fontconfig --enable-gnutls --enable-gpl --enable-libass --enable-libbluray --enable-libcaca --enable-libcelt --enable-libfreetype --enable-libgsm --enable-libmodplug --enable-libmp3lame --enable-libopencore_amrnb --enable-libopencore_amrwb --enable-libopenjpeg --enable-libopus --enable-librtmp --enable-libspeex --enable-libtheora --enable-libvorbis --enable-libx264 --enable-libx265 --enable-libxvid --enable-libvpx --enable-libwebp --enable-openal --enable-libwavpack --enable-pic --enable-postproc --enable-runtime-cpudetect --enable-shared --enable-static --enable-swresample --enable-version3 --enable-zlib --disable-doc
libavutil 55. 78.100 / 55. 78.100
libavcodec 57.107.100 / 57.107.100
libavformat 57. 83.100 / 57. 83.100
libavdevice 57. 10.100 / 57. 10.100
libavfilter 6.107.100 / 6.107.100
libavresample 3. 7. 0 / 3. 7. 0
libswscale 4. 8.100 / 4. 8.100
libswresample 2. 9.100 / 2. 9.100
libpostproc 54. 7.100 / 54. 7.100
youtube-dl version: 2018.03.14
Following is the output of the command above. The <MY NOTE #> is added by me for description purposes.
At start execution goes smoothly. It then freezes for 10 or 15 sec at <MY NOTE 1>. It then downloads the part of the stream - <MY NOTE 2>, plays is, then freezes again for some seconds. Then downloads the next part - <MY NOTE 3>, plays it, freezes, and so on...
$ ffmpeg -i '$(./youtube-dl -f best -g https://www.youtube.com/watch?v=emGI3UrzIMc)' -f flv rtmp://192.168.0.11/myapp/mystream
ffmpeg version 3.4.2 Copyright (c) 2000-2018 the FFmpeg developers
built with gcc 7.3.0 (Rev1, Built by MSYS2 project)
configuration: --prefix=/mingw64 --target-os=mingw32 --arch=x86_64 --disable-debug --disable-static --enable-avresample --enable-dxva2 --enable-d3d11va --enable-fontconfig --enable-gnutls --enable-gpl --enable-libass --enable-libbluray --enable-libcaca --enable-libcelt --enable-libfreetype --enable-libgsm --enable-libmodplug --enable-libmp3lame --enable-libopencore_amrnb --enable-libopencore_amrwb --enable-libopenjpeg --enable-libopus --enable-librtmp --enable-libspeex --enable-libtheora --enable-libvorbis --enable-libx264 --enable-libx265 --enable-libxvid --enable-libvpx --enable-libwebp --enable-openal --enable-libwavpack --enable-pic --enable-postproc --enable-runtime-cpudetect --enable-shared --enable-static --enable-swresample --enable-version3 --enable-zlib --disable-doc
libavutil 55. 78.100 / 55. 78.100
libavcodec 57.107.100 / 57.107.100
libavformat 57. 83.100 / 57. 83.100
libavdevice 57. 10.100 / 57. 10.100
libavfilter 6.107.100 / 6.107.100
libavresample 3. 7. 0 / 3. 7. 0
libswscale 4. 8.100 / 4. 8.100
libswresample 2. 9.100 / 2. 9.100
libpostproc 54. 7.100 / 54. 7.100
[hls,applehttp # 00000287da404cc0] Opening 'https://r4---sn-cap1vv-nv4l.googlevideo.com/videoplayback/id/emGI3UrzIMc.0/itag/95/source/yt_live_broadcast/requiressl/yes/ratebypass/yes/live/1/cmbypass/yes/goi/160/sgoap/gir%3Dyes%3Bitag%3D140/sgovp/gir%3Dyes%3Bitag%3D136/hls_chunk_host/r4---sn-cap1vv-nv4l.googlevideo.com/ei/6jiqWt7SIJKD8gPimZTACA/playlist_type/DVR/gcr/bg/initcwndbps/10410/mm/32/mn/sn-cap1vv-nv4l/ms/lv/mv/m/pcm2cms/yes/pl/16/keepalive/yes/mt/1521105015/ip/130.204.135.162/ipbits/0/expire/1521126730/sparams/ip,ipbits,expire,id,itag,source,requiressl,ratebypass,live,cmbypass,goi,sgoap,sgovp,hls_chunk_host,ei,playlist_type,gcr,initcwndbps,mm,mn,ms,mv,pcm2cms,pl/signature/503304477BD05CCC71061344F8BB23195E152A32.512A84732C501AF08AC9340181A75D34C5B2FF77/key/dg_yt0/playlist/index.m3u8/sq/1308292/goap/clen%3D48852%3Blmt%3D1520930742662673/govp/clen%3D347004%3Blmt%3D1520930742662679/dur/2.000/file/seg.ts' for reading
Input #0, hls,applehttp, from 'https://manifest.googlevideo.com/api/manifest/hls_playlist/id/emGI3UrzIMc.0/itag/95/source/yt_live_broadcast/requiressl/yes/ratebypass/yes/live/1/cmbypass/yes/goi/160/sgoap/gir%3Dyes%3Bitag%3D140/sgovp/gir%3Dyes%3Bitag%3D136/hls_chunk_host/r4---sn-cap1vv-nv4l.googlevideo.com/ei/6jiqWt7SIJKD8gPimZTACA/playlist_type/DVR/gcr/bg/initcwndbps/10410/mm/32/mn/sn-cap1vv-nv4l/ms/lv/mv/m/pcm2cms/yes/pl/16/dover/10/keepalive/yes/mt/1521105015/ip/130.204.135.162/ipbits/0/expire/1521126730/sparams/ip,ipbits,expire,id,itag,source,requiressl,ratebypass,live,cmbypass,goi,sgoap,sgovp,hls_chunk_host,ei,playlist_type,gcr,initcwndbps,mm,mn,ms,mv,pcm2cms,pl/signature/503304477BD05CCC71061344F8BB23195E152A32.512A84732C501AF08AC9340181A75D34C5B2FF77/key/dg_yt0/playlist/index.m3u8':
Duration: N/A, start: 39603.798400, bitrate: N/A
Program 0
Metadata:
variant_bitrate : 0
Stream #0:0: Audio: aac (LC) ([15][0][0][0] / 0x000F), 48000 Hz, stereo, fltp
Metadata:
variant_bitrate : 0
Stream #0:1: Video: h264 (Main) ([27][0][0][0] / 0x001B), yuv420p, 1280x720 [SAR 1:1 DAR 16:9], 30 fps, 30 tbr, 90k tbn, 60 tbc
Metadata:
variant_bitrate : 0
Stream mapping:
Stream #0:1 -> #0:0 (h264 (native) -> flv1 (flv))
Stream #0:0 -> #0:1 (aac (native) -> mp3 (libmp3lame))
Press [q] to stop, [?] for help
Output #0, flv, to 'rtmp://192.168.0.11/myapp/mystream':
Metadata:
encoder : Lavf57.83.100
Stream #0:0: Video: flv1 (flv) ([2][0][0][0] / 0x0002), yuv420p, 1280x720 [SAR 1:1 DAR 16:9], q=2-31, 200 kb/s, 30 fps, 1k tbn, 30 tbc
Metadata:
variant_bitrate : 0
encoder : Lavc57.107.100 flv
Side data:
cpb: bitrate max/min/avg: 0/0/200000 buffer size: 0 vbv_delay: -1
Stream #0:1: Audio: mp3 (libmp3lame) ([2][0][0][0] / 0x0002), 48000 Hz, stereo, fltp
Metadata:
variant_bitrate : 0
<MY NOTE 1>encoder : Lavc57.107.100 libmp3lame
<MY NOTE 2>[hls,applehttp # 00000287da404cc0] Opening 'https://r4---sn-cap1vv-nv4l.googlevideo.com/videoplayback/id/emGI3UrzIMc.0/itag/95/source/yt_live_broadcast/requiressl/yes/ratebypass/yes/live/1/cmbypass/yes/goi/160/sgoap/gir%3Dyes%3Bitag%3D140/sgovp/gir%3Dyes%3Bitag%3D136/hls_chunk_host/r4---sn-cap1vv-nv4l.googlevideo.com/ei/6jiqWt7SIJKD8gPimZTACA/playlist_type/DVR/gcr/bg/initcwndbps/10410/mm/32/mn/sn-cap1vv-nv4l/ms/lv/mv/m/pcm2cms/yes/pl/16/keepalive/yes/mt/1521105015/ip/130.204.135.162/ipbits/0/expire/1521126730/sparams/ip,ipbits,expire,id,itag,source,requiressl,ratebypass,live,cmbypass,goi,sgoap,sgovp,hls_chunk_host,ei,playlist_type,gcr,initcwndbps,mm,mn,ms,mv,pcm2cms,pl/signature/503304477BD05CCC71061344F8BB23195E152A32.512A84732C501AF08AC9340181A75D34C5B2FF77/key/dg_yt0/playlist/index.m3u8/sq/1308293/goap/clen%3D48853%3Blmt%3D1520930742662680/govp/clen%3D404944%3Blmt%3D1520930742662686/dur/2.000/file/seg.ts' for reading
<MY NOTE 3>[hls,applehttp # 00000287da404cc0] Opening 'https://r4---sn-cap1vv-nv4l.googlevideo.com/videoplayback/id/emGI3UrzIMc.0/itag/95/source/yt_live_broadcast/requiressl/yes/ratebypass/yes/live/1/cmbypass/yes/goi/160/sgoap/gir%3Dyes%3Bitag%3D140/sgovp/gir%3Dyes%3Bitag%3D136/hls_chunk_host/r4---sn-cap1vv-nv4l.googlevideo.com/ei/6jiqWt7SIJKD8gPimZTACA/playlist_type/DVR/gcr/bg/initcwndbps/10410/mm/32/mn/sn-cap1vv-nv4l/ms/lv/mv/m/pcm2cms/yes/pl/16/keepalive/yes/mt/1521105015/ip/130.204.135.162/ipbits/0/expire/1521126730/sparams/ip,ipbits,expire,id,itag,source,requiressl,ratebypass,live,cmbypass,goi,sgoap,sgovp,hls_chunk_host,ei,playlist_type,gcr,initcwndbps,mm,mn,ms,mv,pcm2cms,pl/signature/503304477BD05CCC71061344F8BB23195E152A32.512A84732C501AF08AC9340181A75D34C5B2FF77/key/dg_yt0/playlist/index.m3u8/sq/1308294/goap/clen%3D48852%3Blmt%3D1520930742662688/govp/clen%3D403294%3Blmt%3D1520930742662693/dur/2.000/file/seg.ts' for reading
[hls,applehttp # 00000287da404cc0] Opening 'https://r4---sn-cap1vv-nv4l.googlevideo.com/videoplayback/id/emGI3UrzIMc.0/itag/95/source/yt_live_broadcast/requiressl/yes/ratebypass/yes/live/1/cmbypass/yes/goi/160/sgoap/gir%3Dyes%3Bitag%3D140/sgovp/gir%3Dyes%3Bitag%3D136/hls_chunk_host/r4---sn-cap1vv-nv4l.googlevideo.com/ei/6jiqWt7SIJKD8gPimZTACA/playlist_type/DVR/gcr/bg/initcwndbps/10410/mm/32/mn/sn-cap1vv-nv4l/ms/lv/mv/m/pcm2cms/yes/pl/16/keepalive/yes/mt/1521105015/ip/130.204.135.162/ipbits/0/expire/1521126730/sparams/ip,ipbits,expire,id,itag,source,requiressl,ratebypass,live,cmbypass,goi,sgoap,sgovp,hls_chunk_host,ei,playlist_type,gcr,initcwndbps,mm,mn,ms,mv,pcm2cms,pl/signature/503304477BD05CCC71061344F8BB23195E152A32.512A84732C501AF08AC9340181A75D34C5B2FF77/key/dg_yt0/playlist/index.m3u8/sq/1308295/goap/clen%3D48355%3Blmt%3D1520930742662695/govp/clen%3D358330%3Blmt%3D1520930742662700/dur/2.000/file/seg.ts' for reading
[hls,applehttp # 00000287da404cc0] Opening 'https://r4---sn-cap1vv-nv4l.googlevideo.com/videoplayback/id/emGI3UrzIMc.0/itag/95/source/yt_live_broadcast/requiressl/yes/ratebypass/yes/live/1/cmbypass/yes/goi/160/sgoap/gir%3Dyes%3Bitag%3D140/sgovp/gir%3Dyes%3Bitag%3D136/hls_chunk_host/r4---sn-cap1vv-nv4l.googlevideo.com/ei/6jiqWt7SIJKD8gPimZTACA/playlist_type/DVR/gcr/bg/initcwndbps/10410/mm/32/mn/sn-cap1vv-nv4l/ms/lv/mv/m/pcm2cms/yes/pl/16/keepalive/yes/mt/1521105015/ip/130.204.135.162/ipbits/0/expire/1521126730/sparams/ip,ipbits,expire,id,itag,source,requiressl,ratebypass,live,cmbypass,goi,sgoap,sgovp,hls_chunk_host,ei,playlist_type,gcr,initcwndbps,mm,mn,ms,mv,pcm2cms,pl/signature/503304477BD05CCC71061344F8BB23195E152A32.512A84732C501AF08AC9340181A75D34C5B2FF77/key/dg_yt0/playlist/index.m3u8/sq/1308296/goap/clen%3D48852%3Blmt%3D1520930742662701/govp/clen%3D347658%3Blmt%3D1520930742662707/dur/2.000/file/seg.ts' for reading
frame= 225 fps=1.8 q=31.0 size= 947kB time=00:00:07.92 bitrate= 979.2kbits/s speed=0.0625x
And you don't have to output to a rtmp. Can be a local file - behavior is the same.
Try using the hls prefix. Example:
ffmpeg -i "hls+$(./youtube-dl -f best -g https://www.youtube.com/watch?v=emGI3UrzIMc)" -f flv rtmp://192.168.0.11/myapp/mystream

Cannot retrieve duration of webm file using ffmpeg

I am trying to retrieve the duration of a .webm video file that I recorded using the the video.js plugin (https://github.com/collab-project/videojs-record).
I am using ffmpeg to get the duration but it always return N/A:
ffprobe version 3.0.2-static http://johnvansickle.com/ffmpeg/ Copyright (c) 2007-2016 the FFmpeg developers
built with gcc 5.3.1 (Debian 5.3.1-16) 20160424
configuration: --enable-gpl --enable-version3 --enable-static --disable-debug --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-amrwbenc --enable-gray --enable-libopenjpeg --enable-libopus --enable-libass --enable-gnutls --enable-libvidstab --enable-libsoxr --enable-frei0r --enable-libfribidi --disable-indev=sndio --disable-outdev=sndio --enable-librtmp --enable-libmfx --enable-libzimg --cc=gcc
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
libswscale 4. 0.100 / 4. 0.100
libswresample 2. 0.101 / 2. 0.101
libpostproc 54. 0.100 / 54. 0.100
Input #0, matroska,webm, from '/home/demoss/public_html/source/bALRt9I697PVQh4zglou.webm':
Metadata:
encoder : Chrome
Duration: N/A, start: 0.000000, bitrate: N/A
Stream #0:0(eng): Video: vp8, yuv420p, 640x480, SAR 1:1 DAR 4:3, 30 fps, 30 tbr, 1k tbn, 1k tbc (default)
Stream #0:1(eng): Audio: opus, 48000 Hz, mono, fltp (default)
duration=N/A
I don't think the video is corrupted as it played in my VideoJS player without issues.
Any pointers as to why its not returning the duration would be greatly appreciated. I wouldn't mind using an alternative library as well
Thanks
If ffprobe/ffmpeg does not show the format or stream durations then you can fully decode the file to find the duration:
ffmpeg -i input.webm -f null -
...
frame= 2087 fps=0.0 q=-0.0 Lsize=N/A time=00:01:23.48 bitrate=N/A speed= 123x
Refer to time= in the second-to-last line in the output. In this example the file duration is 00:01:23.48.
Depending on the duration and complexity of your input this may take some time.
Also see FFmpeg Wiki: FFprobe Tips - Duration.
I was able to convert the webm to mp4 using the following command:
ffmpeg -fflags +genpts -i myfile.webm -r 24 mynew.mp4
I am not quite sure of how it works internally, but I hope the experts could expand on this.
Hope this helps someone

Error while concating mkv files using ffmpeg in cygwin based shell script

I have written cygwin based shell script to concate 2 .mkv files as below,
#!/bin/sh
ffmpeg -f concat -i concat.txt -codec copy out.mkv
concat.txt contains path to 2 mkv files to be concatenated
file '../temp/1'
file '../temp/2'
when I run script from cygwin terminal I get following error
Rishi#Rishikesh /cygdrive/i/video/Interface_code/Testing_function/bin
$ . script.sh
ffmpeg version 2.5.2 Copyright (c) 2000-2014 the FFmpeg developers
built on Dec 30 2014 17:13:24 with gcc 4.9.2 (GCC)
configuration: --enable-gpl --enable-version3 --disable-w32threads --enable- avisynth --enable-bzlib --enable-fontconfig --enable-frei0r --enable-gnutls --enable-iconv --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libfreetype --enable-libgme --enable-libgsm --enable-libilbc --enable-libmodplug --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-librtmp -- enable-libschroedinger --enable-libsoxr --enable-libspeex --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvo-aacenc --enable-libvo-amrwbenc --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxavs --enable-libxvid --enable-lzma --enable-decklink --enable-zlib
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
Guessed Channel Layout for Input Stream #0.1 : stereo
Input #0, concat, from 'concat.txt':
Duration: N/A, start: 0.000000, bitrate: 1536 kb/s
Stream #0:0: Video: h264 (High), yuv420p, 720x576 [SAR 1:1 DAR 5:4], 25 fps, 25 tbr, 1k tbn, 50 tbc
Stream #0:1: Audio: pcm_s16le, 48000 Hz, 2 channels, s16, 1536 kb/s
'NULL # 04780280] Unable to find a suitable output format for 'out.mkv
: Invalid argument
another thing to add, if I run this command from cygwin terminal directly(instead of calling it through script) it runs correctly and creates concatenated output .mkv file
Applying dos2unix command on shell script file solved my problem. Hope it helps someone.

Resources